diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-05-08 21:49:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-10 12:18:29 +0200 |
commit | c86cf2aaa07538e8c37dc81729905a3bb9ecc1ff (patch) | |
tree | ccf989aacdbb0718784518e34a9c942d66b569f7 | |
parent | 96dd1cd36c2f9446d3455a06b5f77a3954950c03 (diff) |
SmartArt: support diagram background
Solved by adding additional shape filling whole diagram.
MS PowerPoint does the same when converting SmartArt to shapes.
Background shape is also copied when loading from drawingML fallback,
appearently there is no background information.
Corrected SmartArt import tests, so that they are aware of extra shape.
Change-Id: I6154f8e1b34e5867ab582d6fc54459c7c93edbac
Reviewed-on: https://gerrit.libreoffice.org/72012
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | include/oox/drawingml/shape.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 11 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 9 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 8 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx | bin | 0 -> 40964 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/smartart-background.pptx | bin | 0 -> 50424 bytes | |||
-rw-r--r-- | sd/qa/unit/data/xml/n819614_0.xml | 69 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml1.cxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 8 | ||||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 255 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 7 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 4 |
13 files changed, 278 insertions, 107 deletions
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index e7d06476656d..1f8b163b5d35 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -151,6 +151,7 @@ public: void setDescription( const OUString& rDescr ) { msDescription = rDescr; } void setHidden( bool bHidden ) { mbHidden = bHidden; } void setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; } + void setLocked( bool bLocked ) { mbLocked = bLocked; } void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; } sal_Int32 getSubType() const { return mnSubType; } void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; } @@ -340,6 +341,7 @@ private: bool mbHiddenMasterShape; // master shapes can be hidden in layout slides // we need separate flag because we don't want // to propagate it when applying reference shape + bool mbLocked; bool mbLockedCanvas; ///< Is this shape part of a locked canvas? bool mbWps; ///< Is this a wps shape? bool mbTextBox; ///< This shape has a textbox. diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 76e5e9089a35..e8e661e64d51 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -29,6 +29,7 @@ #include <drawingml/textrun.hxx> #include <drawingml/diagram/diagram.hxx> #include <drawingml/fillproperties.hxx> +#include <drawingml/customshapeproperties.hxx> #include <oox/ppt/pptshapegroupcontext.hxx> #include <oox/ppt/pptshape.hxx> #include <oox/token/namespaces.hxx> @@ -314,6 +315,16 @@ void Diagram::addTo( const ShapePtr & pParentShape ) ShapeLayoutingVisitor aLayoutingVisitor; mpLayout->getNode()->accept(aLayoutingVisitor); } + + ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape")); + pBackground->setSubType(XML_rect); + pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect); + pBackground->setSize(pParentShape->getSize()); + pBackground->getFillProperties() = *mpData->getFillProperties(); + pBackground->setLocked(true); + auto& aChildren = pParentShape->getChildren(); + aChildren.insert(aChildren.begin(), pBackground); + pParentShape->setDiagramDoms( getDomsAsPropertyValues() ); } diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 41c8d9493dcf..64c80568f7a8 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -128,6 +128,7 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight ) , mbFlipV( false ) , mbHidden( false ) , mbHiddenMasterShape( false ) +, mbLocked( false ) , mbLockedCanvas( false ) , mbWps( false ) , mbTextBox( false ) @@ -171,6 +172,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) , mbFlipV( pSourceShape->mbFlipV ) , mbHidden( pSourceShape->mbHidden ) , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape ) +, mbLocked( pSourceShape->mbLocked ) , mbLockedCanvas( pSourceShape->mbLockedCanvas ) , mbWps( pSourceShape->mbWps ) , mbTextBox( pSourceShape->mbTextBox ) @@ -335,6 +337,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) mbFlipH = rReferencedShape.mbFlipH; mbFlipV = rReferencedShape.mbFlipV; mbHidden = rReferencedShape.mbHidden; + mbLocked = rReferencedShape.mbLocked; } struct ActionLockGuard @@ -856,6 +859,12 @@ Reference< XShape > const & Shape::createAndInsert( xSet->setPropertyValue( sPrintable, Any( false ) ); } + if (mbLocked) + { + xSet->setPropertyValue("MoveProtect", Any(true)); + xSet->setPropertyValue("SizeProtect", Any(true)); + } + ActionLockGuard const alg(mxShape); // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 3035a390a36f..41cf6973b492 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -434,6 +434,14 @@ ShapeContextHandler::getShape() pShapePtr->setDiagramDoms(mpShape->getDiagramDoms()); pShapePtr->keepDiagramDrawing(*mxFilterBase, aFragmentPath); + if (!mpShape->getChildren().empty()) + { + // first child is diagram background - we want to keep it, as drawingML fallback doesn't contain it + auto& aChildren = pShapePtr->getChildren(); + ShapePtr pBackground = mpShape->getChildren().front(); + aChildren.insert(aChildren.begin(), pBackground); + } + pShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShapePtr->getFillProperties() ); xResult = pShapePtr->getXShape(); } diff --git a/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx b/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx Binary files differnew file mode 100644 index 000000000000..d89f28a21c02 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx diff --git a/sd/qa/unit/data/pptx/smartart-background.pptx b/sd/qa/unit/data/pptx/smartart-background.pptx Binary files differnew file mode 100644 index 000000000000..beb862dc12d3 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-background.pptx diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml index fc109917c460..72e28f38c82d 100644 --- a/sd/qa/unit/data/xml/n819614_0.xml +++ b/sd/qa/unit/data/xml/n819614_0.xml @@ -14,8 +14,71 @@ <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" name="Content Placeholder 4"> + <XShape positionX="0" positionY="2328" sizeX="25399" sizeY="16509" type="com.sun.star.drawing.GroupShape" name="Content Placeholder 4"> <XShapes> + <XShape positionX="0" positionY="2328" sizeX="25399" sizeY="16509" 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=""> + <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> + <FillGradient style="LINEAR" startColor="3465a4" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> + <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/> + <FillBitmap width="32" height="32"/> + <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/> + <LineStart/> + <LineEnd/> + <Transformation> + <Line1 column1="25400.000000" column2="0.000000" column3="0.000000"/> + <Line2 column1="0.000000" column2="16510.000000" column3="2328.000000"/> + <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/> + </Transformation> + <CustomShapeGeometry> + <PropertyValue name="AdjustmentValues"> + <AdjustmentValues/> + </PropertyValue> + <PropertyValue name="Equations" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="Handles"> + <Handles/> + </PropertyValue> + <PropertyValue name="MirroredX" value="false" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="MirroredY" value="false" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="Path"> + <Path> + <PropertyValue name="Coordinates"> + <Coordinates> + <EnhancedCustomShapeParameterPair> + <First value="0" type="0"/> + <Second value="0" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="3" type="1"/> + <Second value="0" type="0"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="3" type="1"/> + <Second value="2" type="1"/> + </EnhancedCustomShapeParameterPair> + <EnhancedCustomShapeParameterPair> + <First value="0" type="0"/> + <Second value="2" type="1"/> + </EnhancedCustomShapeParameterPair> + </Coordinates> + </PropertyValue> + <PropertyValue name="Segments"> + <Segments> + <EnhancedCustomShapeSegment command="1" count="1"/> + <EnhancedCustomShapeSegment command="2" count="3"/> + <EnhancedCustomShapeSegment command="4" count="0"/> + <EnhancedCustomShapeSegment command="5" count="0"/> + </Segments> + </PropertyValue> + <PropertyValue name="TextFrames" handle="0" propertyState="DIRECT_VALUE"/> + </Path> + </PropertyValue> + <PropertyValue name="TextPreRotateAngle" value="0" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="Type" value="ooxml-rect" handle="0" propertyState="DIRECT_VALUE"/> + <PropertyValue name="ViewBox"> + <ViewBox x="0" y="0" width="0" height="0"/> + </PropertyValue> + </CustomShapeGeometry> + </XShape> <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=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> <FillGradient style="LINEAR" startColor="3465a4" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> @@ -6819,8 +6882,8 @@ </XShape> </XShapes> <Transformation> - <Line1 column1="25126.000000" column2="0.000000" column3="182.000000"/> - <Line2 column1="0.000000" column2="16294.000000" column3="2544.000000"/> + <Line1 column1="25400.000000" column2="0.000000" column3="0.000000"/> + <Line2 column1="0.000000" column2="16510.000000" column3="2328.000000"/> <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/> </Transformation> </XShape> diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 9c7b6381e56d..ad636943a60d 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -373,7 +373,7 @@ void SdOOXMLExportTest1::testBnc880763() // First object in the background has blue background color const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0)); CPPUNIT_ASSERT(pObjGroup); - const SdrObject *pObj = pObjGroup->GetSubList()->GetObj(0); + const SdrObject *pObj = pObjGroup->GetSubList()->GetObj(1); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( Color(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue()); @@ -395,7 +395,7 @@ void SdOOXMLExportTest1::testBnc862510_5() // Same as testBnc870237, but here we check the horizontal spacing const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0)); CPPUNIT_ASSERT(pObjGroup); - const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(1); + const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(2); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue()); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue()); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 66c6154f1da2..73cd138ee259 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1375,10 +1375,10 @@ void SdOOXMLExportTest2::testSmartartRotation2() xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); assertXPathContent(pXmlDocContent, - "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:p/a:r/a:t", "Text"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000"); - double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x").toDouble(); - double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y").toDouble(); + "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:txBody/a:p/a:r/a:t", "Text"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:txBody/a:bodyPr", "rot", "10800000"); + double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:spPr/a:xfrm/a:off", "x").toDouble(); + double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:spPr/a:xfrm/a:off", "y").toDouble(); CPPUNIT_ASSERT_DOUBLES_EQUAL( 2276280.0, dX, dX * .001); CPPUNIT_ASSERT_DOUBLES_EQUAL( 3158280.0, dY, dY * .001); } diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 61b4e44f1b50..a1acd88cc213 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -72,6 +72,8 @@ public: void testCycleMatrix(); void testPictureStrip(); void testInteropGrabBag(); + void testBackground(); + void testBackgroundDrawingmlFallback(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -106,6 +108,8 @@ public: CPPUNIT_TEST(testCycleMatrix); CPPUNIT_TEST(testPictureStrip); CPPUNIT_TEST(testInteropGrabBag); + CPPUNIT_TEST(testBackground); + CPPUNIT_TEST(testBackgroundDrawingmlFallback); CPPUNIT_TEST_SUITE_END(); }; @@ -114,20 +118,20 @@ void SdImportTestSmartArt::testBase() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart1.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup->getCount()); - uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString()); - uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString()); - uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString()); - uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3->getString()); - uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4->getString()); - uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); sal_Int32 nFillColor = 0; xShape->getPropertyValue("FillColor") >>= nFillColor; @@ -139,11 +143,11 @@ void SdImportTestSmartArt::testBase() xPropSet->getPropertyValue("ParaAdjust") >>= nParaAdjust; CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust)); - uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y,xShape1->getPosition().Y); CPPUNIT_ASSERT_EQUAL(xShape2->getPosition().Y,xShape3->getPosition().Y); CPPUNIT_ASSERT(xShape2->getPosition().Y > xShape0->getPosition().Y); @@ -159,9 +163,9 @@ void SdImportTestSmartArt::testChildren() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-children.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount()); - uno::Reference<drawing::XShapes> xShapeGroup0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapeGroup0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup0->getCount()); uno::Reference<text::XText> xTextA(xShapeGroup0->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA->getString()); @@ -175,7 +179,7 @@ void SdImportTestSmartArt::testChildren() uno::Reference<text::XText> xTextC(xChildC->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xTextC->getString()); - uno::Reference<drawing::XShapes> xShapeGroup1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapeGroup1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup1->getCount()); uno::Reference<text::XText> xTextX(xShapeGroup1->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("x"), xTextX->getString()); @@ -196,7 +200,7 @@ void SdImportTestSmartArt::testText() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-text.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShapes> xShapeGroup2(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapeGroup2(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); uno::Reference<text::XText> xText0(xShapeGroup2->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xText0->getString().isEmpty()); @@ -228,10 +232,10 @@ void SdImportTestSmartArt::testDir() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-dir.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount()); - uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xShape0->getPosition().X > xShape1->getPosition().X); xDocShRef->DoClose(); @@ -241,15 +245,15 @@ void SdImportTestSmartArt::testMaxDepth() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-maxdepth.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount()); - uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("first"), xText0->getString()); - uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("second"), xText1->getString()); - uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y , xShape1->getPosition().Y); // Confirms shapes are in same Y axis-level. xDocShRef->DoClose(); @@ -260,13 +264,13 @@ void SdImportTestSmartArt::testRotation() sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySet> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape0->getPropertyValue("RotateAngle").get<sal_Int32>()); - uno::Reference<beans::XPropertySet> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(24000), xShape1->getPropertyValue("RotateAngle").get<sal_Int32>()); - uno::Reference<beans::XPropertySet> xShape2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(12000), xShape2->getPropertyValue("RotateAngle").get<sal_Int32>()); xDocShRef->DoClose(); @@ -283,6 +287,7 @@ void SdImportTestSmartArt::testTextAutoRotation() uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, pageNo, xDocShRef), uno::UNO_QUERY_THROW); + txtNo++; //skip background uno::Reference<text::XText> xTxt(xShapeGroup->getByIndex(txtNo), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expTx, xTxt->getString()); uno::Reference<beans::XPropertySet> xTxtProps(xTxt, uno::UNO_QUERY_THROW); @@ -375,18 +380,18 @@ void SdImportTestSmartArt::testChevron() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-chevron.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup->getCount()); - uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString()); - uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString()); - uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString()); - uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xShape0->getPosition().X < xShape1->getPosition().X && xShape1->getPosition().X < xShape2->getPosition().X); CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y, xShape1->getPosition().Y); @@ -402,12 +407,12 @@ void SdImportTestSmartArt::testCycle() uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xGroup.is()); - // 10 children: 5 shapes, 5 connectors - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10), xGroup->getCount()); + // 11 children: background, 5 shapes, 5 connectors + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11), xGroup->getCount()); - uno::Reference<drawing::XShape> xShape0(xGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(1), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(3), uno::UNO_QUERY_THROW); uno::Reference<text::XText> xText0(xShape0, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString()); @@ -458,10 +463,10 @@ void SdImportTestSmartArt::testMultidirectional() uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xGroup.is()); - // 6 children: 3 shapes, 3 connectors - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6), xGroup->getCount()); + // 7 children: background, 3 shapes, 3 connectors + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7), xGroup->getCount()); - uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(2), uno::UNO_QUERY_THROW); uno::Reference<beans::XPropertySet> xPropSetConn(xShapeConn, uno::UNO_QUERY_THROW); comphelper::SequenceAsHashMap aCustomShapeGeometry( xPropSetConn->getPropertyValue("CustomShapeGeometry")); @@ -494,20 +499,20 @@ void SdImportTestSmartArt::testBaseRtoL() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rightoleftblockdiagram.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup->getCount()); - uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString()); - uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString()); - uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString()); - uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3->getString()); - uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4->getString()); - uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); sal_Int32 nFillColor = 0; xShape->getPropertyValue("FillColor") >>= nFillColor; @@ -519,11 +524,11 @@ void SdImportTestSmartArt::testBaseRtoL() xPropSet->getPropertyValue("ParaAdjust") >>= nParaAdjust; CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust)); - uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y,xShape1->getPosition().Y); CPPUNIT_ASSERT_EQUAL(xShape2->getPosition().Y,xShape3->getPosition().Y); CPPUNIT_ASSERT(xShape2->getPosition().Y > xShape0->getPosition().Y); @@ -543,9 +548,9 @@ void SdImportTestSmartArt::testVerticalBoxList() uno::UNO_QUERY_THROW); // Without the accompanying fix in place, this test would have failed with // 'actual: 0'. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xShapeGroup->getCount()); - uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstChild.is()); uno::Reference<drawing::XShape> xParentText(xFirstChild->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xParentText.is()); @@ -554,7 +559,7 @@ void SdImportTestSmartArt::testVerticalBoxList() // constraint wanted. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11852), xParentText->getSize().Width); - uno::Reference<drawing::XShape> xChildText(xShapeGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xChildText(xShapeGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT(xChildText.is()); // Without the accompanying fix in place, this test would have failed with // 'actual: 7361' (and with the fix: 'actual: 16932', i.e. the width of the @@ -577,9 +582,9 @@ void SdImportTestSmartArt::testVerticalBracketList() m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/vertical-bracket-list.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xShapeGroup->getCount()); - uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstChild.is()); // Without the accompanying fix in place, this test would have failed with // 'actual: 2', i.e. one child shape (with its "A" text) was missing. @@ -594,16 +599,16 @@ void SdImportTestSmartArt::testTableList() m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/table-list.pptx"), PPTX); uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xShapeGroup.is()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xShapeGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xShapeGroup->getCount()); - uno::Reference<text::XText> xParentText(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XText> xParentText(xShapeGroup->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xParentText.is()); CPPUNIT_ASSERT_EQUAL(OUString("Parent"), xParentText->getString()); uno::Reference<drawing::XShape> xParent(xParentText, uno::UNO_QUERY); CPPUNIT_ASSERT(xParent.is()); int nParentRight = xParent->getPosition().X + xParent->getSize().Width; - uno::Reference<drawing::XShapes> xChildren(xShapeGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xChildren(xShapeGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT(xChildren.is()); uno::Reference<text::XText> xChild2Text(xChildren->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xChild2Text.is()); @@ -627,13 +632,13 @@ void SdImportTestSmartArt::testAccentProcess() uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xGroup.is()); // 3 children: first pair, connector, second pair. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup->getCount()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xGroup->getCount()); uno::Reference<drawing::XShape> xGroupShape(xGroup, uno::UNO_QUERY); CPPUNIT_ASSERT(xGroupShape.is()); // The pair is a parent (shape + text) and a child, so 3 shapes in total. // The order is important, first is at the back, last is at the front. - uno::Reference<drawing::XShapes> xFirstPair(xGroup->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xFirstPair(xGroup->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstPair.is()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xFirstPair->getCount()); @@ -676,7 +681,7 @@ void SdImportTestSmartArt::testAccentProcess() CPPUNIT_ASSERT_LESS(nFirstChildTop, nFirstParentTop); // Make sure that we have an arrow shape between the two pairs. - uno::Reference<beans::XPropertySet> xArrow(xGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xArrow(xGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT(xArrow.is()); comphelper::SequenceAsHashMap aCustomShapeGeometry( xArrow->getPropertyValue("CustomShapeGeometry")); @@ -692,7 +697,7 @@ void SdImportTestSmartArt::testAccentProcess() awt::Size aArrowSize = xArrowShape->getSize(); CPPUNIT_ASSERT_LESS(aArrowSize.Width, aArrowSize.Height); - uno::Reference<drawing::XShapes> xSecondPair(xGroup->getByIndex(2), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xSecondPair(xGroup->getByIndex(3), uno::UNO_QUERY); CPPUNIT_ASSERT(xSecondPair.is()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xSecondPair->getCount()); uno::Reference<text::XText> xSecondParentText(xSecondPair->getByIndex(1), uno::UNO_QUERY); @@ -718,10 +723,10 @@ void SdImportTestSmartArt::testContinuousBlockProcess() PPTX); uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xGroup.is()); - // 2 children: background, foreground. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup->getCount()); + // 3 children: diagram background, background arrow, foreground. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup->getCount()); - uno::Reference<drawing::XShapes> xLinear(xGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xLinear(xGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT(xLinear.is()); // 3 children: A, B and C. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xLinear->getCount()); @@ -750,7 +755,7 @@ void SdImportTestSmartArt::testOrgChart() CPPUNIT_ASSERT(xGroup.is()); uno::Reference<text::XText> xManager( - getChildShape(getChildShape(getChildShape(xGroup, 0), 0), 0), uno::UNO_QUERY); + getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xManager.is()); // Without the accompanying fix in place, this test would have failed: this // was just "Manager", and the second paragraph was lost. @@ -775,7 +780,7 @@ void SdImportTestSmartArt::testOrgChart() awt::Size aManagerSize = xManagerShape->getSize(); // Make sure that the manager has 2 employees. - uno::Reference<drawing::XShapes> xEmployees(getChildShape(getChildShape(xGroup, 0), 2), + uno::Reference<drawing::XShapes> xEmployees(getChildShape(getChildShape(xGroup, 1), 2), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployees.is()); // 4 children: connector, 1st employee, connector, 2nd employee. @@ -783,7 +788,7 @@ void SdImportTestSmartArt::testOrgChart() uno::Reference<text::XText> xEmployee( getChildShape( - getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1), 0), 0), + getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 1), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployee.is()); CPPUNIT_ASSERT_EQUAL(OUString("Employee"), xEmployee->getString()); @@ -805,7 +810,7 @@ void SdImportTestSmartArt::testOrgChart() // the second employee was below the first one. uno::Reference<text::XText> xEmployee2( getChildShape( - getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 3), 0), 0), + getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 3), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployee2.is()); CPPUNIT_ASSERT_EQUAL(OUString("Employee2"), xEmployee2->getString()); @@ -820,7 +825,7 @@ void SdImportTestSmartArt::testOrgChart() // Make sure that assistant is above employees. uno::Reference<text::XText> xAssistant( getChildShape( - getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 1), 1), 0), 0), + getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 1), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Assistant"), xAssistant->getString()); @@ -834,7 +839,7 @@ void SdImportTestSmartArt::testOrgChart() // Make sure the connector of the assistant is above the shape. uno::Reference<drawing::XShape> xAssistantConnector( - getChildShape(getChildShape(getChildShape(xGroup, 0), 1), 0), uno::UNO_QUERY); + getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xAssistantConnector.is()); awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition(); // This failed, the vertical positions of the connector and the shape of @@ -843,7 +848,7 @@ void SdImportTestSmartArt::testOrgChart() // Make sure the height of xManager and xManager2 is the same. uno::Reference<text::XText> xManager2( - getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 0), uno::UNO_QUERY); + getChildShape(getChildShape(getChildShape(xGroup, 2), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xManager2.is()); CPPUNIT_ASSERT_EQUAL(OUString("Manager2"), xManager2->getString()); @@ -875,14 +880,14 @@ void SdImportTestSmartArt::testCycleMatrix() // Without the accompanying fix in place, this test would have failed: the height was 12162, // which is not the mm100 equivalent of the 4064000 EMU in the input file. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11287), xGroup->getSize().Height); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11288), xGroup->getSize().Height); - uno::Reference<text::XText> xA1(getChildShape(getChildShape(xGroup, 1), 0), uno::UNO_QUERY); + uno::Reference<text::XText> xA1(getChildShape(getChildShape(xGroup, 2), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xA1.is()); CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1->getString()); // Test fill color of B1, should be orange. - uno::Reference<text::XText> xB1(getChildShape(getChildShape(xGroup, 1), 1), uno::UNO_QUERY); + uno::Reference<text::XText> xB1(getChildShape(getChildShape(xGroup, 2), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xB1.is()); CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1->getString()); @@ -896,7 +901,7 @@ void SdImportTestSmartArt::testCycleMatrix() // Without the accompanying fix in place, this test would have failed: the // content of the "A2" shape was lost. - uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 0), 0), 1), + uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xA2.is()); CPPUNIT_ASSERT_EQUAL(OUString("A2"), xA2->getString()); @@ -908,7 +913,7 @@ void SdImportTestSmartArt::testCycleMatrix() uno::Reference<drawing::XShape> xA2Shape(xA2, uno::UNO_QUERY); CPPUNIT_ASSERT(xA2Shape.is()); - uno::Reference<text::XText> xB2(getChildShape(getChildShape(getChildShape(xGroup, 0), 1), 1), + uno::Reference<text::XText> xB2(getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xB2.is()); CPPUNIT_ASSERT_EQUAL(OUString("B2"), xB2->getString()); @@ -922,7 +927,7 @@ void SdImportTestSmartArt::testCycleMatrix() xB2Props->getPropertyValue("LineColor") >>= nLineColor; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nLineColor); - uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1), + uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xC2.is()); // Without the accompanying fix in place, this test would have failed, i.e. the order of the @@ -931,7 +936,7 @@ void SdImportTestSmartArt::testCycleMatrix() uno::Reference<drawing::XShape> xC2Shape(xC2, uno::UNO_QUERY); CPPUNIT_ASSERT(xC2Shape.is()); - uno::Reference<text::XText> xD2(getChildShape(getChildShape(getChildShape(xGroup, 0), 3), 1), + uno::Reference<text::XText> xD2(getChildShape(getChildShape(getChildShape(xGroup, 1), 3), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xD2.is()); CPPUNIT_ASSERT_EQUAL(OUString("D2"), xD2->getString()); @@ -964,7 +969,7 @@ void SdImportTestSmartArt::testPictureStrip() uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); CPPUNIT_ASSERT(xGroup.is()); - uno::Reference<beans::XPropertySet> xFirstImage(getChildShape(getChildShape(xGroup, 0), 1), + uno::Reference<beans::XPropertySet> xFirstImage(getChildShape(getChildShape(xGroup, 1), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstImage.is()); drawing::FillStyle eFillStyle = drawing::FillStyle_NONE; @@ -977,7 +982,7 @@ void SdImportTestSmartArt::testPictureStrip() xFirstImage->getPropertyValue("FillBitmap") >>= xGraphic; Graphic aFirstGraphic(xGraphic); - uno::Reference<beans::XPropertySet> xSecondImage(getChildShape(getChildShape(xGroup, 1), 1), + uno::Reference<beans::XPropertySet> xSecondImage(getChildShape(getChildShape(xGroup, 2), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xSecondImage.is()); eFillStyle = drawing::FillStyle_NONE; @@ -995,7 +1000,7 @@ void SdImportTestSmartArt::testPictureStrip() CPPUNIT_ASSERT(xFirstImage.is()); uno::Reference<drawing::XShape> xSecondImageShape(xSecondImage, uno::UNO_QUERY); CPPUNIT_ASSERT(xSecondImage.is()); - uno::Reference<drawing::XShape> xThirdImageShape(getChildShape(getChildShape(xGroup, 2), 1), + uno::Reference<drawing::XShape> xThirdImageShape(getChildShape(getChildShape(xGroup, 3), 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xThirdImageShape.is()); // Without the accompanying fix in place, this test would have failed: the first and the second @@ -1012,11 +1017,12 @@ void SdImportTestSmartArt::testPictureStrip() CPPUNIT_ASSERT(xTitle.is()); // Without the accompanying fix in place, this test would have failed with 'Expected greater // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped. + uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 1); CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height, - xGroup->getPosition().Y); + xFirstPair->getPosition().Y); // Make sure that left margin is 60% of width (if you count width in points and margin in mms). - uno::Reference<beans::XPropertySet> xFirstText(getChildShape(getChildShape(xGroup, 0), 0), + uno::Reference<beans::XPropertySet> xFirstText(getChildShape(getChildShape(xGroup, 1), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstText.is()); sal_Int32 nTextLeftDistance = 0; @@ -1030,7 +1036,6 @@ void SdImportTestSmartArt::testPictureStrip() CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nWidth * fFactor), nTextLeftDistance); // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times. - uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 0); awt::Size aFirstPairSize = xFirstPair->getSize(); // Without the accompanying fix in place, this test would have failed: bad width was 16932, good // width is 12540, but let's accept 12541 as well. @@ -1059,6 +1064,78 @@ void SdImportTestSmartArt::testInteropGrabBag() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testBackground() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-background.pptx"), PPTX); + uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xGroup.is()); + + // background should fill whole diagram + uno::Reference<drawing::XShape> xShapeGroup(xGroup, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(xShape->getPosition().X, xShapeGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(xShape->getPosition().Y, xShapeGroup->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(xShape->getSize().Width, xShapeGroup->getSize().Width); + CPPUNIT_ASSERT_EQUAL(xShape->getSize().Height, xShapeGroup->getSize().Height); + + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW); + drawing::FillStyle eFillStyle = drawing::FillStyle_NONE; + xPropertySet->getPropertyValue("FillStyle") >>= eFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, eFillStyle); + + sal_Int32 nFillColor = 0; + xPropertySet->getPropertyValue("FillColor") >>= nFillColor; + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x339933), nFillColor); + + bool bMoveProtect = false; + xPropertySet->getPropertyValue("MoveProtect") >>= bMoveProtect; + CPPUNIT_ASSERT_EQUAL(true, bMoveProtect); + + bool bSizeProtect = false; + xPropertySet->getPropertyValue("SizeProtect") >>= bSizeProtect; + CPPUNIT_ASSERT_EQUAL(true, bSizeProtect); + + xDocShRef->DoClose(); +} + +void SdImportTestSmartArt::testBackgroundDrawingmlFallback() +{ + // same as testBackground, but test file contains drawingML fallback + + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx"), PPTX); + uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xGroup.is()); + + // background should fill whole diagram + uno::Reference<drawing::XShape> xShapeGroup(xGroup, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(xShape->getPosition().X, xShapeGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(xShape->getPosition().Y, xShapeGroup->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(xShape->getSize().Width, xShapeGroup->getSize().Width); + CPPUNIT_ASSERT_EQUAL(xShape->getSize().Height, xShapeGroup->getSize().Height); + + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW); + drawing::FillStyle eFillStyle = drawing::FillStyle_NONE; + xPropertySet->getPropertyValue("FillStyle") >>= eFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, eFillStyle); + + sal_Int32 nFillColor = 0; + xPropertySet->getPropertyValue("FillColor") >>= nFillColor; + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x339933), nFillColor); + + bool bMoveProtect = false; + xPropertySet->getPropertyValue("MoveProtect") >>= bMoveProtect; + CPPUNIT_ASSERT_EQUAL(true, bMoveProtect); + + bool bSizeProtect = false; + xPropertySet->getPropertyValue("SizeProtect") >>= bSizeProtect; + CPPUNIT_ASSERT_EQUAL(true, bSizeProtect); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 5423296ec30e..7dc82aebf94c 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -459,7 +459,7 @@ void SdImportTest::testN862510_2() CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount()); SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) ); CPPUNIT_ASSERT( pGrpObj ); - SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) ); + SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 1 ) ); CPPUNIT_ASSERT( pObj ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong Text Rotation!", 90.0, pObj->GetExtraTextRotation( true ) ); } @@ -837,7 +837,8 @@ void SdImportTest::testBnc870237() const SdrPage *pPage = GetPage( 1, xDocShRef ); // Simulate a:ext inside dsp:txXfrm with changing the lower distance - const SdrObjGroup* pObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) ); + const SdrObjGroup* pGroupObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) ); + const SdrObject* pObj = pGroupObj->GetSubList()->GetObj( 1 ); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue()); CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue()); @@ -1285,7 +1286,7 @@ void SdImportTest::testTdf93830() // Get the first text box from group shape uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(0), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xPropSet( xShape->getByIndex(2), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPropSet( xShape->getByIndex(3), uno::UNO_QUERY ); CPPUNIT_ASSERT_MESSAGE( "no textbox shape", xPropSet.is() ); sal_Int32 nTextLeftDistance = 0; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index ebf9577cb499..3b1250f11fd9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -109,14 +109,14 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xGroup->getCount()); // background, 3 rectangles and an arrow in the group - uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(2), uno::UNO_QUERY); sal_Int32 nValue(0); xPropertySet->getPropertyValue("FillColor") >>= nValue; CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK - uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY); @@ -479,7 +479,7 @@ DECLARE_OOXMLEXPORT_TEST(testSmartartStrict, "strict-smartart.docx") { uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); // This was 0, SmartArt was visually missing. - CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xGroup->getCount()); // 3 ellipses + 3 arrows + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xGroup->getCount()); // background, 3 ellipses + 3 arrows } DECLARE_OOXMLEXPORT_TEST(testLibreOfficeHang, "frame-wrap-auto.docx") diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 53deec97aae0..f40264586eae 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1041,11 +1041,11 @@ DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx") // StarView MetaFile. uno::Reference<container::XIndexAccess> group(getShape(1), uno::UNO_QUERY); { - uno::Reference<text::XTextRange> text(group->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> text(group->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("text2"), text->getString()); } { - uno::Reference<beans::XPropertySet> props(group->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> props(group->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(props->getPropertyValue("RotateAngle"), uno::makeAny<sal_Int32>(270 * 100)); comphelper::SequenceAsHashMap geom(props->getPropertyValue("CustomShapeGeometry")); |