From f8586c223f07ddff4bba5d5c694cee33ac811412 Mon Sep 17 00:00:00 2001 From: Grzegorz Araminowicz Date: Thu, 14 Mar 2019 08:25:12 +0100 Subject: PPTX import: import SmartArt drawing into single GroupShape before that there were imported two GroupShapes: - empty one with properties like id, name, InteropGrapBag - second one with actual shapes also fixed tests that relyed on that behaviour Change-Id: I2b94a53e21666b16725c4353448d75e916e4f9df Reviewed-on: https://gerrit.libreoffice.org/69252 Tested-by: Jenkins Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/72472 --- oox/source/ppt/extdrawingfragmenthandler.cxx | 6 +----- oox/source/ppt/extdrawingfragmenthandler.hxx | 1 - oox/source/ppt/pptshapegroupcontext.cxx | 7 +++++-- sd/qa/unit/data/xml/n819614_0.xml | 10 +--------- sd/qa/unit/export-tests-ooxml1.cxx | 6 +++--- sd/qa/unit/export-tests-ooxml2.cxx | 4 ++-- sd/qa/unit/import-tests.cxx | 1 + 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/oox/source/ppt/extdrawingfragmenthandler.cxx b/oox/source/ppt/extdrawingfragmenthandler.cxx index a0d40ea0412c..cf8d8e50ed3c 100644 --- a/oox/source/ppt/extdrawingfragmenthandler.cxx +++ b/oox/source/ppt/extdrawingfragmenthandler.cxx @@ -29,7 +29,7 @@ ExtDrawingFragmentHandler::ExtDrawingFragmentHandler( XmlFilterBase& rFilter, mpSlidePersistPtr (rSlidePersistPtr ), meShapeLocation( eShapeLocation ), mpGroupShapePtr( pGroupShapePtr ), - mpOrgShapePtr( pShapePtr ) + mpShapePtr( pShapePtr ) { } @@ -49,10 +49,6 @@ ExtDrawingFragmentHandler::onCreateContext( ::sal_Int32 aElement, case DSP_TOKEN( drawing ): break; case DSP_TOKEN( spTree ): - mpShapePtr = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ); - mpShapePtr->setPosition( mpOrgShapePtr->getPosition() ); - mpShapePtr->setName( mpOrgShapePtr->getName() ); - return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, mpShapePtr ); diff --git a/oox/source/ppt/extdrawingfragmenthandler.hxx b/oox/source/ppt/extdrawingfragmenthandler.hxx index 83dfcd216e8f..cdde03777bc1 100644 --- a/oox/source/ppt/extdrawingfragmenthandler.hxx +++ b/oox/source/ppt/extdrawingfragmenthandler.hxx @@ -34,7 +34,6 @@ private: const oox::ppt::SlidePersistPtr mpSlidePersistPtr; const oox::ppt::ShapeLocation meShapeLocation; oox::drawingml::ShapePtr const mpGroupShapePtr; - oox::drawingml::ShapePtr mpOrgShapePtr; // Original Shape data, if any oox::drawingml::ShapePtr mpShapePtr; }; diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 1180af3f10fb..9a775655518f 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -71,9 +71,12 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken { case PPT_TOKEN( cNvPr ): { + // don't override SmartArt properties for embedded drawing's spTree mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); - mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() ); - mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() ); + if (mpGroupShapePtr->getId().isEmpty()) + mpGroupShapePtr->setId(rAttribs.getString(XML_id).get()); + if (mpGroupShapePtr->getName().isEmpty()) + mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; } case PPT_TOKEN( ph ): diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml index e51b520d3130..fc109917c460 100644 --- a/sd/qa/unit/data/xml/n819614_0.xml +++ b/sd/qa/unit/data/xml/n819614_0.xml @@ -14,7 +14,7 @@ - + @@ -6824,12 +6824,4 @@ - - - - - - - - diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 7cc50e21f963..3e832aad4e3f 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -231,7 +231,7 @@ void SdOOXMLExportTest1::testBnc870233_2() // Second smart art has "dk2" font color (style) { - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(2)); // FIXME should be 1, smartart import creates an additional empty group for some reason + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(1)); CPPUNIT_ASSERT(pObjGroup); const SdrTextObj *pObj = dynamic_cast(pObjGroup->GetSubList()->GetObj(0)); checkFontAttributes( pObj, Color(0x1F497D) ); @@ -239,7 +239,7 @@ void SdOOXMLExportTest1::testBnc870233_2() // Third smart art has white font color (style) { - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(4)); // FIXME should be 2, smartart import creates an additional empty group for some reason + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(2)); CPPUNIT_ASSERT(pObjGroup); const SdrTextObj *pObj = dynamic_cast(pObjGroup->GetSubList()->GetObj(0)); checkFontAttributes(pObj, Color(0xffffff)); @@ -381,7 +381,7 @@ void SdOOXMLExportTest1::testBnc880763() CPPUNIT_ASSERT_EQUAL( Color(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue()); // Second object at the front has green background color - pObj = pPage->GetObj(2); // FIXME should be 1, smartart import creates an additional empty group for some reason + pObj = pPage->GetObj(1); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( Color(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue()); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 80090c1656ae..7555ce0ea1e4 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1417,10 +1417,10 @@ void SdOOXMLExportTest2::testGroupsPosition() xDocShRef->DoClose(); xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920"); assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "4040640"); assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "4273920"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920"); } void SdOOXMLExportTest2::testGroupsRotatedPosition() diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 14a907316d70..6ca42293bf1c 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -444,6 +444,7 @@ void SdImportTest::testN862510_2() const SdrPage *pPage = GetPage( 1, xDocShRef ); { + CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount()); SdrObjGroup *pGrpObj = dynamic_cast( pPage->GetObj( 0 ) ); CPPUNIT_ASSERT( pGrpObj ); SdrObjCustomShape *pObj = dynamic_cast( pGrpObj->GetSubList()->GetObj( 0 ) ); -- cgit v1.2.3