diff options
author | Matus Uzak <matus.uzak@gmail.com> | 2016-03-08 21:44:21 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-05-02 20:57:05 +0200 |
commit | 4d4edcc3d4c27688f5bed4beebf5fee2b0cd1760 (patch) | |
tree | a2c1952ba2033e5aa7a28fc63e962d370511da3f | |
parent | 8d0455e4bba7516550227326c32c46273ffa00da (diff) |
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.
Reviewed-on: https://gerrit.libreoffice.org/23039
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit f3d1ac75c4b7fa63022e54a9cbff46ba99535076)
Change-Id: I8b568e730f00326d51e7b604579f4ff990b26f8a
-rw-r--r-- | include/oox/ppt/slidepersist.hxx | 4 | ||||
-rw-r--r-- | oox/source/ppt/pptshapegroupcontext.cxx | 9 | ||||
-rw-r--r-- | oox/source/ppt/slidefragmenthandler.cxx | 3 | ||||
-rw-r--r-- | oox/source/ppt/slidepersist.cxx | 3 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf93868.pptx | bin | 0 -> 69213 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 15 |
6 files changed, 22 insertions, 12 deletions
diff --git a/include/oox/ppt/slidepersist.hxx b/include/oox/ppt/slidepersist.hxx index 91cd49bc3426..4e4fcec5fd72 100644 --- a/include/oox/ppt/slidepersist.hxx +++ b/include/oox/ppt/slidepersist.hxx @@ -85,7 +85,6 @@ public: void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr& rFillPropertiesPtr ){ mpBackgroundPropertiesPtr = rFillPropertiesPtr; } oox::drawingml::FillPropertiesPtr getBackgroundProperties() const { return mpBackgroundPropertiesPtr; } - oox::drawingml::Color& getBackgroundColor() { return maBackgroundColor; } bool isMasterPage() const { return mbMaster; } bool isNotesPage() const { return mbNotes; } @@ -129,9 +128,8 @@ private: SlidePersistPtr mpMasterPagePtr; oox::drawingml::ShapePtr maShapesPtr; - oox::drawingml::Color maBackgroundColor; oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr; - ::std::list< std::shared_ptr< TimeNode > > maTimeNodeList; + ::std::list< std::shared_ptr< TimeNode > > maTimeNodeList; oox::ppt::HeaderFooter maHeaderFooter; sal_Int32 mnLayoutValueToken; diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 05044caa23b0..b38cd113964d 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 5a27ea34a114..ed8053533d26 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 82d0f9fe69ca..45e7b4a5af18 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 Binary files differnew file mode 100644 index 000000000000..f54fb0496e11 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf93868.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 8f4685b1e6d2..257aef8e3497 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -108,6 +108,7 @@ public: void testRowHeight(); void testTdf93830(); void testTdf93097(); + void testTdf93868(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -150,6 +151,7 @@ public: CPPUNIT_TEST(testRowHeight); CPPUNIT_TEST(testTdf93830); CPPUNIT_TEST(testTdf93097); + CPPUNIT_TEST(testTdf93868); CPPUNIT_TEST_SUITE_END(); }; @@ -1309,6 +1311,19 @@ void SdImportTest::testTdf93097() xDocShRef->DoClose(); } +void SdImportTest::testTdf93868() +{ + sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf93868.pptx"), PPTX); + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = &(pDoc->GetPage(1)->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(); |