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             |   16 ++++++-------
 sd/qa/unit/import-tests.cxx                   |   32 +++++++++++++++++++++++---
 7 files changed, 52 insertions(+), 22 deletions(-)

New commits:
commit 7c7c7dc785750769d661df1dc36201b9f5566ea1
Author: Zolnai Tamás <tamas.zol...@collabora.com>
Date:   Fri Jun 6 15:57:43 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.
    
    Change-Id: I9e8d54c2b1afeb78a1122390dc4982d580c152ae
    (cherry picked from commit 46d682eec92bb241f4604a4b6ab42a3859cd0d48)

diff --git a/include/oox/drawingml/graphicshapecontext.hxx 
b/include/oox/drawingml/graphicshapecontext.hxx
index 72881fe..fe4b216 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 ebd2028..db04d5c 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 fb879cd..22543cf 100644
--- a/sd/qa/unit/data/xml/n819614_0.xml
+++ b/sd/qa/unit/data/xml/n819614_0.xml
@@ -14,14 +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>
- </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="">
@@ -6888,4 +6880,12 @@
    <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>
+ </XShape>
 </XShapes>
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 0b032c1..1c36673 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -77,6 +77,7 @@ public:
     void testBnc870237();
     void testBnc870233_1();
     void testBnc870233_2();
+    void testBnc880763();
 
     CPPUNIT_TEST_SUITE(SdFiltersTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -104,6 +105,7 @@ public:
     CPPUNIT_TEST(testBnc870237);
     CPPUNIT_TEST(testBnc870233_1);
     CPPUNIT_TEST(testBnc870233_2);
+    CPPUNIT_TEST(testBnc880763);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -293,7 +295,7 @@ void SdFiltersTest::testN862510_2()
     const SdrPage *pPage = pDoc->GetPage(1);
     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     {
-        SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 1 ) 
);
+        SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) 
);
         CPPUNIT_ASSERT( pGrpObj );
         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( 
pGrpObj->GetSubList()->GetObj( 0 ) );
         CPPUNIT_ASSERT( pObj );
@@ -312,7 +314,7 @@ void SdFiltersTest::testN862510_3()
     const SdrPage *pPage = pDoc->GetPage( 1 );
     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     {
-        SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 1 ) 
);
+        SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) 
);
         CPPUNIT_ASSERT( pGrpObj );
         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( 
pGrpObj->GetSubList()->GetObj( 0 ) );
         CPPUNIT_ASSERT( pObj );
@@ -755,7 +757,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());
@@ -900,6 +902,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);
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to