diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx index 6baedab42411..6334d9eb6b81 100644 --- a/svx/source/inc/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -173,11 +173,10 @@ class ImpSdrPdfImport final void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex); - static ImportedFontMap CollectFonts(sal_Int64 nPrefix, vcl::pdf::PDFiumDocument& rPdfDocument); + static ImportedFontMap CollectFonts(std::u16string_view sPrefix, + vcl::pdf::PDFiumDocument& rPdfDocument); - sal_Int64 getPrefix() const { return reinterpret_cast(this); } - - static EmbeddedFontInfo convertToOTF(sal_Int64 nPrefix, SubSetInfo& rSubSetInfo, + static EmbeddedFontInfo convertToOTF(std::u16string_view sPrefix, SubSetInfo& rSubSetInfo, const OUString& fileUrl, const OUString& fontName, const OUString& baseFontName, std::u16string_view fontFileName, diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 1eb77ab46b73..6a10ae9bde60 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -89,6 +89,12 @@ using namespace com::sun::star; +static OUString getPrefix(void* p) +{ + static sal_Int64 snCounter = 0; + return OUString::number(reinterpret_cast(p)) + "_" + OUString::number(snCounter++); +} + ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect, Graphic const& rGraphic) : maScaleRect(rRect) @@ -135,7 +141,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools: if (!mxImportedFonts) { mxImportedFonts - = std::make_shared(CollectFonts(getPrefix(), *mpPdfDocument)); + = std::make_shared(CollectFonts(getPrefix(this), *mpPdfDocument)); if (xGrfLink) xGrfLink->setImportedFonts(mxImportedFonts); } @@ -231,17 +237,17 @@ OUString stripPostScriptStyle(const OUString& postScriptName, FontWeight& eWeigh return sFontName; } -OUString getFileUrlForTemporaryFont(sal_Int64 prefix, std::u16string_view name, +OUString getFileUrlForTemporaryFont(std::u16string_view prefix, std::u16string_view name, std::u16string_view suffix) { return EmbeddedFontsManager::getFileUrlForTemporaryFont( - Concat2View(OUString::number(prefix) + name), suffix); + Concat2View(OUString::Concat(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(sal_Int64 nPrefix, +ImportedFontMap ImpSdrPdfImport::CollectFonts(std::u16string_view sPrefix, vcl::pdf::PDFiumDocument& rPdfDocument) { ImportedFontMap aImportedFonts; @@ -338,7 +344,7 @@ ImportedFontMap ImpSdrPdfImport::CollectFonts(sal_Int64 nPrefix, eFontWeight); SAL_INFO_IF(!bTTF, "sd.filter", "not ttf/otf, converting"); OUString fileUrl - = getFileUrlForTemporaryFont(nPrefix, sFontFileName, bTTF ? u".ttf" : u".t1"); + = getFileUrlForTemporaryFont(sPrefix, sFontFileName, bTTF ? u".ttf" : u".t1"); if (!writeFontFile(fileUrl, aFontData)) SAL_WARN("sd.filter", "ttf not written"); else @@ -349,7 +355,7 @@ ImportedFontMap ImpSdrPdfImport::CollectFonts(sal_Int64 nPrefix, if (!bTTF || !aToUnicodeData.empty()) { EmbeddedFontInfo fontInfo - = convertToOTF(nPrefix, *pSubSetInfo, fileUrl, sFontName, sPostScriptName, + = convertToOTF(sPrefix, *pSubSetInfo, fileUrl, sFontName, sPostScriptName, sFontFileName, aToUnicodeData, *font); fileUrl = fontInfo.sFontFile; sFontName = fontInfo.sFontName; @@ -1498,7 +1504,7 @@ static OUString buildFontMenuName(const OUString& FontMenuNameDBUrl, } // https://adobe-type-tools.github.io/font-tech-notes/pdfs/5900.RFMFAH_Tutorial.pdf -static EmbeddedFontInfo mergeFontSubsets(sal_Int64 prefix, const OUString& mergedFontUrl, +static EmbeddedFontInfo mergeFontSubsets(std::u16string_view prefix, const OUString& mergedFontUrl, const OUString& FontMenuNameDBUrl, const OUString& postScriptName, const OUString& longFontName, std::string_view Weight, @@ -1654,7 +1660,7 @@ static EmbeddedFontInfo mergeFontSubsets(sal_Int64 prefix, const OUString& merge } //static -EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(sal_Int64 prefix, SubSetInfo& rSubSetInfo, +EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(std::u16string_view prefix, SubSetInfo& rSubSetInfo, const OUString& fileUrl, const OUString& fontName, const OUString& postScriptName, std::u16string_view fontFileName, diff --git a/vcl/source/gdi/embeddedfontsafdko.cxx b/vcl/source/gdi/embeddedfontsafdko.cxx index 7558faed7085..9de0ed6e5a75 100644 --- a/vcl/source/gdi/embeddedfontsafdko.cxx +++ b/vcl/source/gdi/embeddedfontsafdko.cxx @@ -338,6 +338,9 @@ bool EmbeddedFontsManager::makeotf(const OUString& srcFontUrl, const OUString& d { bool ret = false; #if HAVE_FEATURE_AFDKO + // cbConvert may abort when dest file already exists + assert(osl::File(destFileUrl).open(osl_File_OpenFlag_Read) == osl::FileBase::E_NOENT); + OUString srcFontPath, destFilePath, charMapPath, fontMenuNameDBPath, featuresPath; if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(srcFontUrl, srcFontPath) || osl::FileBase::E_None