diff options
-rw-r--r-- | include/oox/export/shapes.hxx | 4 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 46 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf119223.odp | bin | 0 -> 18335 bytes | |||
-rw-r--r-- | sd/qa/unit/data/xml/tdf90338_0.xml | 2 | ||||
-rw-r--r-- | sd/qa/unit/data/xml/tdf92001_0.xml | 2 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 36 |
6 files changed, 66 insertions, 24 deletions
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index 2dbbb658c036..53d505f168a2 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -87,10 +87,12 @@ public: typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap; protected: - sal_Int32 mnShapeIdMax, mnPictureIdMax; + sal_Int32 mnShapeIdMax; void WriteGraphicObjectShapePart( const css::uno::Reference< css::drawing::XShape >& xShape, const Graphic *pGraphic=nullptr ); + OUString GetShapeName(const css::uno::Reference< css::drawing::XShape >& xShape); + private: sal_Int32 mnXmlNamespace; MapMode maMapModeSrc, maMapModeDest; diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 9a6a72b08b0f..3ea0ae57ba6b 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -91,7 +91,6 @@ using ::css::frame::XModel; using ::oox::core::XmlFilterBase; using ::sax_fastparser::FSHelperPtr; -#define IDS(x) OString(#x " " + OString::number(mnShapeIdMax++)).getStr() namespace oox { @@ -325,7 +324,6 @@ ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap : DrawingML( std::move(pFS), pFB, eDocumentType, pTextExport ) , m_nEmbeddedObjects(0) , mnShapeIdMax( 1 ) - , mnPictureIdMax( 1 ) , mnXmlNamespace( nXmlNamespace ) , maMapModeSrc( MapUnit::Map100thMM ) , maMapModeDest( MapUnit::MapInch, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) ) @@ -416,7 +414,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Freeform ) ); + XML_name, GetShapeName(xShape).toUtf8()); } pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr); if (GetDocumentType() != DOCUMENT_DOCX) @@ -477,7 +475,7 @@ ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>& pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr); pFS->singleElementNS(mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS(Group)); + XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr); WriteNonVisualProperties(xShape ); pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr); @@ -803,7 +801,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) pFS->startElementNS( mnXmlNamespace, XML_nvSpPr ); pFS->startElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( CustomShape ), + XML_name, GetShapeName(xShape).toUtf8(), XML_hidden, isVisible ? nullptr : "1" ); if( GETA( URL ) ) @@ -1051,7 +1049,7 @@ ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape ) pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Ellipse ) ); + XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr ); WriteNonVisualProperties( xShape ); pFS->endElementNS( mnXmlNamespace, XML_nvSpPr ); @@ -1185,11 +1183,9 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape pFS->startElementNS(mnXmlNamespace, XML_nvPicPr); - OUString sName, sDescr, sURL; - bool bHaveName, bHaveDesc; + OUString sDescr, sURL; + bool bHaveDesc; - if ( ( bHaveName= GetProperty( xShapeProps, "Name" ) ) ) - mAny >>= sName; if ( ( bHaveDesc = GetProperty( xShapeProps, "Description" ) ) ) mAny >>= sDescr; if ( GetProperty( xShapeProps, "URL" ) ) @@ -1197,9 +1193,7 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape pFS->startElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, bHaveName - ? sName.toUtf8() - : OString("Picture " + OString::number(mnPictureIdMax++)), + XML_name, GetShapeName(xShape).toUtf8(), XML_descr, bHaveDesc ? sDescr.toUtf8().getStr() : nullptr ); // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkHover @@ -1343,7 +1337,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Line ) ); + XML_name, GetShapeName(xShape).toUtf8()); // non visual connector shape drawing properties pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr); WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) ); @@ -1395,7 +1389,7 @@ ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape ) pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Line ) ); + XML_name, GetShapeName(xShape).toUtf8()); } pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr ); if (GetDocumentType() != DOCUMENT_DOCX) @@ -1470,7 +1464,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( const Reference< XShape >& xShape pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Rectangle ) ); + XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr); WriteNonVisualProperties( xShape ); pFS->endElementNS( mnXmlNamespace, XML_nvSpPr ); @@ -1847,7 +1841,7 @@ ShapeExport& ShapeExport::WriteTableShape( const Reference< XShape >& xShape ) pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS(Table) ); + XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr); @@ -1876,7 +1870,7 @@ ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape ) pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->startElementNS(mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS(TextShape)); + XML_name, GetShapeName(xShape).toUtf8()); OUString sURL; if (GetProperty(xShapeProps, "URL")) mAny >>= sURL; @@ -1939,7 +1933,7 @@ void ShapeExport::WriteMathShape(Reference<XShape> const& xShape) mpFS->startElementNS(mnXmlNamespace, XML_nvSpPr); mpFS->singleElementNS(mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS(Formula)); + XML_name, GetShapeName(xShape).toUtf8()); mpFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1"); mpFS->singleElementNS(mnXmlNamespace, XML_nvPr); mpFS->endElementNS(mnXmlNamespace, XML_nvSpPr); @@ -2112,7 +2106,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape ) mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS(Object) ); + XML_name, GetShapeName(xShape).toUtf8()); mpFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr); @@ -2205,6 +2199,18 @@ sal_Int32 ShapeExport::GetShapeID( const Reference< XShape >& rXShape, ShapeHash return aIter->second; } +OUString ShapeExport::GetShapeName(const Reference<XShape>& xShape) +{ + Reference<XPropertySet> rXPropSet(xShape, UNO_QUERY); + + // Empty name keeps the object unnamed. + OUString sName; + + if (GetProperty(rXPropSet, "Name")) + mAny >>= sName; + return sName; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/data/odp/tdf119223.odp b/sd/qa/unit/data/odp/tdf119223.odp Binary files differnew file mode 100644 index 000000000000..efb4306b9c04 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf119223.odp diff --git a/sd/qa/unit/data/xml/tdf90338_0.xml b/sd/qa/unit/data/xml/tdf90338_0.xml index a357211c6a0a..2f779413596b 100644 --- a/sd/qa/unit/data/xml/tdf90338_0.xml +++ b/sd/qa/unit/data/xml/tdf90338_0.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <XShapes> - <XShape positionX="5498" positionY="2715" sizeX="11630" sizeY="8623" type="com.sun.star.drawing.CustomShape" name="CustomShape 1" 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="SOLID" fillColor="e7e6e6" fillTransparence="0" fillTransparenceGradientName=""> + <XShape positionX="5498" positionY="2715" sizeX="11630" sizeY="8623" type="com.sun.star.drawing.CustomShape" name="Freeform 3" 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="SOLID" fillColor="e7e6e6" fillTransparence="0" fillTransparenceGradientName=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="000000" 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"/> diff --git a/sd/qa/unit/data/xml/tdf92001_0.xml b/sd/qa/unit/data/xml/tdf92001_0.xml index 3bfe7f391c88..40e64cdc1cea 100644 --- a/sd/qa/unit/data/xml/tdf92001_0.xml +++ b/sd/qa/unit/data/xml/tdf92001_0.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <XShapes> - <XShape positionX="4826" positionY="4826" sizeX="19557" sizeY="12953" type="com.sun.star.drawing.CustomShape" name="CustomShape 1" 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="SOLID" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName=""> + <XShape positionX="4826" positionY="4826" sizeX="19557" sizeY="12953" 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="SOLID" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="000000" 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"/> diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 498443d12236..a46edd8c72f3 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -198,6 +198,7 @@ public: void testTdf132201EffectOrder(); void testShapeSoftEdgeEffect(); void testShapeShadowBlurEffect(); + void testTdf119223(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -313,6 +314,7 @@ public: CPPUNIT_TEST(testTdf132201EffectOrder); CPPUNIT_TEST(testShapeSoftEdgeEffect); CPPUNIT_TEST(testShapeShadowBlurEffect); + CPPUNIT_TEST(testTdf119223); CPPUNIT_TEST_SUITE_END(); @@ -1579,7 +1581,7 @@ void SdOOXMLExportTest2::testTdf114845_rotateShape() xDocShRef->DoClose(); xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:nvSpPr/p:cNvPr", "name", "CustomShape 5"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:nvSpPr/p:cNvPr", "name", "Straight Arrow Connector 9"); assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm", "flipV", "1"); double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "x").toDouble(); double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "y").toDouble(); @@ -2927,6 +2929,38 @@ void SdOOXMLExportTest2::testShapeShadowBlurEffect() CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius); // 11 pt } +void SdOOXMLExportTest2::testTdf119223() +{ + auto xDocShRef + = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf119223.odp"), ODP); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeCustomShape']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomePicture']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeFormula']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeLine']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeTextbox']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeTable']"); + + assertXPath(pXmlDocRels, + "//p:cNvPr[@name='SomeGroup']"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |