include/oox/export/drawingml.hxx | 5 ++-- oox/source/export/drawingml.cxx | 41 ++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 9 deletions(-)
New commits: commit 360612fde57c1dcf55508f5e9ea2a5193ac11ef2 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 28 15:43:41 2025 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon May 5 09:38:15 2025 +0200 oox: Don't substitute fonts if embedding fonts is enabled This is needed to prevent that we embed a font but then export a different (substituted) font name into the document, which would defeat the purpose of embedding in the first place. This is not ideal either as a we probably need better control of what we can just substitue and what we need to embed. Change-Id: Icd29789ceb739b6950576379358a96cc0449b3b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184696 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 0c1b3c1c97bbfdc8d8f84b36fb5879400095c5e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184824 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 14df9e9cad8c..d0b08d8bb305 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -305,6 +305,8 @@ protected: /// True when exporting presentation placeholder shape. bool mbPlaceholder; + bool mbEmbedFonts = false; + bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& aName ); bool GetPropertyAndState( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const css::uno::Reference< css::beans::XPropertyState >& rXPropState, @@ -352,8 +354,7 @@ protected: const bool bReplaceGeoWidth, const bool bReplaceGeoHeight); public: - DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = nullptr ) - : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS(std::move( pFS )), mpFB( pFB ), mbIsBackgroundDark( false ), mbPlaceholder(false) {} + OOX_DLLPUBLIC DrawingML(::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = nullptr); void SetFS(const ::sax_fastparser::FSHelperPtr& pFS) { mpFS = pFS; } const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; } ::oox::core::XmlFilterBase* GetFB() { return mpFB; } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f02c4e3499be..787a0325ea18 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -250,6 +250,27 @@ sal_Int32 DrawingML::mnDrawingMLCount = 0; sal_Int32 DrawingML::mnVmlCount = 0; sal_Int32 DrawingML::mnChartCount = 0; +DrawingML::DrawingML(::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType, DMLTextExport* pTextExport) + : meDocumentType(eDocumentType) + , mpTextExport(pTextExport) + , mpFS(std::move(pFS)) + , mpFB(pFB) + , mbIsBackgroundDark(false) + , mbPlaceholder(false) +{ + uno::Reference<beans::XPropertySet> xSettings(pFB->getModelFactory()->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY); + if (xSettings.is()) + { + try + { + xSettings->getPropertyValue(u"EmbedFonts"_ustr) >>= mbEmbedFonts; + } + catch (Exception& ) + { + } + } +} + sal_Int16 DrawingML::GetScriptType(const OUString& rStr) { if (rStr.getLength() > 0) @@ -2814,9 +2835,13 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool OUString usTypeface; mAny >>= usTypeface; - OUString aSubstName( GetSubsFontName( usTypeface, SubsFontFlags::ONLYONE | SubsFontFlags::MS ) ); - if (!aSubstName.isEmpty()) - usTypeface = aSubstName; + + if (!mbEmbedFonts) + { + OUString aSubstName( GetSubsFontName( usTypeface, SubsFontFlags::ONLYONE | SubsFontFlags::MS ) ); + if (!aSubstName.isEmpty()) + usTypeface = aSubstName; + } mpFS->singleElementNS( XML_a, XML_latin, XML_typeface, usTypeface, @@ -2836,10 +2861,12 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool OUString usTypeface; mAny >>= usTypeface; - OUString aSubstName( GetSubsFontName( usTypeface, SubsFontFlags::ONLYONE | SubsFontFlags::MS ) ); - if (!aSubstName.isEmpty()) - usTypeface = aSubstName; - + if (!mbEmbedFonts) + { + OUString aSubstName( GetSubsFontName( usTypeface, SubsFontFlags::ONLYONE | SubsFontFlags::MS ) ); + if (!aSubstName.isEmpty()) + usTypeface = aSubstName; + } mpFS->singleElementNS( XML_a, bComplex ? XML_cs : XML_ea, XML_typeface, usTypeface, XML_pitchFamily, pitch,