oox/inc/drawingml/textfont.hxx | 4 +++- oox/source/drawingml/shape.cxx | 18 +++++++++--------- oox/source/drawingml/textcharacterproperties.cxx | 12 ++++++------ oox/source/drawingml/textfont.cxx | 10 ++++++---- oox/source/drawingml/textparagraphproperties.cxx | 6 +++--- oox/source/drawingml/textrun.cxx | 7 ++++++- 6 files changed, 33 insertions(+), 24 deletions(-)
New commits: commit 82d4b2d48ffae91d5c6f1a09b2aaf4a059bf8574 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Aug 28 20:54:50 2023 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Aug 29 10:20:31 2023 +0200 pptx using Wingdings didn't fallback to OpenSymbol <a:sym typeface="Wingdings" pitchFamily="2" charset="2"/> ^ The charset indicating that it was symbol encoded wasn't applied. There are quite a few uses of GetFontData so make this an optional request and only apply it right now to the problematic case. Change-Id: Ie1c4b9ac38c2bf5f0867d64eddea853a6dd05aad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156211 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/oox/inc/drawingml/textfont.hxx b/oox/inc/drawingml/textfont.hxx index 1c6da232d443..e5f245a43380 100644 --- a/oox/inc/drawingml/textfont.hxx +++ b/oox/inc/drawingml/textfont.hxx @@ -50,6 +50,7 @@ public: OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, + bool* pbSymbol, const ::oox::core::XmlFilterBase& rFilter ) const; void fillThemeFont(model::ThemeFont& rThemeFont) const; @@ -60,7 +61,8 @@ private: bool implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, - sal_Int16& rnFontFamily ) const; + sal_Int16& rnFontFamily, + bool* pbSymbol ) const; private: OUString maTypeface; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 039b51977850..c9a4137c77a1 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -784,7 +784,7 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha // minor Latin if (const TextFont* pFont = pTheme->resolveFont(u"+mn-lt")) { - bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) { xSet->setPropertyValue(u"CharFontName", uno::Any(sFontName)); @@ -795,7 +795,7 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha // minor Asian if (const TextFont* pFont = pTheme->resolveFont(u"+mn-ea")) { - bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) { xSet->setPropertyValue(u"CharFontNameAsian", uno::Any(sFontName)); @@ -806,7 +806,7 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha // minor Complex if (const TextFont* pFont = pTheme->resolveFont(u"+mn-cs")) { - bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) { xSet->setPropertyValue(u"CharFontNameComplex", uno::Any(sFontName)); @@ -818,10 +818,10 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha // Replace theme fonts with formatting at run if any. ToDo: Inspect paragraph too? // Latin - bRet = rCharProps.maLatinFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + bRet = rCharProps.maLatinFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (!bRet) // In case there is no direct font, try to look it up as a theme reference. - bRet = rCharProps.maLatinThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, + bRet = rCharProps.maLatinThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) @@ -831,10 +831,10 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha xSet->setPropertyValue(u"CharFontFamily", uno::Any(nFontFamily)); } // Asian - bRet = rCharProps.maAsianFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + bRet = rCharProps.maAsianFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (!bRet) // In case there is no direct font, try to look it up as a theme reference. - bRet = rCharProps.maAsianThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, + bRet = rCharProps.maAsianThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) { @@ -844,10 +844,10 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha } // Complex bRet - = rCharProps.maComplexFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter); + = rCharProps.maComplexFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (!bRet) // In case there is no direct font, try to look it up as a theme reference. - bRet = rCharProps.maComplexThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, + bRet = rCharProps.maComplexThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter); if (bRet) { diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index c3dde4889a64..d123f3607208 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -78,10 +78,10 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil sal_Int16 nFontPitch = 0; sal_Int16 nFontFamily = 0; - bool bRet = maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bool bRet = maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (!bRet) // In case there is no direct font, try to look it up as a theme reference. - bRet = maLatinThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bRet = maLatinThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (bRet) { rPropMap.setProperty( PROP_CharFontName, aFontName); @@ -89,9 +89,9 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty( PROP_CharFontFamily, nFontFamily); } - bRet = maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bRet = maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (!bRet) - bRet = maAsianThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bRet = maAsianThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (bRet) { rPropMap.setProperty( PROP_CharFontNameAsian, aFontName); @@ -99,9 +99,9 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty( PROP_CharFontFamilyAsian, nFontPitch); } - bRet = maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bRet = maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (!bRet) - bRet = maComplexThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + bRet = maComplexThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, nullptr, rFilter ); if (bRet) { rPropMap.setProperty( PROP_CharFontNameComplex, aFontName); diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx index 1ac57258a7da..40cd842f945a 100644 --- a/oox/source/drawingml/textfont.cxx +++ b/oox/source/drawingml/textfont.cxx @@ -76,18 +76,20 @@ void TextFont::assignIfUsed( const TextFont& rTextFont ) *this = rTextFont; } -bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const +bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, bool* pbSymbol, const XmlFilterBase& rFilter ) const { if( const Theme* pTheme = rFilter.getCurrentTheme() ) if( const TextFont* pFont = pTheme->resolveFont( maTypeface ) ) - return pFont->implGetFontData( rFontName, rnFontPitch, rnFontFamily ); - return implGetFontData( rFontName, rnFontPitch, rnFontFamily ); + return pFont->implGetFontData( rFontName, rnFontPitch, rnFontFamily, pbSymbol ); + return implGetFontData( rFontName, rnFontPitch, rnFontFamily, pbSymbol ); } -bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily ) const +bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, bool* pbSymbol ) const { rFontName = maTypeface; resolvePitch(mnPitchFamily, rnFontPitch, rnFontFamily); + if (pbSymbol) + *pbSymbol = mnCharset == WINDOWS_CHARSET_SYMBOL; return !rFontName.isEmpty(); } diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index df3d36a21003..37dc10f64020 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -314,14 +314,14 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, P if( pFilterBase) { bool bFollowTextFont = false; mbBulletFontFollowText >>= bFollowTextFont; - if (!bFollowTextFont && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, *pFilterBase ) ) + if (!bFollowTextFont && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, nullptr, *pFilterBase ) ) { FontDescriptor aFontDesc; sal_Int16 nFontSize = 0; if( mnFontSize >>= nFontSize ) aFontDesc.Height = nFontSize; - // TODO move the to the TextFont struct. + // TODO either use getFontData encoding hint, or move this to the TextFont struct. aFontDesc.Name = aBulletFontName; aFontDesc.Pitch = nBulletFontPitch; aFontDesc.Family = nBulletFontFamily; @@ -347,7 +347,7 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, P msBulletChar >>= sBuChar; - if( pFilterBase && sBuChar.getLength() == 1 && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, *pFilterBase ) && bSymbolFont ) + if( pFilterBase && sBuChar.getLength() == 1 && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, nullptr, *pFilterBase ) && bSymbolFont ) { sal_Unicode nBuChar = sBuChar.toChar(); nBuChar &= 0x00ff; diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index 6bfc3701fedb..3eca13d4ad8f 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -19,6 +19,7 @@ #include <drawingml/textrun.hxx> +#include <com/sun/star/awt/CharSet.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -67,6 +68,7 @@ sal_Int32 TextRun::insertAt( Any aOldFontName = xState->getPropertyDefault("CharFontName"); Any aOldFontPitch = xState->getPropertyDefault("CharFontPitch"); Any aOldFontFamily = xState->getPropertyDefault("CharFontFamily"); + Any aOldFontCharSet = xState->getPropertyDefault("CharFontCharSet"); TextCharacterProperties aTextCharacterProps( rTextCharacterStyle ); @@ -104,15 +106,17 @@ sal_Int32 TextRun::insertAt( OUString aFontName; sal_Int16 nFontFamily = 0, nFontPitch = 0; + bool bSymbolEnc(false); bool bReset = false; // Direct formatting for symbols. - if (bSymbol && aTextCharacterProps.maSymbolFont.getFontData(aFontName, nFontPitch, nFontFamily, rFilterBase)) + if (bSymbol && aTextCharacterProps.maSymbolFont.getFontData(aFontName, nFontPitch, nFontFamily, &bSymbolEnc, rFilterBase)) { aPropSet.setAnyProperty(PROP_CharFontName, Any(aFontName)); aPropSet.setAnyProperty(PROP_CharFontPitch, Any(nFontPitch)); aPropSet.setAnyProperty(PROP_CharFontFamily, Any(nFontFamily)); + aPropSet.setAnyProperty(PROP_CharFontCharSet, Any(bSymbolEnc ? css::awt::CharSet::SYMBOL : css::awt::CharSet::DONTKNOW)); bReset = true; } @@ -126,6 +130,7 @@ sal_Int32 TextRun::insertAt( aPropSet.setAnyProperty(PROP_CharFontName, aOldFontName); aPropSet.setAnyProperty(PROP_CharFontPitch, aOldFontPitch); aPropSet.setAnyProperty(PROP_CharFontFamily, aOldFontFamily); + aPropSet.setAnyProperty(PROP_CharFontCharSet, aOldFontCharSet); } nIndex += nCount;