svx/source/inc/svdpdf.hxx    |    9 ++++++---
 svx/source/svdraw/svdpdf.cxx |   35 ++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 16 deletions(-)

New commits:
commit aff38cde533a61593ab0a03befb27a08819d6a97
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Oct 17 19:38:26 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sun Oct 26 18:27:50 2025 +0100

    separate ImpSdrPdfImport's by prefix
    
    Change-Id: Icbd642126e2debe63bfac5a34542a7914bbdb9d3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192592
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193004
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index c0783ff3fb5a..92f3f18f1447 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -173,10 +173,13 @@ class ImpSdrPdfImport final
 
 #if HAVE_FEATURE_PDFIMPORT
 
-    static ImportedFontMap CollectFonts(vcl::pdf::PDFiumDocument& 
rPdfDocument);
+    static ImportedFontMap CollectFonts(sal_Int64 nPrefix, 
vcl::pdf::PDFiumDocument& rPdfDocument);
 
-    static EmbeddedFontInfo convertToOTF(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
-                                         const OUString& fontName, const 
OUString& baseFontName,
+    sal_Int64 getPrefix() const { return reinterpret_cast<sal_Int64>(this); }
+
+    static EmbeddedFontInfo convertToOTF(sal_Int64 prefix, SubSetInfo& 
rSubSetInfo,
+                                         const OUString& fileUrl, const 
OUString& fontName,
+                                         const OUString& baseFontName,
                                          std::u16string_view fontFileName,
                                          const std::vector<uint8_t>& 
toUnicodeData,
                                          const vcl::pdf::PDFiumFont& font);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 333260ac8ffc..3d8a178e067c 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -125,7 +125,8 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
         mxImportedFonts = xGrfLink->getImportedFonts();
     if (!mxImportedFonts)
     {
-        mxImportedFonts = 
std::make_shared<ImportedFontMap>(CollectFonts(*mpPdfDocument));
+        mxImportedFonts
+            = std::make_shared<ImportedFontMap>(CollectFonts(getPrefix(), 
*mpPdfDocument));
         if (xGrfLink)
             xGrfLink->setImportedFonts(mxImportedFonts);
     }
@@ -224,11 +225,19 @@ OUString stripPostScriptStyle(const OUString& 
postScriptName, FontWeight& eWeigh
     }
     return sFontName;
 }
+
+OUString getFileUrlForTemporaryFont(sal_Int64 prefix, std::u16string_view name,
+                                    std::u16string_view suffix)
+{
+    return EmbeddedFontsManager::getFileUrlForTemporaryFont(
+        Concat2View(OUString::number(prefix) + name), suffix);
+}
 }
 
 // Possibly there is some alternative route to query pdfium for all fonts 
without
 // iterating through every object to see what font each uses
