[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - include/oox oox/source sd/qa
Tamás Zolnai
tamas.zolnai at collabora.com
Sat Nov 26 22:50:49 UTC 2016
include/oox/drawingml/shape.hxx | 6 +
oox/source/drawingml/shape.cxx | 111 +++++++++++++++++++++++++++---------
sd/qa/unit/data/pptx/tdf104015.pptx |binary
sd/qa/unit/import-tests.cxx | 40 ++++++++++++
4 files changed, 130 insertions(+), 27 deletions(-)
New commits:
commit 502b8d0d4178174130609b4b3085714864fb7b64
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Sat Nov 19 00:10:01 2016 +0000
tdf#104015: PPTX import: Title shape does not inherit fill properties
...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.
Reviewed-on: https://gerrit.libreoffice.org/30969
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 8d613870b2cd2e3e4396b4fa97dbd8080fda8f52)
Conflicts:
sd/qa/unit/import-tests.cxx
Change-Id: I587582498cf4315087f9a576c1b7fc41ee23e2fd
Reviewed-on: https://gerrit.libreoffice.org/30971
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 520bc51..80c17b2 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -125,7 +125,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; }
@@ -259,6 +259,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 483ba4d..5f6a066 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -302,11 +302,11 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
else
mpTextBody.reset();
maShapeProperties = rReferencedShape.maShapeProperties;
- mpShapeRefLinePropPtr = std::make_shared<LineProperties>( *rReferencedShape.mpLinePropertiesPtr.get() );
- mpShapeRefFillPropPtr = std::make_shared<FillProperties>( *rReferencedShape.mpFillPropertiesPtr.get() );
+ mpShapeRefLinePropPtr = std::make_shared<LineProperties>( rReferencedShape.getActualLineProperties(nullptr) );
+ mpShapeRefFillPropPtr = std::make_shared<FillProperties>( rReferencedShape.getActualFillProperties(nullptr, nullptr) );
mpCustomShapePropertiesPtr = std::make_shared<CustomShapeProperties>( *rReferencedShape.mpCustomShapePropertiesPtr.get() );
mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : nullptr );
- mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( *rReferencedShape.mpEffectPropertiesPtr.get() );
+ mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( rReferencedShape.getActualEffectProperties(nullptr) );
mpMasterTextListStyle = std::make_shared<TextListStyle>( *rReferencedShape.mpMasterTextListStyle.get() );
maSize = rReferencedShape.maSize;
maPosition = rReferencedShape.maPosition;
@@ -654,25 +654,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 );
@@ -690,8 +682,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();
@@ -708,8 +698,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 );
@@ -721,15 +709,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
@@ -749,8 +728,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 );
@@ -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;
diff --git a/sd/qa/unit/data/pptx/tdf104015.pptx b/sd/qa/unit/data/pptx/tdf104015.pptx
new file mode 100644
index 0000000..f3675f9
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf104015.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index e36d042..8aaf485 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -125,6 +125,7 @@ public:
void testTdf103473();
void testTdf103792();
void testTdf103876();
+ void testTdf104015();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -178,6 +179,7 @@ public:
CPPUNIT_TEST(testTdf103473);
CPPUNIT_TEST(testTdf103792);
CPPUNIT_TEST(testTdf103876);
+ CPPUNIT_TEST(testTdf104015);
CPPUNIT_TEST_SUITE_END();
};
@@ -1465,6 +1467,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(m_directories.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();
More information about the Libreoffice-commits
mailing list