include/oox/ppt/presentationfragmenthandler.hxx | 2 ++ oox/source/ppt/EmbeddedFontListContext.cxx | 13 +++++++++++-- oox/source/ppt/EmbeddedFontListContext.hxx | 5 ++++- oox/source/ppt/presentationfragmenthandler.cxx | 7 ++++++- 4 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit 04a2757d3c7f8ae7798efc453033228deaaacf69 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 21 16:33:22 2025 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 30 16:04:40 2025 +0200 oox: read embedTrueTypeFonts and set doc. setting "EmbedFonts" Embed fonts depending if the attribute "embedTrueTypeFonts "on "presentation" element is set to true. If true, set the doc. setting "EmbedFonts" and start proceed with font embedding code path. Change-Id: Iba2552ab58c07cfa41afca4e1883ae706eb8c678 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184403 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 248b826786e29c32ebdd2553d68adf240903977b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184814 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/include/oox/ppt/presentationfragmenthandler.hxx b/include/oox/ppt/presentationfragmenthandler.hxx index cd9084235221..b0e46e16bc4b 100644 --- a/include/oox/ppt/presentationfragmenthandler.hxx +++ b/include/oox/ppt/presentationfragmenthandler.hxx @@ -73,6 +73,8 @@ private: CommentAuthorList maAuthorList; bool mbCommentAuthorsRead; // read commentAuthors.xml only once + + bool mbEmbedTrueTypeFonts = false; }; } diff --git a/oox/source/ppt/EmbeddedFontListContext.cxx b/oox/source/ppt/EmbeddedFontListContext.cxx index c60a257fbcf3..792387e34556 100644 --- a/oox/source/ppt/EmbeddedFontListContext.cxx +++ b/oox/source/ppt/EmbeddedFontListContext.cxx @@ -20,8 +20,12 @@ using namespace css; namespace oox::ppt { -EmbeddedFontListContext::EmbeddedFontListContext(FragmentHandler2 const& rParent) +EmbeddedFontListContext::EmbeddedFontListContext( + FragmentHandler2 const& rParent, bool bEmbedTrueType, + css::uno::Reference<css::beans::XPropertySet> const& rxDocSettings) : FragmentHandler2(rParent) + , mbEmbedTrueType(bEmbedTrueType) + , mxDocSettings(rxDocSettings) { } @@ -77,9 +81,14 @@ void EmbeddedFontListContext::onEndElement() if (!isCurrentElement(PPT_TOKEN(embeddedFont))) return; - if (!moCurrentFont) + if (!mbEmbedTrueType || !moCurrentFont) return; + if (mxDocSettings.is()) + { + mxDocSettings->setPropertyValue(u"EmbedFonts"_ustr, uno::Any(true)); + } + if (!moCurrentFont->aRegularID.isEmpty()) { OUString aFragmentPath = getFragmentPathFromRelId(moCurrentFont->aRegularID); diff --git a/oox/source/ppt/EmbeddedFontListContext.hxx b/oox/source/ppt/EmbeddedFontListContext.hxx index 35a15b24c62a..4c9dd4075fe6 100644 --- a/oox/source/ppt/EmbeddedFontListContext.hxx +++ b/oox/source/ppt/EmbeddedFontListContext.hxx @@ -45,9 +45,12 @@ class EmbeddedFontListContext final : public ::oox::core::FragmentHandler2 { std::optional<EmbeddedFont> moCurrentFont; EmbeddedFontsHelper maEmbeddedFontHelper; + bool mbEmbedTrueType = false; + css::uno::Reference<css::beans::XPropertySet> mxDocSettings; public: - EmbeddedFontListContext(oox::core::FragmentHandler2 const& rParent); + EmbeddedFontListContext(oox::core::FragmentHandler2 const& rParent, bool bEmbedTrueType, + css::uno::Reference<css::beans::XPropertySet> const& rxDocSettings); ~EmbeddedFontListContext() override; oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index be5c9f19749d..83c308902499 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -682,6 +682,8 @@ void PresentationFragmentHandler::finalizeImport() switch( aElementToken ) { case PPT_TOKEN( presentation ): + mbEmbedTrueTypeFonts = rAttribs.getBool(XML_embedTrueTypeFonts, false); + return this; case PPT_TOKEN( sldMasterIdLst ): case PPT_TOKEN( notesMasterIdLst ): case PPT_TOKEN( sldIdLst ): @@ -706,7 +708,10 @@ void PresentationFragmentHandler::finalizeImport() case PPT_TOKEN( defaultTextStyle ): return new TextListStyleContext( *this, *mpTextListStyle ); case PPT_TOKEN(embeddedFontLst): - return new EmbeddedFontListContext(*this); + { + uno::Reference<beans::XPropertySet> xDocSettings(getFilter().getModelFactory()->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY); + return new EmbeddedFontListContext(*this, mbEmbedTrueTypeFonts, xDocSettings); + } case PPT_TOKEN( modifyVerifier ): OUString sAlgorithmClass = rAttribs.getStringDefaulted(XML_cryptAlgorithmClass); OUString sAlgorithmType = rAttribs.getStringDefaulted(XML_cryptAlgorithmType);