include/xmloff/XMLFontAutoStylePool.hxx | 7 ++++++ sd/qa/unit/export-tests.cxx | 2 - xmloff/source/core/xmlexp.cxx | 10 +++++++++ xmloff/source/draw/sdxmlexp.cxx | 28 ------------------------- xmloff/source/draw/shapeexport.cxx | 1 xmloff/source/style/XMLFontAutoStylePool.cxx | 30 +++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 28 deletions(-)
New commits: commit 8c93dc9f993ab3273d8f20121ff7c70a44e1d655 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Oct 14 17:32:23 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 23:00:01 2025 +0200 add extra pdf shape fonts to export extract a separate XMLFontAutoStylePool::addModelFonts and reuse it to add additional fonts Change-Id: Id08b185baaca9fd38ca24e2284b27a74ef8eacfb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192438 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins Tested-by: Caolán McNamara <[email protected]> diff --git a/include/xmloff/XMLFontAutoStylePool.hxx b/include/xmloff/XMLFontAutoStylePool.hxx index 427ad6dac79f..2f406cbfcb50 100644 --- a/include/xmloff/XMLFontAutoStylePool.hxx +++ b/include/xmloff/XMLFontAutoStylePool.hxx @@ -30,6 +30,11 @@ #include <unordered_map> #include <memory> +namespace com::sun::star { + namespace uno { template<typename T> class Reference; } + namespace beans { class XPropertySet; struct PropertyValue; } +} + class XMLFontAutoStylePool_Impl; class SvXMLExport; @@ -63,6 +68,8 @@ public: rtl_TextEncoding eEnc )const; void exportXML(); + + void addModelFonts(const css::uno::Reference<css::beans::XPropertySet>& xProps); }; #endif // INCLUDED_XMLOFF_XMLFONTAUTOSTYLEPOOL_HXX diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index d6829ec1f9e6..1f6ebf9f8d28 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1135,7 +1135,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfHindi) // ensure the expected font name assertXPath(pXmlDoc, "/office:document/office:automatic-styles/style:style[@style:name='P4']/" - "style:text-properties[@fo:font-family='AcademyEngravedLetPlain']"); + "style:text-properties[@style:font-name='AcademyEngravedLetPlain']"); } CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfGrayscaleImageUnderInvisibleTest) diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 93b88d8abb40..3d9a7c9b0297 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2805,33 +2805,7 @@ XMLFontAutoStylePool* SdXMLExport::CreateFontAutoStylePool() XMLFontAutoStylePool* pPool = new XMLFontAutoStylePool(*this); - Reference< beans::XPropertySet > xProps( GetModel(), UNO_QUERY ); - if ( xProps.is() ) { - Sequence<Any> aAnySeq; - if( xProps->getPropertyValue(u"Fonts"_ustr) >>= aAnySeq ) - { - if( aAnySeq.getLength() % 5 == 0 ) - { - int nLen = aAnySeq.getLength() / 5; - int nSeqIndex = 0; - for( int i = 0; i < nLen; i++ ) - { - OUString sFamilyName, sStyleName; - sal_Int16 eFamily(FAMILY_DONTKNOW), - ePitch(PITCH_DONTKNOW), - eCharSet(RTL_TEXTENCODING_DONTKNOW); - - aAnySeq[nSeqIndex++] >>= sFamilyName; - aAnySeq[nSeqIndex++] >>= sStyleName; - aAnySeq[nSeqIndex++] >>= eFamily; - aAnySeq[nSeqIndex++] >>= ePitch; - aAnySeq[nSeqIndex++] >>= eCharSet; - - pPool->Add( sFamilyName, sStyleName, FontFamily( eFamily ), FontPitch( ePitch ), rtl_TextEncoding( eCharSet ) ); - } - } - } - } + pPool->addModelFonts(Reference<beans::XPropertySet>(GetModel(), UNO_QUERY)); return pPool; } diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index b4af3d21cab1..e37b2924dd55 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -327,6 +327,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap if (xPDFModelReplacement) { aShapeInfo.xPDFModelReplacement = std::move(xPDFModelReplacement); + GetExport().GetFontAutoStylePool()->addModelFonts(uno::Reference<beans::XPropertySet>(aShapeInfo.xPDFModelReplacement, uno::UNO_QUERY)); aShapeInfo.xCustomShapeReplacement = GetPDFShape(aShapeInfo.xPDFModelReplacement); } else diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx index 8692811fea34..e7ac4c068248 100644 --- a/xmloff/source/style/XMLFontAutoStylePool.cxx +++ b/xmloff/source/style/XMLFontAutoStylePool.cxx @@ -542,6 +542,36 @@ void XMLFontAutoStylePool::exportXML() GetExport().exportFonts(aFontAutoStyles); } +void XMLFontAutoStylePool::addModelFonts(const uno::Reference<css::beans::XPropertySet>& xProps) +{ + if ( xProps.is() ) { + Sequence<Any> aAnySeq; + if( xProps->getPropertyValue(u"Fonts"_ustr) >>= aAnySeq ) + { + if( aAnySeq.getLength() % 5 == 0 ) + { + int nLen = aAnySeq.getLength() / 5; + int nSeqIndex = 0; + for( int i = 0; i < nLen; i++ ) + { + OUString sFamilyName, sStyleName; + sal_Int16 eFamily(FAMILY_DONTKNOW), + ePitch(PITCH_DONTKNOW), + eCharSet(RTL_TEXTENCODING_DONTKNOW); + + aAnySeq[nSeqIndex++] >>= sFamilyName; + aAnySeq[nSeqIndex++] >>= sStyleName; + aAnySeq[nSeqIndex++] >>= eFamily; + aAnySeq[nSeqIndex++] >>= ePitch; + aAnySeq[nSeqIndex++] >>= eCharSet; + + Add( sFamilyName, sStyleName, FontFamily( eFamily ), FontPitch( ePitch ), rtl_TextEncoding( eCharSet ) ); + } + } + } + } +} + static OUString getFreeFontName(uno::Reference<embed::XStorage> const & rxStorage, OUString const & rFamilyName) { OUString sName; commit d912220361f7ff5acbeb1861fb2f2464f87070de Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 15 10:16:58 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 22:59:50 2025 +0200 collect autostyles before output fonts we will do this anyway, and its already common place to explicitly call collectAutoStyles before places it is additionally needed for various other reasons. collectAutoStyles returns early if already called. Change-Id: I0ba36897963ccf5f9394eedc8c4f5a102c73c6c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192437 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 4356baee947c..ed48ebd132d4 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -1410,7 +1410,17 @@ ErrCode SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) // font declarations if( mnExportFlags & SvXMLExportFlags::FONTDECLS ) + { + if (mnExportFlags & SvXMLExportFlags::AUTOSTYLES && decomposePDF()) + { + // We will call collectAutoStyles anyway, but do it now before + // we export the fonts so we can export embedded fonts used in + // the decomposed pdf + collectAutoStyles(); + } + ExportFontDecls_(); + } // styles if( mnExportFlags & SvXMLExportFlags::STYLES )
