diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-08-28 20:54:50 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-08-29 09:26:34 +0200 |
commit | 7f1c2b6ccf318d3b6bbf46f6559b2a3017a72821 (patch) | |
tree | 0ba4b4a50e5744c6eb9ff7783ae904c69bd02245 /oox/source/drawingml | |
parent | 16d43b7c5396d6382926d514dc9ce10b3ce94cba (diff) |
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/+/156230
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 18 | ||||
-rw-r--r-- | oox/source/drawingml/textcharacterproperties.cxx | 12 | ||||
-rw-r--r-- | oox/source/drawingml/textfont.cxx | 10 | ||||
-rw-r--r-- | oox/source/drawingml/textparagraphproperties.cxx | 6 | ||||
-rw-r--r-- | oox/source/drawingml/textrun.cxx | 7 |
5 files changed, 30 insertions, 23 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 4f600528b56a..b4e0a05ba7a6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -639,7 +639,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)); @@ -650,7 +650,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)); @@ -661,7 +661,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)); @@ -673,10 +673,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) @@ -686,10 +686,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) { @@ -699,10 +699,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 949ee3f22d6b..9dd3a6c3c181 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; |