From cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Thu, 10 Mar 2022 08:42:12 +0100 Subject: tdf#89449 PPTX import: fix line connectors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Line connectors were imported as plain shapes, losing their functionality during editing, i.e. keeping connections of boxes and other shapes. Change-Id: I0f1562be2dbcce0e45eb209c6ca4e035731039e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131303 Tested-by: László Németh Reviewed-by: László Németh --- include/oox/drawingml/connectorshapecontext.hxx | 15 +- include/oox/drawingml/shape.hxx | 11 + include/oox/ppt/slidepersist.hxx | 4 + oox/inc/drawingml/customshapeproperties.hxx | 1 - .../drawingml/chart/chartdrawingfragment.cxx | 3 +- oox/source/drawingml/connectorshapecontext.cxx | 84 +++++- oox/source/drawingml/customshapeproperties.cxx | 36 +-- oox/source/drawingml/shape.cxx | 37 ++- oox/source/drawingml/shapegroupcontext.cxx | 3 +- oox/source/drawingml/shapepropertiescontext.cxx | 8 +- oox/source/export/shapes.cxx | 3 +- oox/source/ppt/pptshapegroupcontext.cxx | 6 +- oox/source/ppt/slidepersist.cxx | 70 +++++ oox/source/shape/LockedCanvasContext.cxx | 7 +- sc/source/filter/oox/drawingfragment.cxx | 3 +- sd/qa/unit/data/pptx/tdf89449.pptx | Bin 0 -> 14939 bytes sd/qa/unit/data/xml/fdo47434_0.xml | 188 +------------ sd/qa/unit/data/xml/tdf100491_0.xml | 304 ++------------------- sd/qa/unit/export-tests-ooxml2.cxx | 8 +- sd/qa/unit/import-tests.cxx | 39 +++ 20 files changed, 288 insertions(+), 542 deletions(-) create mode 100644 sd/qa/unit/data/pptx/tdf89449.pptx diff --git a/include/oox/drawingml/connectorshapecontext.hxx b/include/oox/drawingml/connectorshapecontext.hxx index 1efdd2e40611..c9819ae85137 100644 --- a/include/oox/drawingml/connectorshapecontext.hxx +++ b/include/oox/drawingml/connectorshapecontext.hxx @@ -25,16 +25,29 @@ #include #include #include +#include namespace oox { class AttributeList; } namespace oox::core { class ContextHandler2Helper; } namespace oox::drawingml { + struct ConnectorShapeProperties + { + bool mbStartShape; + OUString maDestShapeId; + sal_Int32 mnDestGlueId; + }; + class OOX_DLLPUBLIC ConnectorShapeContext final : public ShapeContext { + std::vector& mrConnectorShapePropertiesList; + ShapePtr mpConnectorShapePtr; + public: - ConnectorShapeContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pMasterShapePtr, const ShapePtr& pGroupShapePtr ); + ConnectorShapeContext(::oox::core::ContextHandler2Helper const& rParent, + const ShapePtr& pMasterShapePtr, const ShapePtr& pGroupShapePtr, + std::vector& rConnectorShapePropertiesList); virtual ~ConnectorShapeContext() override; virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override; }; diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index 734e805ccac5..a16e65a71ef1 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -73,6 +74,8 @@ typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; typedef ::std::map< OUString, ShapePtr > ShapeIdMap; +typedef std::vector ConnectorShapePropertiesList; + struct ShapeStyleRef { Color maPhClr; @@ -128,6 +131,10 @@ public: CustomShapePropertiesPtr& getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; } + ConnectorShapePropertiesList& getConnectorShapeProperties() { return maConnectorShapePropertiesList; } + void setConnectorShape(bool bConnector) { mbConnector = bConnector; } + bool isConnectorShape() const { return mbConnector; } + Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; } const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; } @@ -332,6 +339,7 @@ protected: PropertyMap maDefaultShapeProperties; TextListStylePtr mpMasterTextListStyle; css::uno::Reference< css::drawing::XShape > mxShape; + ConnectorShapePropertiesList maConnectorShapePropertiesList; OUString msServiceName; OUString msName; @@ -394,6 +402,9 @@ private: /// The shape fill should be set to that of the slide background surface. bool mbUseBgFill = false; + // Is this a connector shape? + bool mbConnector = false; + // temporary space for DiagramHelper in preparation for collecting data // Note: I tried to use a unique_ptr here, but existing constructor func does not allow that IDiagramHelper* mpDiagramHelper; diff --git a/include/oox/ppt/slidepersist.hxx b/include/oox/ppt/slidepersist.hxx index c09e5f0b0da0..1b0a92c70783 100644 --- a/include/oox/ppt/slidepersist.hxx +++ b/include/oox/ppt/slidepersist.hxx @@ -125,6 +125,8 @@ public: CommentList& getCommentsList() { return maCommentsList; } CommentAuthorList& getCommentAuthors() { return maCommentAuthors; } + void createConnectorShapeConnection(); + private: OUString maPath; OUString maLayoutPath; @@ -156,6 +158,8 @@ private: // slide comments CommentList maCommentsList; CommentAuthorList maCommentAuthors; + + std::vector maConnectorShapeId; }; } diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx index 779003412fbb..ea9b9e9d53af 100644 --- a/oox/inc/drawingml/customshapeproperties.hxx +++ b/oox/inc/drawingml/customshapeproperties.hxx @@ -98,7 +98,6 @@ public: CustomShapeProperties(); void pushToPropSet( const css::uno::Reference < css::beans::XPropertySet > & xPropSet, - const css::uno::Reference < css::drawing::XShape > & xShape, const css::awt::Size &aSize ); sal_Int32 getShapePresetType() const { return mnShapePresetType; } diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index c41e2db49821..9509ad4ea01e 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -157,7 +157,8 @@ ContextHandlerRef ChartDrawingFragment::onCreateContext( sal_Int32 nElement, con return new ShapeContext( *this, ShapePtr(), mxShape ); case CDR_TOKEN( cxnSp ): mxShape = std::make_shared( "com.sun.star.drawing.ConnectorShape" ); - return new ConnectorShapeContext( *this, ShapePtr(), mxShape ); + return new ConnectorShapeContext(*this, ShapePtr(), mxShape, + mxShape->getConnectorShapeProperties()); case CDR_TOKEN( pic ): mxShape = std::make_shared( "com.sun.star.drawing.GraphicObjectShape" ); return new GraphicShapeContext( *this, ShapePtr(), mxShape ); diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx index e815d56994d9..b1ea90c357af 100644 --- a/oox/source/drawingml/connectorshapecontext.cxx +++ b/oox/source/drawingml/connectorshapecontext.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -35,30 +36,93 @@ using namespace ::com::sun::star::xml::sax; namespace oox::drawingml { -ConnectorShapeContext::ConnectorShapeContext( ContextHandler2Helper const & rParent, - const ShapePtr& pMasterShapePtr, const ShapePtr& pGroupShapePtr ) -: ShapeContext( rParent, pMasterShapePtr, pGroupShapePtr ) +namespace { +class ConnectorShapePropertiesContext : public ::oox::core::ContextHandler2 +{ + std::vector& mrConnectorShapePropertiesList; + ShapePtr mpConnectorShapePtr; + +public: + ConnectorShapePropertiesContext( + ::oox::core::ContextHandler2Helper const& rParent, ShapePtr& pShapePtr, + std::vector& rConnectorShapePropertiesList); + + virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, + const AttributeList& rAttribs) override; +}; } -ConnectorShapeContext::~ConnectorShapeContext() +ConnectorShapePropertiesContext::ConnectorShapePropertiesContext( + ContextHandler2Helper const& rParent, ShapePtr& pShapePtr, + std::vector& rConnectorShapePropertiesList) + : ContextHandler2(rParent) + , mrConnectorShapePropertiesList(rConnectorShapePropertiesList) + , mpConnectorShapePtr(pShapePtr) { + mpConnectorShapePtr->setConnectorShape(true); } -ContextHandlerRef ConnectorShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +::oox::core::ContextHandlerRef +ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken, + const AttributeList& rAttribs) { - switch( getBaseToken( aElementToken ) ) + switch (getBaseToken(aElementToken)) { - case XML_nvCxnSpPr : - break; - + case XML_cNvPr: + mpConnectorShapePtr->setId(rAttribs.getString(XML_id).get()); + mpConnectorShapePtr->setName(rAttribs.getString(XML_name).get()); + break; + case XML_stCxn: + { + ConnectorShapeProperties aConnectorShapeProps; + aConnectorShapeProps.mbStartShape = true; + aConnectorShapeProps.maDestShapeId = rAttribs.getString(XML_id).get(); + aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx).get(); + mrConnectorShapePropertiesList.push_back(aConnectorShapeProps); + break; + } + case XML_endCxn: + { + ConnectorShapeProperties aConnectorShapeProps; + aConnectorShapeProps.mbStartShape = false; + aConnectorShapeProps.maDestShapeId = rAttribs.getString(XML_id).get(); + aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx).get(); + mrConnectorShapePropertiesList.push_back(aConnectorShapeProps); + break; + } default: - return ShapeContext::onCreateContext( aElementToken, rAttribs ); + break; } return this; } +ConnectorShapeContext::ConnectorShapeContext( + ContextHandler2Helper const& rParent, const ShapePtr& pMasterShapePtr, + const ShapePtr& pGroupShapePtr, + std::vector& rConnectorShapePropertiesList) + : ShapeContext(rParent, pMasterShapePtr, pGroupShapePtr) + , mrConnectorShapePropertiesList(rConnectorShapePropertiesList) + , mpConnectorShapePtr(pGroupShapePtr) +{ +} + +ConnectorShapeContext::~ConnectorShapeContext() {} + +ContextHandlerRef ConnectorShapeContext::onCreateContext(sal_Int32 aElementToken, + const AttributeList& rAttribs) +{ + switch (getBaseToken(aElementToken)) + { + case XML_nvCxnSpPr: + return new ConnectorShapePropertiesContext(*this, mpConnectorShapePtr, + mrConnectorShapePropertiesList); + } + + return ShapeContext::onCreateContext(aElementToken, rAttribs); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index efe7c0ad03af..b748deb48702 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -97,25 +97,8 @@ bool CustomShapeProperties::representsDefaultShape() const CustomShapeProperties::PresetDataMap CustomShapeProperties::maPresetDataMap; -static OUString GetConnectorShapeType( sal_Int32 nType ) -{ - SAL_INFO( - "oox.drawingml", "preset: " << nType << " " << XML_straightConnector1); - - OUString sType; - switch( nType ) - { - case XML_straightConnector1: - sType = "mso-spt32"; - break; - default: - break; - } - return sType; -} - void CustomShapeProperties::pushToPropSet( - const Reference < XPropertySet >& xPropSet, const Reference < XShape > & xShape, const awt::Size &aSize ) + const Reference < XPropertySet >& xPropSet, const awt::Size &aSize ) { if ( mnShapePresetType >= 0 ) { @@ -127,22 +110,7 @@ void CustomShapeProperties::pushToPropSet( PropertyMap aPropertyMap; PropertySet aPropSet( xPropSet ); - OUString sConnectorShapeType = GetConnectorShapeType( mnShapePresetType ); - - if (sConnectorShapeType.getLength() > 0) - { - SAL_INFO( - "oox.drawingml", - "connector shape: " << sConnectorShapeType << " (" - << mnShapePresetType << ")"); - //const uno::Reference < drawing::XShape > xShape( xPropSet, UNO_QUERY ); - Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( xShape, UNO_QUERY ); - if( xDefaulter.is() ) { - xDefaulter->createCustomShapeDefaults( sConnectorShapeType ); - aPropertyMap.setProperty( PROP_Type, sConnectorShapeType ); - } - } - else if (maPresetDataMap.find(mnShapePresetType) != maPresetDataMap.end()) + if (maPresetDataMap.find(mnShapePresetType) != maPresetDataMap.end()) { SAL_INFO( "oox.drawingml", diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index cc988699292e..2ef801c5ee08 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -867,10 +868,8 @@ Reference< XShape > const & Shape::createAndInsert( bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && !mpCustomShapePropertiesPtr->representsDefaultShape()); - // ToDo: Why is ConnectorShape here treated as custom shape, but below with start and end point? - bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || - aServiceName == "com.sun.star.drawing.ConnectorShape" || - bIsCroppedGraphic); + bool bIsCustomShape = (aServiceName == "com.sun.star.drawing.CustomShape" || bIsCroppedGraphic); + bool bIsConnectorShape = (aServiceName == "com.sun.star.drawing.ConnectorShape"); if(bIsCroppedGraphic) { aServiceName = "com.sun.star.drawing.CustomShape"; @@ -1653,6 +1652,34 @@ Reference< XShape > const & Shape::createAndInsert( if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape) mxShape->setPosition(maPosition); + if (bIsConnectorShape) + { + ConnectorType aConnectorType; + sal_Int32 nType = mpCustomShapePropertiesPtr->getShapePresetType(); + switch (nType) + { + case XML_line: + case XML_straightConnector1: + aConnectorType = ConnectorType_LINE; + break; + case XML_bentConnector2: + case XML_bentConnector3: + case XML_bentConnector4: + case XML_bentConnector5: + aConnectorType = ConnectorType_STANDARD; + break; + case XML_curvedConnector2: + case XML_curvedConnector3: + case XML_curvedConnector4: + case XML_curvedConnector5: + aConnectorType = ConnectorType_CURVE; + break; + default: + break; + } + xSet->setPropertyValue("EdgeKind", Any(aConnectorType)); + } + if( bIsCustomShape ) { if ( mbFlipH ) @@ -1701,7 +1728,7 @@ Reference< XShape > const & Shape::createAndInsert( // for these ==cscode== and ==csdata== markers, so don't "clean up" these SAL_INFOs SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'"); SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'"); - mpCustomShapePropertiesPtr->pushToPropSet( xSet, mxShape, maSize ); + mpCustomShapePropertiesPtr->pushToPropSet(xSet, maSize); if (mpTextBody) { diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx index 61aadb45d862..1a9cb4113871 100644 --- a/oox/source/drawingml/shapegroupcontext.cxx +++ b/oox/source/drawingml/shapegroupcontext.cxx @@ -85,7 +85,8 @@ ContextHandlerRef ShapeGroupContext::onCreateContext( sal_Int32 aElementToken, c { ShapePtr pShape = std::make_shared("com.sun.star.drawing.ConnectorShape"); pShape->setLockedCanvas(mpGroupShapePtr->getLockedCanvas()); - return new ConnectorShapeContext( *this, mpGroupShapePtr, pShape ); + return new ConnectorShapeContext(*this, mpGroupShapePtr, pShape, + pShape->getConnectorShapeProperties()); } case XML_grpSp: // group shape return new ShapeGroupContext( *this, mpGroupShapePtr, std::make_shared( "com.sun.star.drawing.GroupShape" ) ); diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx index e0fc3274c731..935cc4970c7c 100644 --- a/oox/source/drawingml/shapepropertiescontext.cxx +++ b/oox/source/drawingml/shapepropertiescontext.cxx @@ -62,16 +62,10 @@ ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementTok { sal_Int32 nToken = rAttribs.getToken( XML_prst, 0 ); // TODO: Move the following checks to a separate place or as a separate function - if ( nToken == XML_line ) + if (nToken == XML_line && !mrShape.isConnectorShape()) { mrShape.getServiceName() = "com.sun.star.drawing.LineShape"; } - if( ( nToken >= XML_bentConnector2 && nToken <= XML_bentConnector5 ) || - ( nToken >= XML_curvedConnector2 && nToken <= XML_curvedConnector5 ) || - nToken == XML_straightConnector1 ) - { - mrShape.getServiceName() = "com.sun.star.drawing.CustomShape"; - } // We got a preset geometry, forget the geometry inherited from the placeholder shape. mrShape.getCustomShapeProperties() = std::make_shared(); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index ea0e21f457d8..0405c975db0a 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1496,7 +1496,8 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr); WriteConnectorConnections(aConnectorEntry, GetShapeID(rXShapeA), GetShapeID(rXShapeB)); pFS->endElementNS(mnXmlNamespace, XML_cNvCxnSpPr); - pFS->singleElementNS(mnXmlNamespace, XML_nvPr); + if (GetDocumentType() == DOCUMENT_PPTX) + pFS->singleElementNS(mnXmlNamespace, XML_nvPr); pFS->endElementNS(mnXmlNamespace, XML_nvCxnSpPr); } diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 4355f951bc8b..4ca58a383af8 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -90,7 +90,11 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken return new ShapeStyleContext( getParser() ); */ case PPT_TOKEN( cxnSp ): // connector shape - return new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, std::make_shared( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ); + { + auto pShape = std::make_shared(meShapeLocation, "com.sun.star.drawing.ConnectorShape"); + return new oox::drawingml::ConnectorShapeContext(*this, mpGroupShapePtr, pShape, + pShape->getConnectorShapeProperties()); + } case PPT_TOKEN( grpSp ): // group shape return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, std::make_shared( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ); case PPT_TOKEN( sp ): // Shape diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index ae9f0f567a7c..061dda725551 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -41,6 +41,9 @@ #include #include #include +#include +#include +#include using namespace ::com::sun::star; using namespace ::oox::core; @@ -143,12 +146,19 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) PPTShape* pPPTShape = dynamic_cast< PPTShape* >( child.get() ); basegfx::B2DHomMatrix aTransformation; if ( pPPTShape ) + { pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap() ); + if (pPPTShape->isConnectorShape()) + maConnectorShapeId.push_back(pPPTShape->getId()); + } else child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() ); } } + if (!maConnectorShapeId.empty()) + createConnectorShapeConnection(); + Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY); if( !xNodeSupplier.is() ) return; @@ -330,6 +340,66 @@ Reference SlidePersist::getAnimationNode(const OUString& sId) co return aResult; } +// create connection between two shape with a connector shape. +void SlidePersist::createConnectorShapeConnection() +{ + sal_Int32 nConnectorShapeCount = maConnectorShapeId.size(); + for (sal_Int32 i = 0; i < nConnectorShapeCount; i++) + { + const auto& pIt = maShapeMap.find(maConnectorShapeId[i]); + oox::drawingml::ConnectorShapePropertiesList aConnectorShapeProperties + = pIt->second->getConnectorShapeProperties(); + uno::Reference xConnector(pIt->second->getXShape(), uno::UNO_QUERY); + uno::Reference xPropertySet(xConnector, uno::UNO_QUERY); + + if (xConnector.is()) + { + sal_Int32 nCount = aConnectorShapeProperties.size(); + for (sal_Int32 j = 0; j < nCount; j++) + { + OUString aDestShapeId = aConnectorShapeProperties[j].maDestShapeId; + const auto& pShape = maShapeMap.find(aDestShapeId); + uno::Reference xShape(pShape->second->getXShape(), uno::UNO_QUERY); + uno::Reference xSet(xShape, uno::UNO_QUERY); + if (xShape.is()) + { + uno::Reference xSupplier(xShape, uno::UNO_QUERY); + css::uno::Reference xGluePoints( + xSupplier->getGluePoints(), uno::UNO_QUERY); + + sal_Int32 nCountGluePoints = xGluePoints->getIdentifiers().getLength(); + sal_Int32 nGlueId = aConnectorShapeProperties[j].mnDestGlueId; + + // The first 4 glue points belong to the bounding box. + if (nCountGluePoints > 4) + nGlueId += 4; + else + { + // change id of the left and right glue points of the bounding box (1 <-> 3) + if (nGlueId == 1) + nGlueId = 3; // Right + else if (nGlueId == 3) + nGlueId = 1; // Left + } + + bool bStart = aConnectorShapeProperties[j].mbStartShape; + if (bStart) + { + xPropertySet->setPropertyValue("StartShape", uno::Any(xShape)); + xPropertySet->setPropertyValue("StartGluePointIndex", uno::Any(nGlueId)); + } + else + { + xPropertySet->setPropertyValue("EndShape", uno::Any(xShape)); + xPropertySet->setPropertyValue("EndGluePointIndex", uno::Any(nGlueId)); + } + } + } + } + } + maConnectorShapeId.clear(); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/LockedCanvasContext.cxx b/oox/source/shape/LockedCanvasContext.cxx index 5eac3b5ceff7..19267954cf06 100644 --- a/oox/source/shape/LockedCanvasContext.cxx +++ b/oox/source/shape/LockedCanvasContext.cxx @@ -51,9 +51,10 @@ LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const ::oox::Attri } case XML_cxnSp: // CT_GvmlConnector { - return new oox::drawingml::ConnectorShapeContext( - *this, mpShapePtr, - std::make_shared("com.sun.star.drawing.ConnectorShape")); + oox::drawingml::ShapePtr pShape + = std::make_shared("com.sun.star.drawing.ConnectorShape"); + return new oox::drawingml::ConnectorShapeContext(*this, mpShapePtr, pShape, + pShape->getConnectorShapeProperties()); } case XML_pic: // CT_GvmlPicture { diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx index 5ce7b2d21ce5..033720a1bf1e 100644 --- a/sc/source/filter/oox/drawingfragment.cxx +++ b/sc/source/filter/oox/drawingfragment.cxx @@ -139,7 +139,8 @@ GroupShapeContext::GroupShapeContext( const FragmentHandler2& rParent, { ShapePtr xShape = std::make_shared( rHelper, rAttribs, "com.sun.star.drawing.ConnectorShape" ); if( pxShape ) *pxShape = xShape; - return new ConnectorShapeContext( rParent, rxParentShape, xShape ); + return new ConnectorShapeContext(rParent, rxParentShape, xShape, + xShape->getConnectorShapeProperties()); } case XDR_TOKEN( pic ): { diff --git a/sd/qa/unit/data/pptx/tdf89449.pptx b/sd/qa/unit/data/pptx/tdf89449.pptx new file mode 100644 index 000000000000..e55cbf21a927 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf89449.pptx differ diff --git a/sd/qa/unit/data/xml/fdo47434_0.xml b/sd/qa/unit/data/xml/fdo47434_0.xml index 512f422fd198..24dc47005623 100644 --- a/sd/qa/unit/data/xml/fdo47434_0.xml +++ b/sd/qa/unit/data/xml/fdo47434_0.xml @@ -1,10 +1,6 @@ - - - - - + @@ -21,53 +17,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -84,53 +35,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -147,53 +53,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -210,46 +71,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sd/qa/unit/data/xml/tdf100491_0.xml b/sd/qa/unit/data/xml/tdf100491_0.xml index 0c250e6fc840..e45eba130ebf 100644 --- a/sd/qa/unit/data/xml/tdf100491_0.xml +++ b/sd/qa/unit/data/xml/tdf100491_0.xml @@ -1,6 +1,6 @@ - + @@ -17,25 +17,8 @@ - - - - - - - - - - - - - - - - - - + @@ -52,25 +35,8 @@ - - - - - - - - - - - - - - - - - - + @@ -87,25 +53,8 @@ - - - - - - - - - - - - - - - - - - + @@ -122,25 +71,8 @@ - - - - - - - - - - - - - - - - - - + @@ -157,25 +89,8 @@ - - - - - - - - - - - - - - - - - - + @@ -192,25 +107,8 @@ - - - - - - - - - - - - - - - - - - + @@ -227,25 +125,8 @@ - - - - - - - - - - - - - - - - - - + @@ -262,25 +143,8 @@ - - - - - - - - - - - - - - - - - - + @@ -297,25 +161,8 @@ - - - - - - - - - - - - - - - - - - + @@ -332,25 +179,8 @@ - - - - - - - - - - - - - - - - - - + @@ -367,25 +197,8 @@ - - - - - - - - - - - - - - - - - - + @@ -402,25 +215,8 @@ - - - - - - - - - - - - - - - - - - + @@ -437,25 +233,8 @@ - - - - - - - - - - - - - - - - - - + @@ -472,25 +251,8 @@ - - - - - - - - - - - - - - - - - - + @@ -507,25 +269,8 @@ - - - - - - - - - - - - - - - - - - + @@ -542,22 +287,5 @@ - - - - - - - - - - - - - - - - - diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index e99ac6168dd5..6be1222b5c7d 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1540,10 +1540,10 @@ 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", "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(); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:cxnSp[2]/p:nvCxnSpPr/p:cNvPr", "name", "Straight Arrow Connector 9"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:cxnSp[2]/p:spPr/a:xfrm", "flipV", "1"); + double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:cxnSp[2]/p:spPr/a:xfrm/a:off", "x").toDouble(); + double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:cxnSp[2]/p:spPr/a:xfrm/a:off", "y").toDouble(); CPPUNIT_ASSERT_DOUBLES_EQUAL( 4059000.0, dX, dX * .001); CPPUNIT_ASSERT_DOUBLES_EQUAL( 3287520.0, dY, dY * .001); } diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 215d668b2f3f..100c9e784875 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,7 @@ public: virtual void setUp() override; void testDocumentLayout(); + void testTdf89449(); void testTdf147459(); void testTdf146223(); void testTdf144918(); @@ -147,6 +149,7 @@ public: CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST(testDocumentLayout); + CPPUNIT_TEST(testTdf89449); CPPUNIT_TEST(testTdf147459); CPPUNIT_TEST(testTdf146223); CPPUNIT_TEST(testTdf144918); @@ -292,6 +295,42 @@ void SdImportTest::testDocumentLayout() } } +void SdImportTest::testTdf89449() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf89449.pptx"), PPTX); + + sal_Int32 nStartGlueId; + sal_Int32 nEndGlueId; + css::drawing::ConnectorType aConnectorType; + + uno::Reference xCurvedConnector(getShapeFromPage(3, 0, xDocShRef)); + xCurvedConnector->getPropertyValue("EdgeKind") >>= aConnectorType; + CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_CURVE, aConnectorType); + nStartGlueId = xCurvedConnector->getPropertyValue("StartGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nStartGlueId); + nEndGlueId = xCurvedConnector->getPropertyValue("EndGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nEndGlueId); + + uno::Reference xStraightConnector(getShapeFromPage(4, 0, xDocShRef)); + xStraightConnector->getPropertyValue("EdgeKind") >>= aConnectorType; + CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_LINE, aConnectorType); + nStartGlueId = xStraightConnector->getPropertyValue("StartGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nStartGlueId); + nEndGlueId = xStraightConnector->getPropertyValue("EndGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nEndGlueId); + + uno::Reference xStandardConnector(getShapeFromPage(5, 0, xDocShRef)); + xStandardConnector->getPropertyValue("EdgeKind") >>= aConnectorType; + CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_STANDARD, aConnectorType); + nStartGlueId = xStandardConnector->getPropertyValue("StartGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nStartGlueId); + nEndGlueId = xStandardConnector->getPropertyValue("EndGluePointIndex").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nEndGlueId); + + xDocShRef->DoClose(); +} + void SdImportTest::testTdf147459() { sd::DrawDocShellRef xDocShRef -- cgit