-ImportedFontMap ImpSdrPdfImport::CollectFonts(vcl::pdf::PDFiumDocument& 
rPdfDocument)
+ImportedFontMap ImpSdrPdfImport::CollectFonts(sal_Int64 nPrefix,
+                                              vcl::pdf::PDFiumDocument& 
rPdfDocument)
 {
     ImportedFontMap aImportedFonts;
 
@@ -323,8 +332,8 @@ ImportedFontMap 
ImpSdrPdfImport::CollectFonts(vcl::pdf::PDFiumDocument& rPdfDocu
                 bool bTTF = EmbeddedFontsManager::analyzeTTF(aFontData.data(), 
aFontData.size(),
                                                              eFontWeight);
                 SAL_INFO_IF(!bTTF, "sd.filter", "not ttf/otf, converting");
-                OUString fileUrl = 
EmbeddedFontsManager::getFileUrlForTemporaryFont(
-                    sFontFileName, bTTF ? u".ttf" : u".t1");
+                OUString fileUrl
+                    = getFileUrlForTemporaryFont(nPrefix, sFontFileName, bTTF 
? u".ttf" : u".t1");
                 if (!writeFontFile(fileUrl, aFontData))
                     SAL_WARN("sd.filter", "ttf not written");
                 else
@@ -335,7 +344,7 @@ ImportedFontMap 
ImpSdrPdfImport::CollectFonts(vcl::pdf::PDFiumDocument& rPdfDocu
                 if (!bTTF || !aToUnicodeData.empty())
                 {
                     EmbeddedFontInfo fontInfo
-                        = convertToOTF(*pSubSetInfo, fileUrl, sFontName, 
sPostScriptName,
+                        = convertToOTF(nPrefix, *pSubSetInfo, fileUrl, 
sFontName, sPostScriptName,
                                        sFontFileName, aToUnicodeData, *font);
                     fileUrl = fontInfo.sFontFile;
                     sFontName = fontInfo.sFontName;
@@ -1621,7 +1630,7 @@ static OUString buildFontMenuName(const OUString& 
FontMenuNameDBUrl,
 }
 
 // 
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5900.RFMFAH_Tutorial.pdf
-static EmbeddedFontInfo mergeFontSubsets(const OUString& mergedFontUrl,
+static EmbeddedFontInfo mergeFontSubsets(sal_Int64 prefix, const OUString& 
mergedFontUrl,
                                          const OUString& FontMenuNameDBUrl,
                                          const OUString& postScriptName,
                                          const OUString& longFontName, 
std::string_view Weight,
@@ -1767,7 +1776,7 @@ static EmbeddedFontInfo mergeFontSubsets(const OUString& 
mergedFontUrl,
         Features.Close();
     }
 
-    OUString otfUrl = 
EmbeddedFontsManager::getFileUrlForTemporaryFont(postScriptName, u".otf");
+    OUString otfUrl = getFileUrlForTemporaryFont(prefix, postScriptName, 
u".otf");
     OUString features = !ligatureGlyphToChars.empty() ? mergedFeaturesUrl : 
OUString();
     if (EmbeddedFontsManager::makeotf(mergedFontUrl, otfUrl, 
FontMenuNameDBUrl, mergedCMapUrl,
                                       features))
@@ -1777,8 +1786,8 @@ static EmbeddedFontInfo mergeFontSubsets(const OUString& 
mergedFontUrl,
 }
 
 //static
-EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
-                                               const OUString& fontName,
+EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(sal_Int64 prefix, SubSetInfo& 
rSubSetInfo,
+                                               const OUString& fileUrl, const 
OUString& fontName,
                                                const OUString& postScriptName,
                                                std::u16string_view 
fontFileName,
                                                const std::vector<uint8_t>& 
toUnicodeData,
@@ -1833,13 +1842,13 @@ EmbeddedFontInfo 
ImpSdrPdfImport::convertToOTF(SubSetInfo& rSubSetInfo, const OU
     if (rSubSetInfo.aComponents.size() > 1)
     {
         OUString mergedFontUrl
-            = EmbeddedFontsManager::getFileUrlForTemporaryFont(postScriptName, 
u".merged.pfa.cid");
-        return mergeFontSubsets(mergedFontUrl, FontMenuNameDBUrl, 
postScriptName, longFontName,
-                                Weight, rSubSetInfo);
+            = getFileUrlForTemporaryFont(prefix, postScriptName, 
u".merged.pfa.cid");
+        return mergeFontSubsets(prefix, mergedFontUrl, FontMenuNameDBUrl, 
postScriptName,
+                                longFontName, Weight, rSubSetInfo);
     }
 
     // Otherwise not merged font, just a single subset
-    OUString otfUrl = 
EmbeddedFontsManager::getFileUrlForTemporaryFont(fontFileName, u".otf");
+    OUString otfUrl = getFileUrlForTemporaryFont(prefix, fontFileName, 
u".otf");
     OUString cmap = bCMap ? CMapUrl : OUString();
     if (EmbeddedFontsManager::makeotf(pfaCIDUrl, otfUrl, FontMenuNameDBUrl, 
cmap, FeaturesUrl))
         return { longFontName, otfUrl, toOfficeWeight(Weight) };

Reply via email to