From 8d613870b2cd2e3e4396b4fa97dbd8080fda8f52 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Fri, 18 Nov 2016 22:57:29 +0000 Subject: tdf#104015: PPTX import: Title shape does not inherit fill properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...from slide master. The problem caused by that PPTX files contains not a one-level master slide set, but has two levels: one called slide master, other called slide layout. Slide layout inherit properties from slide master and normal slide inherit propetries from slide layout. Bug appeared because, slide layout inherited properties were not forwarded to the normal slide. Change-Id: I587582498cf4315087f9a576c1b7fc41ee23e2fd Reviewed-on: https://gerrit.libreoffice.org/30969 Tested-by: Jenkins Reviewed-by: Tamás Zolnai --- oox/source/drawingml/shape.cxx | 111 +++++++++++++++++++++++++++++++---------- 1 file changed, 85 insertions(+), 26 deletions(-) (limited to 'oox/source') diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index f027cd159524..0ee6cef28eef 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -303,11 +303,11 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) else mpTextBody.reset(); maShapeProperties = rReferencedShape.maShapeProperties; - mpShapeRefLinePropPtr = std::make_shared( *rReferencedShape.mpLinePropertiesPtr.get() ); - mpShapeRefFillPropPtr = std::make_shared( *rReferencedShape.mpFillPropertiesPtr.get() ); + mpShapeRefLinePropPtr = std::make_shared( rReferencedShape.getActualLineProperties(nullptr) ); + mpShapeRefFillPropPtr = std::make_shared( rReferencedShape.getActualFillProperties(nullptr, nullptr) ); mpCustomShapePropertiesPtr = std::make_shared( *rReferencedShape.mpCustomShapePropertiesPtr.get() ); mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : nullptr ); - mpShapeRefEffectPropPtr = std::make_shared( *rReferencedShape.mpEffectPropertiesPtr.get() ); + mpShapeRefEffectPropPtr = std::make_shared( rReferencedShape.getActualEffectProperties(nullptr) ); mpMasterTextListStyle = std::make_shared( *rReferencedShape.mpMasterTextListStyle.get() ); maSize = rReferencedShape.maSize; maPosition = rReferencedShape.maPosition; @@ -654,25 +654,17 @@ Reference< XShape > const & 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 ); @@ -690,8 +682,6 @@ Reference< XShape > const & 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(); @@ -708,8 +698,6 @@ Reference< XShape > const & 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 ); @@ -721,15 +709,6 @@ Reference< XShape > const & 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 @@ -749,8 +728,12 @@ Reference< XShape > const & 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 ); @@ -1461,6 +1444,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; -- cgit