diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-28 12:17:51 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-28 13:51:35 +0100 |
commit | 440fbd609054d78e37f4953dfdde8c79c10b4981 (patch) | |
tree | 587ce0c0df692ac025d0167bac0ea0bfb25e25dd /oox | |
parent | WaE: implicit conversion of literal of type 'sal_Bool' to 'bool' (diff) | |
download | core-440fbd609054d78e37f4953dfdde8c79c10b4981.tar.gz core-440fbd609054d78e37f4953dfdde8c79c10b4981.zip |
DOCX import: handle font theme references in group shape text
Change-Id: I1d5b86ad17b2c4a0945f483c94ac6abf410cf1d6
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/textcharacterproperties.cxx | 19 | ||||
-rw-r--r-- | oox/source/drawingml/textcharacterpropertiescontext.cxx | 12 | ||||
-rw-r--r-- | oox/source/drawingml/theme.cxx | 17 |
3 files changed, 44 insertions, 4 deletions
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index 1ad0bae6e51e..b7827616ecfb 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -44,8 +44,11 @@ void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSource // overwrite all properties exisiting in rSourceProps maHyperlinkPropertyMap.insert( rSourceProps.maHyperlinkPropertyMap.begin(), rSourceProps.maHyperlinkPropertyMap.end() ); maLatinFont.assignIfUsed( rSourceProps.maLatinFont ); + maLatinThemeFont.assignIfUsed( rSourceProps.maLatinThemeFont ); maAsianFont.assignIfUsed( rSourceProps.maAsianFont ); + maAsianThemeFont.assignIfUsed( rSourceProps.maAsianThemeFont ); maComplexFont.assignIfUsed( rSourceProps.maComplexFont ); + maComplexThemeFont.assignIfUsed( rSourceProps.maComplexThemeFont ); maSymbolFont.assignIfUsed( rSourceProps.maSymbolFont ); maCharColor.assignIfUsed( rSourceProps.maCharColor ); maHighlightColor.assignIfUsed( rSourceProps.maHighlightColor ); @@ -68,21 +71,31 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil sal_Int16 nFontPitch = 0; sal_Int16 nFontFamily = 0; - if( maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) ) + bool bRet = maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, 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 ); + if (bRet) { rPropMap[ PROP_CharFontName ] <<= aFontName; rPropMap[ PROP_CharFontPitch ] <<= nFontPitch; rPropMap[ PROP_CharFontFamily ] <<= nFontFamily; } - if( maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) ) + bRet = maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + if (!bRet) + bRet = maAsianThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + if (bRet) { rPropMap[ PROP_CharFontNameAsian ] <<= aFontName; rPropMap[ PROP_CharFontPitchAsian ] <<= nFontFamily; rPropMap[ PROP_CharFontFamilyAsian ] <<= nFontPitch; } - if( maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) ) + bRet = maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + if (!bRet) + bRet = maComplexThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ); + if (bRet) { rPropMap[ PROP_CharFontNameComplex ] <<= aFontName; rPropMap[ PROP_CharFontPitchComplex ] <<= nFontPitch; diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx index 8b6156ec64fb..cde4a636282b 100644 --- a/oox/source/drawingml/textcharacterpropertiescontext.cxx +++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx @@ -136,14 +136,26 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl { mrTextCharacterProperties.maLatinFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, ascii), OUString())); } + if (rAttribs.hasAttribute(OOX_TOKEN(doc, asciiTheme))) + { + mrTextCharacterProperties.maLatinThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, asciiTheme), OUString())); + } if( rAttribs.hasAttribute(OOX_TOKEN(doc, cs)) ) { mrTextCharacterProperties.maComplexFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, cs), OUString())); } + if (rAttribs.hasAttribute(OOX_TOKEN(doc, cstheme))) + { + mrTextCharacterProperties.maComplexThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, cstheme), OUString())); + } if( rAttribs.hasAttribute(OOX_TOKEN(doc, eastAsia)) ) { mrTextCharacterProperties.maAsianFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, eastAsia), OUString())); } + if (rAttribs.hasAttribute(OOX_TOKEN(doc, eastAsiaTheme))) + { + mrTextCharacterProperties.maAsianThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, eastAsiaTheme), OUString())); + } break; case OOX_TOKEN( doc, b ): mrTextCharacterProperties.moBold = rAttribs.getBool(OOX_TOKEN( doc, val ), true); diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index 1fbcf1134261..859488f25105 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -67,13 +67,13 @@ const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) cons const TextFont* Theme::resolveFont( const OUString& rName ) const { + const TextCharacterProperties* pCharProps = 0; /* Resolves the following names: +mj-lt, +mj-ea, +mj-cs -- major Latin, Asian, Complex font +mn-lt, +mn-ea, +mn-cs -- minor Latin, Asian, Complex font */ if( (rName.getLength() == 6) && (rName[ 0 ] == '+') && (rName[ 3 ] == '-') ) { - const TextCharacterProperties* pCharProps = 0; if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'j') ) pCharProps = maFontScheme.get( XML_major ).get(); else if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'n') ) @@ -88,6 +88,21 @@ const TextFont* Theme::resolveFont( const OUString& rName ) const return &pCharProps->maComplexFont; } } + + // See writerfilter::dmapper::ThemeTable::getFontNameForTheme(). + if (rName == "majorHAnsi" || rName == "majorAscii" || rName == "majorBidi" || rName == "majorEastAsia") + pCharProps = maFontScheme.get(XML_major).get(); + else if (rName == "minorHAnsi" || rName == "minorAscii" || rName == "minorBidi" || rName == "minorEastAsia") + pCharProps = maFontScheme.get(XML_minor).get(); + if (pCharProps) + { + if (rName == "majorAscii" || rName == "majorHAnsi" || rName == "minorAscii" || rName == "minorHAnsi") + return &pCharProps->maLatinFont; + else if (rName == "minorBidi" || rName == "majorBidi") + return &pCharProps->maComplexFont; + else if (rName == "minorEastAsia" || rName == "majorEastAsia") + return &pCharProps->maAsianFont; + } return 0; } |