[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - include/oox oox/source sd/qa
Zolnai Tamás
tamas.zolnai at collabora.com
Fri Jun 6 08:55:36 PDT 2014
include/oox/drawingml/graphicshapecontext.hxx | 2 +
include/oox/ppt/pptshapegroupcontext.hxx | 3 --
oox/source/drawingml/graphicshapecontext.cxx | 14 +++++++++++--
oox/source/ppt/pptshapegroupcontext.cxx | 7 ------
sd/qa/unit/data/pptx/bnc880763.pptx |binary
sd/qa/unit/data/xml/n819614_0.xml | 18 ++++++++--------
sd/qa/unit/import-tests.cxx | 28 +++++++++++++++++++++++++-
7 files changed, 51 insertions(+), 21 deletions(-)
New commits:
commit 5b6d26becca7f7a03bbc615265c5426deb28244f
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Fri Jun 6 17:53:38 2014 +0200
bnc#880763: PPTX import: wrong z-order becuause of wrong import order
importExtDrawings() must be called as soon as possible,
before parser starts to parse the next shape.
Call it when graphicFrame tag is closed. This tag include
the reference to the SmartArt.
Plus fix up import tests.
(cherry picked from commit 46d682eec92bb241f4604a4b6ab42a3859cd0d48)
Change-Id: I9e8d54c2b1afeb78a1122390dc4982d580c152ae
diff --git a/include/oox/drawingml/graphicshapecontext.hxx b/include/oox/drawingml/graphicshapecontext.hxx
index 322f08e..a228f86 100644
--- a/include/oox/drawingml/graphicshapecontext.hxx
+++ b/include/oox/drawingml/graphicshapecontext.hxx
@@ -44,9 +44,11 @@ public:
GraphicalObjectFrameContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr, bool bEmbedShapesInChart );
virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE;
+ virtual void onEndElement() SAL_OVERRIDE;
private:
bool mbEmbedShapesInChart;
+ ::oox::core::ContextHandler2Helper* mpParent;
};
// ====================================================================
diff --git a/include/oox/ppt/pptshapegroupcontext.hxx b/include/oox/ppt/pptshapegroupcontext.hxx
index 847d9b6..5cae54d 100644
--- a/include/oox/ppt/pptshapegroupcontext.hxx
+++ b/include/oox/ppt/pptshapegroupcontext.hxx
@@ -32,7 +32,6 @@ class PPTShapeGroupContext : public ::oox::drawingml::ShapeGroupContext
ShapeLocation meShapeLocation;
oox::drawingml::ShapePtr pGraphicShape;
- void importExtDrawings();
void applyFontRefColor(oox::drawingml::ShapePtr pShape, const oox::drawingml::Color& rFontRefColor);
public:
@@ -46,7 +45,7 @@ public:
virtual ::oox::core::ContextHandlerRef
onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE;
- virtual void onEndElement() SAL_OVERRIDE;
+ void importExtDrawings();
protected:
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index e0818ac..cd4e75d 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -36,6 +36,7 @@
#include "oox/drawingml/transform2dcontext.hxx"
#include "oox/helper/binaryinputstream.hxx"
#include "oox/helper/binaryoutputstream.hxx"
+#include "oox/ppt/pptshapegroupcontext.hxx"
#include <comphelper/processfactory.hxx>
using namespace ::com::sun::star;
@@ -103,7 +104,8 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
GraphicalObjectFrameContext::GraphicalObjectFrameContext( ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr, bool bEmbedShapesInChart ) :
ShapeContext( rParent, pMasterShapePtr, pShapePtr ),
- mbEmbedShapesInChart( bEmbedShapesInChart )
+ mbEmbedShapesInChart( bEmbedShapesInChart ),
+ mpParent(&rParent)
{
}
@@ -146,7 +148,15 @@ ContextHandlerRef GraphicalObjectFrameContext::onCreateContext( sal_Int32 aEleme
return ShapeContext::onCreateContext( aElementToken, rAttribs );
}
-// ============================================================================
+void GraphicalObjectFrameContext::onEndElement()
+{
+ if( getCurrentElement() == PPT_TOKEN( graphicFrame ) && mpParent )
+ {
+ oox::ppt::PPTShapeGroupContext* pParent = dynamic_cast<oox::ppt::PPTShapeGroupContext*>(mpParent);
+ if( pParent )
+ pParent->importExtDrawings();
+ }
+}
OleObjectGraphicDataContext::OleObjectGraphicDataContext( ContextHandler2Helper& rParent, ShapePtr xShape ) :
ShapeContext( rParent, ShapePtr(), xShape ),
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index 0fd517f..9bf3d2b 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -109,8 +109,6 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
return new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) );
case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame
{
- if( pGraphicShape )
- importExtDrawings();
pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) );
return new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true );
}
@@ -150,11 +148,6 @@ void PPTShapeGroupContext::applyFontRefColor(oox::drawingml::ShapePtr pShape, co
}
}
-void PPTShapeGroupContext::onEndElement()
-{
- importExtDrawings();
-}
-
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/data/pptx/bnc880763.pptx b/sd/qa/unit/data/pptx/bnc880763.pptx
new file mode 100644
index 0000000..f45eb13
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc880763.pptx differ
diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml
index 6a834be..3c0b5b1 100644
--- a/sd/qa/unit/data/xml/n819614_0.xml
+++ b/sd/qa/unit/data/xml/n819614_0.xml
@@ -14,15 +14,6 @@
<Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
</Transformation>
</XShape>
- <XShape positionX="0" positionY="0" sizeX="100" sizeY="100" type="com.sun.star.drawing.GroupShape" name="Content Placeholder 4">
- <XShapes/>
- <Transformation>
- <Line1 column1="101.000000" column2="0.000000" column3="0.000000"/>
- <Line2 column1="0.000000" column2="101.000000" column3="0.000000"/>
- <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
- </Transformation>
- <InteropGrabBag/>
- </XShape>
<XShape positionX="182" positionY="2544" sizeX="25125" sizeY="16293" type="com.sun.star.drawing.GroupShape">
<XShapes>
<XShape positionX="10751" positionY="3496" sizeX="1563" sizeY="253" type="com.sun.star.drawing.CustomShape" fontHeight="18.000000" fontColor="ffffffff" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="TOP" textLeftDistance="250" textRightDistance="250" textUpperDistance="125" textLowerDistance="125" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName="">
@@ -7001,4 +6992,13 @@
</Transformation>
<InteropGrabBag/>
</XShape>
+ <XShape positionX="0" positionY="0" sizeX="100" sizeY="100" type="com.sun.star.drawing.GroupShape" name="Content Placeholder 4">
+ <XShapes/>
+ <Transformation>
+ <Line1 column1="101.000000" column2="0.000000" column3="0.000000"/>
+ <Line2 column1="0.000000" column2="101.000000" column3="0.000000"/>
+ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
+ </Transformation>
+ <InteropGrabBag/>
+ </XShape>
</XShapes>
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 4f68104..0b60132 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -60,6 +60,7 @@ public:
void testBnc870237();
void testBnc870233_1();
void testBnc870233_2();
+ void testBnc880763();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
@@ -74,6 +75,7 @@ public:
CPPUNIT_TEST(testBnc870237);
CPPUNIT_TEST(testBnc870233_1);
CPPUNIT_TEST(testBnc870233_2);
+ CPPUNIT_TEST(testBnc880763);
CPPUNIT_TEST_SUITE_END();
};
@@ -419,7 +421,7 @@ void SdFiltersTest::testBnc870237()
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
// Simulate a:ext inside dsp:txXfrm with changing the lower distance
- const SdrObjGroup* pObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 1 ) );
+ const SdrObjGroup* pObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) );
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextUpperDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue());
CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), (static_cast< const SdrTextLowerDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue());
@@ -564,6 +566,30 @@ void SdFiltersTest::testBnc870233_2()
xDocShRef->DoClose();
}
+void SdFiltersTest::testBnc880763()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx"));
+ xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+ const SdrPage *pPage = pDoc->GetPage (1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+ // Check z-order of the two shapes, use background color to identify them
+ // First object in the background has blue background color
+ const SdrObject *pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 0 ) );
+ CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor());
+
+ // Second object at the front has green background color
+ pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 1 ) );
+ CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor());
+
+
+ xDocShRef->DoClose();
+}
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
More information about the Libreoffice-commits
mailing list