svx/source/svdraw/svdpdf.cxx |   77 ++++++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 33 deletions(-)

New commits:
commit 161c36a1ddc5a9372a06bf684ff7e429db036fdb
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Oct 15 17:27:08 2025 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Oct 17 14:04:33 2025 +0200

    split out current use as new class and ctor
    
    Change-Id: Ifb387d6d1a00aa5c1338a37f08349efe2116aa3a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192461
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 04816ddcf2f5..709eb9a452e1 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1264,43 +1264,54 @@ const char cmapsuffix[] = "endcmap
"
                           "end
"
                           "end
";
 
-static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& 
Features,
-                                 std::string_view FontName,
-                                 const std::vector<uint8_t>& toUnicodeData, 
bool bNameKeyed,
-                                 std::map<int, int>& nameIndexToGlyph, 
SubSetInfo& rSubSetInfo)
+namespace
+{
+struct ToUnicodeData
 {
-    SvFileStream CMap(CMapUrl, StreamMode::READWRITE | StreamMode::TRUNC);
-
-    CMap.WriteBytes(cmapprefix, std::size(cmapprefix) - 1);
-
-    SvMemoryStream aInCMap(const_cast<uint8_t*>(toUnicodeData.data()), 
toUnicodeData.size(),
-                           StreamMode::READ);
-
     std::vector<OString> bfcharlines;
     std::vector<OString> bfcharranges;
 
-    OString sLine;
-    while (aInCMap.ReadLine(sLine))
+    ToUnicodeData(const std::vector<uint8_t>& toUnicodeData)
     {
-        if (sLine.endsWith("beginbfchar"))
+        SvMemoryStream aInCMap(const_cast<uint8_t*>(toUnicodeData.data()), 
toUnicodeData.size(),
+                               StreamMode::READ);
+
+        OString sLine;
+        while (aInCMap.ReadLine(sLine))
         {
-            while (aInCMap.ReadLine(sLine))
+            if (sLine.endsWith("beginbfchar"))
             {
-                if (sLine.endsWith("endbfchar"))
-                    break;
-                bfcharlines.push_back(sLine);
+                while (aInCMap.ReadLine(sLine))
+                {
+                    if (sLine.endsWith("endbfchar"))
+                        break;
+                    bfcharlines.push_back(sLine);
+                }
             }
-        }
-        else if (sLine.endsWith("beginbfrange"))
-        {
-            while (aInCMap.ReadLine(sLine))
+            else if (sLine.endsWith("beginbfrange"))
             {
-                if (sLine.endsWith("endbfrange"))
-                    break;
-                bfcharranges.push_back(sLine);
+                while (aInCMap.ReadLine(sLine))
+                {
+                    if (sLine.endsWith("endbfrange"))
+                        break;
+                    bfcharranges.push_back(sLine);
+                }
             }
         }
     }
+};
+}
+
+static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& 
Features,
+                                 std::string_view FontName,
+                                 const std::vector<uint8_t>& toUnicodeData, 
bool bNameKeyed,
+                                 std::map<int, int>& nameIndexToGlyph, 
SubSetInfo& rSubSetInfo)
+{
+    SvFileStream CMap(CMapUrl, StreamMode::READWRITE | StreamMode::TRUNC);
+
+    CMap.WriteBytes(cmapprefix, std::size(cmapprefix) - 1);
+
+    ToUnicodeData tud(toUnicodeData);
 
     sal_Int32 mergeOffset = 1; //Leave space for notdef
     for (const auto& count : rSubSetInfo.aComponents)
@@ -1309,11 +1320,11 @@ static void buildCMapAndFeatures(const OUString& 
CMapUrl, SvFileStream& Features
     std::map<sal_Int32, OString> ligatureGlyphToChars;
     std::vector<sal_Int32> glyphs;
 
-    if (!bfcharranges.empty())
+    if (!tud.bfcharranges.empty())
     {
         std::vector<OString> cidranges;
 
-        for (const auto& charrange : bfcharranges)
+        for (const auto& charrange : tud.bfcharranges)
         {
             assert(charrange[0] == '<');
             sal_Int32 nEnd = charrange.indexOf('>', 1);
@@ -1339,7 +1350,7 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, 
SvFileStream& Features
                 OStringBuffer aBuffer("<");
                 appendFourByteHex(aBuffer, nGlyphRangeStart);
                 aBuffer.append("> " + sChars);
-                bfcharlines.push_back(aBuffer.toString());
+                tud.bfcharlines.push_back(aBuffer.toString());
                 continue;
             }
 
@@ -1359,7 +1370,7 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, 
SvFileStream& Features
                 aBuffer.append("> <");
                 appendFourByteHex(aBuffer, nCharRangeStart);
                 aBuffer.append(">");
-                bfcharlines.push_back(aBuffer.toString());
+                tud.bfcharlines.push_back(aBuffer.toString());
                 continue;
             }
 
@@ -1386,11 +1397,11 @@ static void buildCMapAndFeatures(const OUString& 
CMapUrl, SvFileStream& Features
         }
     }
 
-    if (!bfcharlines.empty())
+    if (!tud.bfcharlines.empty())
     {
-        OString beginline = OString::number(bfcharlines.size()) + " 
begincidchar";
+        OString beginline = OString::number(tud.bfcharlines.size()) + " 
begincidchar";
         CMap.WriteLine(beginline);
-        for (const auto& charline : bfcharlines)
+        for (const auto& charline : tud.bfcharlines)
         {
             assert(charline[0] == '<');
             sal_Int32 nEnd = charline.indexOf('>', 1);
@@ -1420,7 +1431,7 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, 
SvFileStream& Features
         }
         CMap.WriteLine("endcidchar");
 
-        rSubSetInfo.aComponents.back().nGlyphCount = bfcharlines.size();
+        rSubSetInfo.aComponents.back().nGlyphCount = tud.bfcharlines.size();
     }
 
     CMap.WriteBytes(cmapsuffix, std::size(cmapsuffix) - 1);

Reply via email to