include/xmloff/XMLFontAutoStylePool.hxx | 7 ++++++ sd/qa/unit/export-tests.cxx | 2 - xmloff/source/draw/sdxmlexp.cxx | 28 ------------------------- xmloff/source/draw/shapeexport.cxx | 1 xmloff/source/style/XMLFontAutoStylePool.cxx | 30 +++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 28 deletions(-)
New commits: commit b3a87bd36736be7c7a0abb73ae9ba066dba8b0cd Author: Caolán McNamara <[email protected]> AuthorDate: Tue Oct 14 17:32:23 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Oct 16 14:16:10 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/+/192404 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[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 7fc1011ba27e..50f3d82ae97c 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1124,7 +1124,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 fdbd763ae403..461b2436e528 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -334,6 +334,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 272d6d3986b4..7efc87e05bec 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;
