[Libreoffice-commits] core.git: oox/inc oox/source sd/qa

Matus Uzak matus.uzak at gmail.com
Thu Mar 10 10:21:10 UTC 2016


 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 +-
 sd/qa/unit/data/pptx/tdf89927.pptx                      |binary
 sd/qa/unit/import-tests.cxx                             |   17 ++++++++++++++++
 11 files changed, 50 insertions(+), 30 deletions(-)

New commits:
commit 6802f760a69f3b1f203d70399f0d73764f9159d5
Author: Matus Uzak <matus.uzak at gmail.com>
Date:   Mon Mar 7 12:04:01 2016 +0100

    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 <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/oox/inc/drawingml/textcharacterproperties.hxx b/oox/inc/drawingml/textcharacterproperties.hxx
index 6d7229a..055e58f 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<css::beans::PropertyValue> maTextEffectsProperties;
 
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 9da925d..b2ac6e5 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 71b2f46..63d8c5a 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 45efa77..47f4103 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 3d71c2d..48803de 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 2241306..1c62c1d 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 5d49659..789d14e 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 397cabd..22d4965 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 ca744e8..35a49dd 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 );
 
diff --git a/sd/qa/unit/data/pptx/tdf89927.pptx b/sd/qa/unit/data/pptx/tdf89927.pptx
new file mode 100644
index 0000000..c71e557
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf89927.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 1e153b0..b5e7431 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -109,6 +109,7 @@ public:
     void testTdf93830();
     void testTdf93097();
     void testTdf62255();
+    void testTdf89927();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -152,6 +153,7 @@ public:
     CPPUNIT_TEST(testTdf93830);
     CPPUNIT_TEST(testTdf93097);
     CPPUNIT_TEST(testTdf62255);
+    CPPUNIT_TEST(testTdf89927);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1192,6 +1194,21 @@ void SdImportTest::testTdf62255()
     }
 }
 
+void SdImportTest::testTdf89927()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf89927.pptx"), PPTX);
+    uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+    uno::Reference< text::XTextRange > xParagraph( getParagraphFromShape( 0, xShape ) );
+    uno::Reference< text::XTextRange > xRun( getRunFromParagraph( 0, xParagraph ) );
+    uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
+
+    sal_Int32 nCharColor;
+    xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFFFFFF), nCharColor );
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list