diff options
-rw-r--r-- | include/oox/drawingml/shape.hxx | 6 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 111 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf104015.pptx | bin | 0 -> 19185 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 40 |
4 files changed, 130 insertions, 27 deletions
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index 0c1150ad932b..dbe1ff8a4537 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -101,7 +101,7 @@ public: table::TablePropertiesPtr getTableProperties(); - EffectProperties& getEffectProperties() { return *mpEffectPropertiesPtr; } + EffectProperties& getEffectProperties() const { return *mpEffectPropertiesPtr; } void setChildPosition( css::awt::Point nPosition ){ maChPosition = nPosition; } void setChildSize( css::awt::Size aSize ){ maChSize = aSize; } @@ -235,6 +235,10 @@ protected: void putPropertiesToGrabBag( const css::uno::Sequence< css::beans::PropertyValue >& aProperties ); + FillProperties getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const; + LineProperties getActualLineProperties(const Theme* pTheme) const; + EffectProperties getActualEffectProperties(const Theme* pTheme) const; + std::vector< ShapePtr > maChildren; // only used for group shapes css::awt::Size maChSize; // only used for group shapes css::awt::Point maChPosition; // only used for group shapes diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 8bd5cfc4c46b..c7dc12206a8e 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -297,11 +297,11 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) else mpTextBody.reset(); maShapeProperties = rReferencedShape.maShapeProperties; - mpShapeRefLinePropPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) ); - mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) ); + mpShapeRefLinePropPtr = LinePropertiesPtr( new LineProperties( rReferencedShape.getActualLineProperties(nullptr) ) ); + mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( rReferencedShape.getActualFillProperties(nullptr, nullptr) ) ); mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) ); mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : nullptr ); - mpShapeRefEffectPropPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) ); + mpShapeRefEffectPropPtr = EffectPropertiesPtr( new EffectProperties( rReferencedShape.getActualEffectProperties(nullptr) ) ); mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) ); maShapeStyleRefs = rReferencedShape.maShapeStyleRefs; maSize = rReferencedShape.maSize; @@ -607,25 +607,17 @@ Reference< XShape > Shape::createAndInsert( const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper(); - LineProperties aLineProperties; - aLineProperties.maLineFill.moFillType = XML_noFill; sal_Int32 nLinePhClr = -1; - FillProperties aFillProperties; - aFillProperties.moFillType = XML_noFill; sal_Int32 nFillPhClr = -1; - EffectProperties aEffectProperties; // TODO: use ph color when applying effect properties //sal_Int32 nEffectPhClr = -1; - // First apply reference shape's properties (shape on the master slide) - aFillProperties.assignUsed( *mpShapeRefFillPropPtr ); - aLineProperties.assignUsed( *mpShapeRefLinePropPtr ); - aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr ); - if( pTheme ) { if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) ) { + LineProperties aLineProperties; + aLineProperties.maLineFill.moFillType = XML_noFill; if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) aLineProperties.assignUsed( *pLineProps ); nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper ); @@ -643,8 +635,6 @@ Reference< XShape > Shape::createAndInsert( } if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) ) { - if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) ) - aFillProperties.assignUsed( *pFillProps ); nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper ); OUString sColorScheme = pFillRef->maPhClr.getSchemeName(); @@ -661,8 +651,6 @@ Reference< XShape > Shape::createAndInsert( } if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) ) { - if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) ) - aEffectProperties.assignUsed( *pEffectProps ); // TODO: use ph color when applying effect properties // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper ); @@ -674,15 +662,6 @@ Reference< XShape > Shape::createAndInsert( putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) ); } } - - aLineProperties.assignUsed( getLineProperties() ); - - // group fill inherits from parent - if ( getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill ) - getFillProperties().assignUsed( rShapeOrParentShapeFillProps ); - aFillProperties.assignUsed( getFillProperties() ); - aEffectProperties.assignUsed ( getEffectProperties() ); - ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() ); // add properties from textbody to shape properties @@ -702,8 +681,12 @@ Reference< XShape > Shape::createAndInsert( mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper ); if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); + + FillProperties aFillProperties = getActualFillProperties(pTheme, &rShapeOrParentShapeFillProps); aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV ); + LineProperties aLineProperties = getActualLineProperties(pTheme); aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr ); + EffectProperties aEffectProperties = getActualEffectProperties(pTheme); // TODO: use ph color when applying effect properties aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper ); @@ -1410,6 +1393,82 @@ void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties } } +FillProperties Shape::getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const +{ + FillProperties aFillProperties; + aFillProperties.moFillType = XML_noFill; + + // Reference shape properties + aFillProperties.assignUsed( *mpShapeRefFillPropPtr ); + + // Theme + if( pTheme != nullptr ) + { + if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) ) + { + if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) ) + aFillProperties.assignUsed( *pFillProps ); + } + } + + // Parent shape's properties + if ( pParentShapeFillProps != nullptr) + if( getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill ) + aFillProperties.assignUsed( *pParentShapeFillProps ); + + // Properties specified directly for this shape + aFillProperties.assignUsed( getFillProperties() ); + + return aFillProperties; +} + +LineProperties Shape::getActualLineProperties(const Theme* pTheme) const +{ + LineProperties aLineProperties; + aLineProperties.maLineFill.moFillType = XML_noFill; + + // Reference shape properties + aLineProperties.assignUsed( *mpShapeRefLinePropPtr ); + + // Theme + if( pTheme != nullptr ) + { + if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) ) + { + if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) + aLineProperties.assignUsed( *pLineProps ); + } + } + + // Properties specified directly for this shape + aLineProperties.assignUsed( getLineProperties() ); + + return aLineProperties; +} + +EffectProperties Shape::getActualEffectProperties(const Theme* pTheme) const +{ + EffectProperties aEffectProperties; + + // Reference shape properties + aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr ); + + // Theme + if( pTheme != nullptr ) + { + if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) ) + { + if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) ) + aEffectProperties.assignUsed( *pEffectProps ); + } + } + + // Properties specified directly for this shape + aEffectProperties.assignUsed ( getEffectProperties() ); + + return aEffectProperties; +} + uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType ) { uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp; diff --git a/sd/qa/unit/data/pptx/tdf104015.pptx b/sd/qa/unit/data/pptx/tdf104015.pptx Binary files differnew file mode 100644 index 000000000000..f3675f9e8805 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf104015.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index f8af062b7ead..2a330ccabcc7 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -115,6 +115,7 @@ public: void testTdf93868(); void testTdf103792(); void testTdf103876(); + void testTdf104015(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -161,6 +162,7 @@ public: CPPUNIT_TEST(testTdf93868); CPPUNIT_TEST(testTdf103792); CPPUNIT_TEST(testTdf103876); + CPPUNIT_TEST(testTdf104015); CPPUNIT_TEST_SUITE_END(); }; @@ -1274,6 +1276,44 @@ void SdImportTest::testTdf103876() xDocShRef->DoClose(); } +void SdImportTest::testTdf104015() +{ + // Shape fill, line and effect properties were not inherited from master slide shape + sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/tdf104015.pptx"), PPTX); + + const SdrPage *pPage = GetPage( 1, xDocShRef ); + CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr); + SdrObject *const pObj = pPage->GetObj(0); + CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr); + // Should have a red fill color + { + const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>( + pObj->GetMergedItem(XATTR_FILLSTYLE)); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue()); + const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>( + pObj->GetMergedItem(XATTR_FILLCOLOR)); + CPPUNIT_ASSERT_EQUAL(ColorData(0xFF0000), rColorItem.GetColorValue().GetColor()); + } + // Should have a blue line + { + const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>( + pObj->GetMergedItem(XATTR_LINESTYLE)); + CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue()); + + const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>( + pObj->GetMergedItem(XATTR_LINECOLOR)); + CPPUNIT_ASSERT_EQUAL(ColorData(0x0000FF), rColorItem.GetColorValue().GetColor()); + } + // Should have some shadow + { + const SdrOnOffItem& rShadowItem = dynamic_cast<const SdrOnOffItem&>( + pObj->GetMergedItem(SDRATTR_SHADOW)); + CPPUNIT_ASSERT(rShadowItem.GetValue()); + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |