From 6802f760a69f3b1f203d70399f0d73764f9159d5 Mon Sep 17 00:00:00 2001 From: Matus Uzak Date: Mon, 7 Mar 2016 12:04:01 +0100 Subject: tdf#89927: PPTX import: Incorrect inheritance of text run fill properties Make use of FillProperties in TextCharacterProperties. DrawingML: Fill related elements in Text Run Properties are in sync with Table Cell Properties and all of Line Properties. Change-Id: I7c513ecfc5f94cf49e98a657384b5c0f5dddc1c7 Reviewed-on: https://gerrit.libreoffice.org/22979 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- oox/inc/drawingml/textcharacterproperties.hxx | 3 +-- oox/source/drawingml/chart/objectformatter.cxx | 6 ++++-- oox/source/drawingml/shape.cxx | 6 +++++- oox/source/drawingml/table/tablecell.cxx | 7 +++++-- oox/source/drawingml/textcharacterproperties.cxx | 11 +++-------- oox/source/drawingml/textcharacterpropertiescontext.cxx | 17 ++++++++--------- oox/source/drawingml/textparagraph.cxx | 8 ++++---- oox/source/drawingml/textparagraphproperties.cxx | 2 +- oox/source/drawingml/textrun.cxx | 3 ++- 9 files changed, 33 insertions(+), 30 deletions(-) (limited to 'oox') diff --git a/oox/inc/drawingml/textcharacterproperties.hxx b/oox/inc/drawingml/textcharacterproperties.hxx index 6d7229a6a461..055e58f758f7 100644 --- a/oox/inc/drawingml/textcharacterproperties.hxx +++ b/oox/inc/drawingml/textcharacterproperties.hxx @@ -42,7 +42,6 @@ struct TextCharacterProperties TextFont maComplexFont; TextFont maComplexThemeFont; TextFont maSymbolFont; - Color maCharColor; Color maUnderlineColor; Color maHighlightColor; OptValue< OUString > moLang; @@ -56,7 +55,7 @@ struct TextCharacterProperties OptValue< bool > moItalic; OptValue< bool > moUnderlineLineFollowText; OptValue< bool > moUnderlineFillFollowText; - GradientFillProperties maGradientProps; /// Properties for gradient text colors + FillProperties maFillProperties; std::vector maTextEffectsProperties; diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 9da925d4caf7..b2ac6e506008 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -881,8 +881,10 @@ TextFormatter::TextFormatter( ObjectFormatterData& rData, const AutoTextEntry* p if( const TextCharacterProperties* pTextProps = pTheme->getFontStyle( pAutoTextEntry->mnThemedFont ) ) *mxAutoText = *pTextProps; sal_Int32 nTextColor = getPhColor( -1 ); - if( nTextColor >= 0 ) - mxAutoText->maCharColor.setSrgbClr( nTextColor ); + if( nTextColor >= 0 ) { + mxAutoText->maFillProperties.maFillColor.setSrgbClr( nTextColor ); + mxAutoText->maFillProperties.moFillType.set(XML_solidFill); + } mxAutoText->moHeight = pAutoTextEntry->mnDefFontSize; mxAutoText->moBold = pAutoTextEntry->mbBold; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 71b2f460c1eb..63d8c5a4d422 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1133,7 +1133,11 @@ Reference< XShape > Shape::createAndInsert( if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) ) aCharStyleProperties.assignUsed( *pCharProps ); SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "use font color"); - aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr ); + if ( pFontRef->maPhClr.isUsed() ) + { + aCharStyleProperties.maFillProperties.maFillColor = pFontRef->maPhClr; + aCharStyleProperties.maFillProperties.moFillType.set(XML_solidFill);; + } } } diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 45efa77e7b9e..47f41033b8e0 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -148,8 +148,11 @@ void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, aTextCharProps.maAsianFont = rTableStylePart.getAsianFont(); aTextCharProps.maComplexFont = rTableStylePart.getComplexFont(); aTextCharProps.maSymbolFont = rTableStylePart.getSymbolFont(); - if (rTableStylePart.getTextColor().isUsed()) - aTextCharProps.maCharColor = rTableStylePart.getTextColor(); + if ( rTableStylePart.getTextColor().isUsed() ) + { + aTextCharProps.maFillProperties.maFillColor = rTableStylePart.getTextColor(); + aTextCharProps.maFillProperties.moFillType.set(XML_solidFill); + } if( rTableStylePart.getTextBoldStyle().is_initialized() ) aTextCharProps.moBold = *rTableStylePart.getTextBoldStyle(); if( rTableStylePart.getTextItalicStyle().is_initialized() ) diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index 3d71c2db5824..48803de31157 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -48,7 +48,6 @@ void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSource maComplexFont.assignIfUsed( rSourceProps.maComplexFont ); maComplexThemeFont.assignIfUsed( rSourceProps.maComplexThemeFont ); maSymbolFont.assignIfUsed( rSourceProps.maSymbolFont ); - maCharColor.assignIfUsed( rSourceProps.maCharColor ); maHighlightColor.assignIfUsed( rSourceProps.maHighlightColor ); maUnderlineColor.assignIfUsed( rSourceProps.maUnderlineColor ); moHeight.assignIfUsed( rSourceProps.moHeight ); @@ -63,7 +62,7 @@ void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSource moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText ); maTextEffectsProperties = rSourceProps.maTextEffectsProperties; - maGradientProps.assignUsed( rSourceProps.maGradientProps ); + maFillProperties.assignUsed( rSourceProps.maFillProperties ); } void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter ) const @@ -103,12 +102,8 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty( PROP_CharFontFamilyComplex, nFontFamily); } - // symbolfont, will now be ... textrun.cxx ... ausgewertet !!!i#113673 - - if( maCharColor.isUsed() ) - rPropMap.setProperty( PROP_CharColor, maCharColor.getColor( rFilter.getGraphicHelper() )); - if( maGradientProps.maGradientStops.size() > 0 ) - rPropMap.setProperty( PROP_CharColor, maGradientProps.maGradientStops.begin()->second.getColor( rFilter.getGraphicHelper() )); + if ( maFillProperties.moFillType.has() ) + rPropMap.setProperty( PROP_CharColor, maFillProperties.getBestSolidColor().getColor( rFilter.getGraphicHelper() )); if( moLang.has() && !moLang.get().isEmpty() ) { diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx index 22413062fb17..1c62c1db37fc 100644 --- a/oox/source/drawingml/textcharacterpropertiescontext.cxx +++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx @@ -88,10 +88,12 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl // TODO unsupported yet // case A_TOKEN( ln ): // CT_LineProperties // return new LinePropertiesContext( getHandler(), rAttribs, maTextOutlineProperties ); - - case A_TOKEN( solidFill ): // EG_FillProperties - return new ColorContext( *this, mrTextCharacterProperties.maCharColor ); - + // EG_FillProperties + case A_TOKEN( noFill ): + case A_TOKEN( solidFill ): + case A_TOKEN( gradFill ): + case A_TOKEN( pattFill ): + return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrTextCharacterProperties.maFillProperties ); // EG_EffectProperties case A_TOKEN( effectDag ): // CT_EffectContainer 5.1.10.25 case A_TOKEN( effectLst ): // CT_EffectList 5.1.10.26 @@ -132,10 +134,6 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl case A_TOKEN( hlinkClick ): // CT_Hyperlink case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap ); - - case A_TOKEN( gradFill ): - return new GradientFillContext( *this, rAttribs, mrTextCharacterProperties.maGradientProps ); - case W_TOKEN( rFonts ): if( rAttribs.hasAttribute(W_TOKEN(ascii)) ) { @@ -173,7 +171,8 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl case W_TOKEN( color ): if (rAttribs.getInteger(W_TOKEN(val)).has()) { - mrTextCharacterProperties.maCharColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val)).get()); + mrTextCharacterProperties.maFillProperties.maFillColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val)).get()); + mrTextCharacterProperties.maFillProperties.moFillType.set(XML_solidFill); } break; case W_TOKEN( sz ): diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx index 5d49659fa5b6..789d14ee181e 100644 --- a/oox/source/drawingml/textparagraph.cxx +++ b/oox/source/drawingml/textparagraph.cxx @@ -112,10 +112,10 @@ void TextParagraph::insertAt( // bullets have same color as following texts by default if( !aioBulletList.hasProperty( PROP_BulletColor ) && maRuns.size() > 0 - && (*maRuns.begin())->getTextCharacterProperties().maCharColor.isUsed() ) - aioBulletList.setProperty( PROP_BulletColor, (*maRuns.begin())->getTextCharacterProperties().maCharColor.getColor( rFilterBase.getGraphicHelper() )); - if( !aioBulletList.hasProperty( PROP_BulletColor ) && aTextCharacterStyle.maCharColor.isUsed() ) - aioBulletList.setProperty( PROP_BulletColor, aTextCharacterStyle.maCharColor.getColor( rFilterBase.getGraphicHelper() )); + && (*maRuns.begin())->getTextCharacterProperties().maFillProperties.moFillType.has() ) + aioBulletList.setProperty( PROP_BulletColor, (*maRuns.begin())->getTextCharacterProperties().maFillProperties.getBestSolidColor().getColor( rFilterBase.getGraphicHelper() )); + if( !aioBulletList.hasProperty( PROP_BulletColor ) && aTextCharacterStyle.maFillProperties.moFillType.has() ) + aioBulletList.setProperty( PROP_BulletColor, aTextCharacterStyle.maFillProperties.getBestSolidColor().getColor( rFilterBase.getGraphicHelper() )); float fCharacterSize = nCharHeight > 0 ? GetFontHeight ( nCharHeight ) : pTextParagraphStyle->getCharHeightPoints( 12 ); aParaProp.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), true, fCharacterSize, true ); diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 397cabd2650d..22d4965043dd 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -436,7 +436,7 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p noFirstLineIndentation = boost::none; } if ( nNumberingType != NumberingType::BITMAP && !rioBulletMap.hasProperty( PROP_BulletColor ) && pFilterBase ) - rioBulletMap.setProperty( PROP_BulletColor, static_cast< sal_Int32 >( maTextCharacterProperties.maCharColor.getColor( pFilterBase->getGraphicHelper()))); + rioBulletMap.setProperty( PROP_BulletColor, static_cast< sal_Int32 >( maTextCharacterProperties.maFillProperties.getBestSolidColor().getColor( pFilterBase->getGraphicHelper()))); } if ( bApplyBulletMap ) diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index ca744e8dfe4a..35a49dd0fda2 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -151,7 +151,8 @@ sal_Int32 TextRun::insertAt( xTextFieldCursor->gotoEnd( sal_True ); - aTextCharacterProps.maCharColor.setSchemeClr( XML_hlink ); + aTextCharacterProps.maFillProperties.maFillColor.setSchemeClr( XML_hlink ); + aTextCharacterProps.maFillProperties.moFillType.set(XML_solidFill); if ( !maTextCharacterProperties.moUnderline.has() ) aTextCharacterProps.moUnderline.set( XML_sng ); -- cgit v1.2.3