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@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
This commit is contained in:
Matus Uzak
2016-03-08 21:44:21 +01:00
committed by Katarina Behrens
parent 15b53976e5
commit f3d1ac75c4
6 changed files with 21 additions and 11 deletions

View File

@@ -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;

View File

@@ -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 );

View File

@@ -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;

View File

@@ -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 );

Binary file not shown.

View File

@@ -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();