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

Matus Uzak matus.uzak at gmail.com
Wed Mar 23 06:49:32 UTC 2016


 include/oox/ppt/slidepersist.hxx        |    3 +--
 oox/source/ppt/pptshapegroupcontext.cxx |    9 ++++-----
 oox/source/ppt/slidefragmenthandler.cxx |    3 +--
 oox/source/ppt/slidepersist.cxx         |    3 +--
 sd/qa/unit/data/pptx/tdf93868.pptx      |binary
 sd/qa/unit/import-tests.cxx             |   14 ++++++++++++++
 6 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit f3d1ac75c4b7fa63022e54a9cbff46ba99535076
Author: Matus Uzak <matus.uzak at gmail.com>
Date:   Tue Mar 8 21:44:21 2016 +0100

    tdf#93868: PPTX import: Incorrect inheritance of shape fill properties
    
    DrawingML: The useBgFill attribute specifies that the shape fill
    should be set to that of the slide background.
    
    Change-Id: I8b568e730f00326d51e7b604579f4ff990b26f8a
    Reviewed-on: https://gerrit.libreoffice.org/23039
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/include/oox/ppt/slidepersist.hxx b/include/oox/ppt/slidepersist.hxx
index 3c08f68..1a61603 100644
--- a/include/oox/ppt/slidepersist.hxx
+++ b/include/oox/ppt/slidepersist.hxx
@@ -83,7 +83,7 @@ public:
     oox::drawingml::ClrMapPtr getClrMap() const { return mpClrMapPtr; }
 
     void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr& rFillPropertiesPtr ){ mpBackgroundPropertiesPtr = rFillPropertiesPtr; }
-    oox::drawingml::Color& getBackgroundColor() { return maBackgroundColor; }
+    const oox::drawingml::FillPropertiesPtr getBackgroundProperties() const { return mpBackgroundPropertiesPtr; }
 
     bool isMasterPage() const { return mbMaster; }
     bool isNotesPage() const { return mbNotes; }
@@ -127,7 +127,6 @@ private:
     SlidePersistPtr                                                         mpMasterPagePtr;
 
     oox::drawingml::ShapePtr                                                maShapesPtr;
-    oox::drawingml::Color                                                   maBackgroundColor;
     oox::drawingml::FillPropertiesPtr                                       mpBackgroundPropertiesPtr;
     ::std::list< std::shared_ptr< TimeNode > >                              maTimeNodeList;
 
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index d5c3dc6..d7337b1 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -98,11 +98,10 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
             std::shared_ptr<PPTShape> pShape( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) );
             if( rAttribs.getBool( XML_useBgFill, false ) )
             {
-                ::oox::drawingml::FillProperties &aFill = pShape->getFillProperties();
-                aFill.moFillType = XML_solidFill;
-                // This is supposed to fill with slide (background) color, but
-                // TODO: We are using white here, because thats the closest we can assume (?)
-                aFill.maFillColor.setSrgbClr( API_RGB_WHITE );
+                const oox::drawingml::FillPropertiesPtr pBackgroundPropertiesPtr = mpSlidePersistPtr->getBackgroundProperties();
+                if ( pBackgroundPropertiesPtr ) {
+                    pShape->getFillProperties().assignUsed( *pBackgroundPropertiesPtr );
+                }
             }
             pShape->setModelId(rAttribs.getString( XML_modelId ).get());
             return new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape );
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 2d75afc..d8c4735 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -166,9 +166,8 @@ SlideFragmentHandler::~SlideFragmentHandler()
             if( mpSlidePersistPtr->getTheme() )
                 pFillProperties = mpSlidePersistPtr->getTheme()->getFillStyle( rAttribs.getInteger( XML_idx, -1 ) );
             FillPropertiesPtr pFillPropertiesPtr( pFillProperties ? new FillProperties( *pFillProperties ) : new FillProperties() );
-            ContextHandlerRef ret = new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() );
             mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr );
-            return ret;
+            return this;
         }
         break;
 
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index d6e3f99..f527868 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -166,8 +166,7 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
 {
     if ( mpBackgroundPropertiesPtr )
     {
-        sal_Int32 nPhClr = maBackgroundColor.isUsed() ?
-            maBackgroundColor.getColor( rFilterBase.getGraphicHelper() ) : API_RGB_TRANSPARENT;
+        sal_Int32 nPhClr = mpBackgroundPropertiesPtr->getBestSolidColor().getColor( rFilterBase.getGraphicHelper() );
 
         ::oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
         mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr );
diff --git a/sd/qa/unit/data/pptx/tdf93868.pptx b/sd/qa/unit/data/pptx/tdf93868.pptx
new file mode 100644
index 0000000..f54fb04
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf93868.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index b102396..9ae03fc 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -110,6 +110,7 @@ public:
     void testTdf93097();
     void testTdf62255();
     void testTdf89927();
+    void testTdf93868();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -154,6 +155,7 @@ public:
     CPPUNIT_TEST(testTdf93097);
     CPPUNIT_TEST(testTdf62255);
     CPPUNIT_TEST(testTdf89927);
+    CPPUNIT_TEST(testTdf93868);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1219,6 +1221,18 @@ void SdImportTest::testTdf89927()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf93868()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93868.pptx"), PPTX);
+
+    const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
+    CPPUNIT_ASSERT_EQUAL(size_t(5), pPage->GetObjCount());
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(0)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(1)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list