svx/source/inc/svdpdf.hxx | 7 +++++-- svx/source/svdraw/svdpdf.cxx | 31 +++++++++++++++++++------------ test/source/xmltesttools.cxx | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-)
New commits: commit 3e1d226c18b25641a2197f9ff6fc5aa781b52851 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 15 14:51:47 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 22:59:38 2025 +0200 replace xmlParseDoc with xmlReadDoc XML_PARSE_NODICT is mentioned in the doc as the equivalent of the xmlParseDoc default, and add XML_PARSE_HUGE which is the motivation for the change so xml with embedded fonts can still be asserted about Change-Id: I139bfeb06bc51b5cbd956655977d18a13f0dbe75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192452 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 65db26850e9f..45ef3fa1029d 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -57,7 +57,7 @@ xmlDocUniquePtr XmlTestTools::parseXmlStream(SvStream* pStream) pBuffer[nSize] = 0; auto pCharBuffer = reinterpret_cast<xmlChar*>(pBuffer.get()); SAL_INFO("test", "XmlTestTools::parseXmlStream: pBuffer is '" << pCharBuffer << "'"); - return xmlDocUniquePtr(xmlParseDoc(pCharBuffer)); + return xmlDocUniquePtr(xmlReadDoc(pCharBuffer, nullptr, nullptr, XML_PARSE_NODICT | XML_PARSE_HUGE)); } xmlDocUniquePtr XmlTestTools::dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile) commit b3bfae88b66acf4e0ecbf3464362834f5ce3ac1e Author: Caolán McNamara <[email protected]> AuthorDate: Fri Oct 17 19:38:26 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 22:59:27 2025 +0200 separate ImpSdrPdfImport's by prefix a temp fix 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]> diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx index a634542730cc..089c0621f535 100644 --- a/svx/source/inc/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -177,8 +177,11 @@ class ImpSdrPdfImport final void CollectFonts(); - 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); diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index cc9ea95efb19..ed25fc3a0c39 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -217,6 +217,13 @@ 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 @@ -306,8 +313,8 @@ void ImpSdrPdfImport::CollectFonts() 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(getPrefix(), sFontFileName, + bTTF ? u".ttf" : u".t1"); if (!writeFontFile(fileUrl, aFontData)) SAL_WARN("sd.filter", "ttf not written"); else @@ -318,8 +325,8 @@ void ImpSdrPdfImport::CollectFonts() if (!bTTF || !aToUnicodeData.empty()) { EmbeddedFontInfo fontInfo - = convertToOTF(*pSubSetInfo, fileUrl, sFontName, sPostScriptName, - sFontFileName, aToUnicodeData); + = convertToOTF(getPrefix(), *pSubSetInfo, fileUrl, sFontName, + sPostScriptName, sFontFileName, aToUnicodeData); fileUrl = fontInfo.sFontFile; sFontName = fontInfo.sFontName; eFontWeight = fontInfo.eFontWeight; @@ -1498,7 +1505,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, @@ -1644,7 +1651,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)) @@ -1654,8 +1661,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) @@ -1703,13 +1710,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) };
