diff options
author | Tibor Nagy <tibor.nagy.extern@allotropia.de> | 2024-07-01 13:59:52 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-07-07 11:09:42 +0200 |
commit | 80bb33a5bf3ffc5bb8b05ca9bb7980543337156b (patch) | |
tree | 5161d99f3b4c73e26981d1653671ae701499cf5d | |
parent | 8c660b1a394f4f512a08f79e9d9fb73942f83461 (diff) |
tdf#157172 tdf#157460 PPTX import: fix connectors adjustment values
Change-Id: Ie95ccd5bcd4d5c3f9c45c7dcc4f88acc0c9438aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169830
Tested-by: Jenkins
Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
(cherry picked from commit 05041641da82fc0382503195ae9bdeb5182f764b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169818
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | include/oox/ppt/slidepersist.hxx | 4 | ||||
-rw-r--r-- | oox/qa/unit/data/curvedConnectors.pptx | bin | 0 -> 35029 bytes | |||
-rw-r--r-- | oox/qa/unit/data/elbowConnectors.pptx | bin | 0 -> 34608 bytes | |||
-rw-r--r-- | oox/qa/unit/data/standardConnectors.pptx (renamed from sd/qa/unit/data/pptx/standardConnectors.pptx) | bin | 36923 -> 36923 bytes | |||
-rw-r--r-- | oox/qa/unit/shape.cxx | 81 | ||||
-rw-r--r-- | oox/source/ppt/slidepersist.cxx | 385 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 30 |
7 files changed, 219 insertions, 281 deletions
diff --git a/include/oox/ppt/slidepersist.hxx b/include/oox/ppt/slidepersist.hxx index 0112a67913e7..88d73d0da3ba 100644 --- a/include/oox/ppt/slidepersist.hxx +++ b/include/oox/ppt/slidepersist.hxx @@ -125,7 +125,7 @@ public: CommentList& getCommentsList() { return maCommentsList; } CommentAuthorList& getCommentAuthors() { return maCommentAuthors; } - void createConnectorShapeConnection(); + void createConnectorShapeConnection(oox::drawingml::ShapePtr& pConnector); private: OUString maPath; @@ -158,8 +158,6 @@ private: // slide comments CommentList maCommentsList; CommentAuthorList maCommentAuthors; - - std::vector<OUString> maConnectorShapeId; }; } diff --git a/oox/qa/unit/data/curvedConnectors.pptx b/oox/qa/unit/data/curvedConnectors.pptx Binary files differnew file mode 100644 index 000000000000..a961aed03444 --- /dev/null +++ b/oox/qa/unit/data/curvedConnectors.pptx diff --git a/oox/qa/unit/data/elbowConnectors.pptx b/oox/qa/unit/data/elbowConnectors.pptx Binary files differnew file mode 100644 index 000000000000..df876f4e73c2 --- /dev/null +++ b/oox/qa/unit/data/elbowConnectors.pptx diff --git a/sd/qa/unit/data/pptx/standardConnectors.pptx b/oox/qa/unit/data/standardConnectors.pptx Binary files differindex 46bb0735f40f..46bb0735f40f 100644 --- a/sd/qa/unit/data/pptx/standardConnectors.pptx +++ b/oox/qa/unit/data/standardConnectors.pptx diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx index ed2cd7965a78..3e4c270162c1 100644 --- a/oox/qa/unit/shape.cxx +++ b/oox/qa/unit/shape.cxx @@ -39,6 +39,7 @@ #include <docmodel/uno/UnoComplexColor.hxx> #include <docmodel/uno/UnoGradientTools.hxx> #include <basegfx/utils/gradienttools.hxx> +#include <editeng/unoprnms.hxx> using namespace ::com::sun::star; @@ -91,6 +92,86 @@ uno::Reference<drawing::XShape> OoxShapeTest::getShapeByName(std::u16string_view return xRet; } +CPPUNIT_TEST_FIXTURE(OoxShapeTest, testElbowConnectors) +{ + loadFromFile(u"elbowConnectors.pptx"); + + sal_Int32 nEdgeLineDelta; + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + uno::Reference<drawing::XShape> xShape1(xDrawPage->getByIndex(2), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps1(xShape1, uno::UNO_QUERY); + xShapeProps1->getPropertyValue(UNO_NAME_EDGELINE1DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(-2756), nEdgeLineDelta); + + uno::Reference<drawing::XShape> xShape2(xDrawPage->getByIndex(5), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps2(xShape2, uno::UNO_QUERY); + xShapeProps2->getPropertyValue(UNO_NAME_EDGELINE1DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(-805), nEdgeLineDelta); +} + +CPPUNIT_TEST_FIXTURE(OoxShapeTest, testCurvedConnectors) +{ + loadFromFile(u"curvedConnectors.pptx"); + + sal_Int32 nEdgeLineDelta; + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + uno::Reference<drawing::XShape> xShape1(xDrawPage->getByIndex(2), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps1(xShape1, uno::UNO_QUERY); + xShapeProps1->getPropertyValue(UNO_NAME_EDGELINE1DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(-2364), nEdgeLineDelta); + xShapeProps1->getPropertyValue(UNO_NAME_EDGELINE2DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(4250), nEdgeLineDelta); + xShapeProps1->getPropertyValue(UNO_NAME_EDGELINE3DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(2051), nEdgeLineDelta); + + uno::Reference<drawing::XShape> xShape2(xDrawPage->getByIndex(5), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps2(xShape2, uno::UNO_QUERY); + xShapeProps2->getPropertyValue(UNO_NAME_EDGELINE1DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(sal_Int32(3019), nEdgeLineDelta); +} + +CPPUNIT_TEST_FIXTURE(OoxShapeTest, testStandardConnectors) +{ + loadFromFile(u"standardConnectors.pptx"); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + sal_Int32 aEdgeValue[] = { -1352, -2457, 2402, // bentConnector5 + 3977, 0, 0, // bentConnector3 + -2899, 0, 0, // bentConnector3 + -1260, 4612, 0, // bentConnector4 + -1431, -2642, 0, // bentConnector4 + 3831, 3438, -1578 }; // bentConnector5 + sal_Int32 nCount = 0; + sal_Int32 nEdgeLineDelta; + for (size_t i = 0; i < 10; i++) + { + uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); + bool bConnector = xShapeProps->getPropertySetInfo()->hasPropertyByName(u"EdgeKind"_ustr); + if (bConnector) + { + xShapeProps->getPropertyValue(UNO_NAME_EDGELINE1DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLineDelta); + nCount++; + xShapeProps->getPropertyValue(UNO_NAME_EDGELINE2DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLineDelta); + nCount++; + xShapeProps->getPropertyValue(UNO_NAME_EDGELINE3DELTA) >>= nEdgeLineDelta; + CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLineDelta); + nCount++; + } + } +} + CPPUNIT_TEST_FIXTURE(OoxShapeTest, testGroupTransform) { loadFromFile(u"tdf141463_GroupTransform.pptx"); diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index bc7fc3514a68..2164311a0bfb 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -34,6 +34,7 @@ #include <oox/core/xmlfilterbase.hxx> #include <drawingml/textliststyle.hxx> #include <drawingml/textparagraphproperties.hxx> +#include <drawingml/connectorhelper.hxx> #include <osl/diagnose.h> @@ -47,6 +48,7 @@ #include <com/sun/star/drawing/ConnectorType.hpp> #include <utility> #include <svx/svdobj.hxx> +#include <svx/svdmodel.hxx> using namespace ::com::sun::star; using namespace ::oox::core; @@ -134,6 +136,28 @@ sal_Int16 SlidePersist::getLayoutFromValueToken() const return nLayout; } +static void lcl_createShapeMap(oox::drawingml::ShapePtr rShapePtr, + oox::drawingml::ShapeIdMap& rShapeMap) +{ + std::vector<oox::drawingml::ShapePtr>& rChildren = rShapePtr->getChildren(); + if (!rChildren.empty()) + { + for (const auto& pIt : rChildren) + { + if (pIt->isConnectorShape()) + { + rShapeMap[pIt->getId()] = pIt; // add child itself + lcl_createShapeMap(pIt, rShapeMap); // and all its descendants + } + } + } + else + { + if(rShapePtr->isConnectorShape()) + rShapeMap[rShapePtr->getId()] = rShapePtr; + } +} + void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) { applyTextStyles( rFilterBase ); @@ -151,14 +175,36 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) if ( pPPTShape ) { pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap() ); - if (pPPTShape->isConnectorShape()) - maConnectorShapeId.push_back(pPPTShape->getId()); - if (!pPPTShape->getChildren().empty()) + + oox::drawingml::ShapeIdMap aConnectorShapeMap; + const auto& pIter = maShapeMap.find(pPPTShape->getId()); + if (pIter != maShapeMap.end()) + lcl_createShapeMap(pIter->second, aConnectorShapeMap); + + if(!aConnectorShapeMap.empty()) { - for (size_t i = 0; i < pPPTShape->getChildren().size(); i++) + for (auto& pIt : aConnectorShapeMap) { - if (pPPTShape->getChildren()[i]->isConnectorShape()) - maConnectorShapeId.push_back(pPPTShape->getChildren()[i]->getId()); + SdrObject* pObj = SdrObject::getSdrObjectFromXShape(pIt.second->getXShape()); + SdrModel& rModel(pObj->getSdrModelFromSdrObject()); + rModel.setLock(false); + + ConnectorHelper::applyConnections(pIt.second, getShapeMap()); + + if (pIt.second->getConnectorName() == u"bentConnector3"_ustr + || pIt.second->getConnectorName() == u"bentConnector4"_ustr + || pIt.second->getConnectorName() == u"bentConnector5"_ustr) + { + ConnectorHelper::applyBentHandleAdjustments(pIt.second); + } + else if (pIt.second->getConnectorName() == u"curvedConnector3"_ustr + || pIt.second->getConnectorName() == u"curvedConnector4"_ustr + || pIt.second->getConnectorName() == u"curvedConnector5"_ustr) + { + ConnectorHelper::applyCurvedHandleAdjustments(pIt.second); + } + else // bentConnector2 + createConnectorShapeConnection(pIt.second); } } } @@ -167,9 +213,6 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) } } - if (!maConnectorShapeId.empty()) - createConnectorShapeConnection(); - Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY); if( !xNodeSupplier.is() ) return; @@ -419,282 +462,126 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector, nEndA = lcl_GetAngle(xEndSp, aEndPt); } - // bentConnector3, bentConnector4, bentConnector5 - if (!rShapePtr->getConnectorAdjustments().empty()) + const OUString sConnectorName = rShapePtr->getConnectorName(); + if (sConnectorName == "bentConnector2") { - sal_Int32 nAdjustValue = 0; - for (size_t i = 0; i < rShapePtr->getConnectorAdjustments().size(); i++) + awt::Size aConnSize = rXConnector->getSize(); + if (xStartSp.is() || xEndSp.is()) { - bool bVertical = false; - if (xStartSp.is() || xEndSp.is()) - bVertical = xStartSp.is() ? ((nStartA == 90 || nStartA == 270) ? true : false) - : ((nEndA == 90 || nEndA == 270) ? true : false); - else + if (nStartA >= 0) { - sal_Int32 nAng = rShapePtr->getRotation() / 60000; - bVertical = (nAng == 90 || nAng == 270) ? true : false; - } - - if (i % 2 == 1) - bVertical = !bVertical; - - nAdjustValue = rShapePtr->getConnectorAdjustments()[i].toInt32(); - if (bVertical) - { - sal_Int32 nY = aStartPt.Y + ((nAdjustValue * (aEndPt.Y - aStartPt.Y)) / 100000); - if (xStartSp.is() && xEndSp.is()) - { - if (aS.Top() <= aE.Top()) - { - if (nStartA == 270 && i != 2) - nEdge = nY - aS.Top(); - else - { - if (aS.Bottom() < aE.Top() && nEndA != 90) - { - nEdge = nY - (aS.Bottom() + ((aE.Top() - aS.Bottom()) / 2)); - } - else - nEdge = nY - aE.Bottom(); - } - } - else - { - if (nStartA == 90 && i != 2) - nEdge = nY - aS.Bottom(); - else - { - if (aE.Bottom() < aS.Top() && nEndA != 270) - nEdge = nY - (aS.Top() + ((aE.Bottom() - aS.Top()) / 2)); - else - nEdge = nY - aE.Top(); - } - } - } - else if ((xStartSp.is() && !xEndSp.is()) || (!xStartSp.is() && xEndSp.is())) - { - if (aStartPt.Y < aEndPt.Y) - { - if (xStartSp.is()) - nEdge = (nStartA == 90) - ? nY - (aEndPt.Y - ((aEndPt.Y - aS.Bottom()) / 2)) - : nY - aS.Top(); - else - nEdge = (nEndA == 90) - ? nY - aE.Bottom() - : nY - (aStartPt.Y + ((aE.Top() - aStartPt.Y) / 2)); - } - else - { - if (xStartSp.is()) - nEdge = (nStartA == 90) ? nY - aS.Bottom() - : nY - (aEndPt.Y + ((aS.Top() - aEndPt.Y) / 2)); - else - nEdge = (nEndA == 90) - ? nY - (aStartPt.Y - ((aStartPt.Y - aE.Bottom()) / 2)) - : nY - aE.Top(); - } - } - else + switch (nStartA) { - nEdge = (aStartPt.Y < aEndPt.Y) - ? nY - (aStartPt.Y + (rXConnector->getSize().Height / 2)) - : nY - (aStartPt.Y - (rXConnector->getSize().Height / 2)); + case 0: nEdge = aEndPt.X - aS.Right(); break; + case 180: nEdge = aEndPt.X - aS.Left(); break; + case 90: nEdge = aEndPt.Y - aS.Bottom(); break; + case 270: nEdge = aEndPt.Y - aS.Top(); break; } } - else // Horizontal + else { - sal_Int32 nX = aStartPt.X + ((nAdjustValue * (aEndPt.X - aStartPt.X)) / 100000); - if (xStartSp.is() && xEndSp.is()) - { - if (aS.Left() <= aE.Left()) - { - if (nStartA == 180 && i != 2) - nEdge = nX - aS.Left(); - else - { - if (aS.Right() < aE.Left() && nEndA != 0) - nEdge = nX - (aS.Right() + ((aE.Left() - aS.Right()) / 2)); - else - nEdge = nX - aE.Right(); - } - } - else - { - if (nStartA == 0 && i != 2) - nEdge = nX - aS.Right(); - else - { - if (aE.Right() < aS.Left() && nEndA != 180) - nEdge = nX - (aS.Left() + ((aE.Right() - aS.Left()) / 2)); - else - nEdge = nX - aE.Left(); - } - } - } - else if ((xStartSp.is() && !xEndSp.is()) || (!xStartSp.is() && xEndSp.is())) + switch (nEndA) { - if (aStartPt.X < aEndPt.X) - { - if (xStartSp.is()) - nEdge = (nStartA == 0) - ? nX - (aS.Right() + ((aEndPt.X - aS.Right()) / 2)) - : nX - aS.Left(); - else - nEdge = (nEndA == 0) - ? nX - aE.Right() - : nX - (aStartPt.X + ((aE.Left() - aStartPt.X) / 2)); - } - else - { - if (xStartSp.is()) - nEdge = (nStartA == 0) ? nX - aS.Right() - : nX - (aEndPt.X + ((aS.Left() - aEndPt.X) / 2)); - else - nEdge = (nEndA == 0) - ? nX - (aE.Right() + ((aStartPt.X - aE.Right()) / 2)) - : nX - aE.Left(); - } - } - else - { - nEdge = (aStartPt.X < aEndPt.X) - ? nX - (aStartPt.X + (rXConnector->getSize().Width / 2)) - : nX - (aStartPt.X - (rXConnector->getSize().Width / 2)); + case 0: nEdge = aStartPt.X - aE.Right(); break; + case 180: nEdge = aStartPt.X - aE.Left(); break; + case 90: nEdge = aStartPt.Y - aE.Bottom(); break; + case 270: nEdge = aStartPt.Y - aE.Top(); break; } } - xPropSet->setPropertyValue("EdgeLine" + OUString::number(i + 1) + "Delta", Any(nEdge)); } - } - else - { - const OUString sConnectorName = rShapePtr->getConnectorName(); - if (sConnectorName == "bentConnector2") + else { - awt::Size aConnSize = rXConnector->getSize(); - if (xStartSp.is() || xEndSp.is()) + bool bFlipH = rShapePtr->getFlipH(); + bool bFlipV = rShapePtr->getFlipV(); + sal_Int32 nConnectorAngle = rShapePtr->getRotation() / 60000; + if (aConnSize.Height < aConnSize.Width) { - if (nStartA >= 0) - { - switch (nStartA) - { - case 0: nEdge = aEndPt.X - aS.Right(); break; - case 180: nEdge = aEndPt.X - aS.Left(); break; - case 90: nEdge = aEndPt.Y - aS.Bottom(); break; - case 270: nEdge = aEndPt.Y - aS.Top(); break; - } - } else { - switch (nEndA) - { - case 0: nEdge = aStartPt.X - aE.Right(); break; - case 180: nEdge = aStartPt.X - aE.Left(); break; - case 90: nEdge = aStartPt.Y - aE.Bottom(); break; - case 270: nEdge = aStartPt.Y - aE.Top(); break; - } - } + if ((nConnectorAngle == 90 && bFlipH && bFlipV) || (nConnectorAngle == 180) + || (nConnectorAngle == 270 && bFlipH)) + nEdge -= aConnSize.Width; + else + nEdge += aConnSize.Width; } else { - bool bFlipH = rShapePtr->getFlipH(); - bool bFlipV = rShapePtr->getFlipV(); - sal_Int32 nConnectorAngle = rShapePtr->getRotation() / 60000; - if (aConnSize.Height < aConnSize.Width) - { - if ((nConnectorAngle == 90 && bFlipH && bFlipV) || (nConnectorAngle == 180) - || (nConnectorAngle == 270 && bFlipH)) - nEdge -= aConnSize.Width; - else - nEdge += aConnSize.Width; - } + if ((nConnectorAngle == 180 && bFlipV) || (nConnectorAngle == 270 && bFlipV) + || (nConnectorAngle == 90 && bFlipH && bFlipV) + || (nConnectorAngle == 0 && !bFlipV)) + nEdge -= aConnSize.Height; else - { - if ((nConnectorAngle == 180 && bFlipV) || (nConnectorAngle == 270 && bFlipV) - || (nConnectorAngle == 90 && bFlipH && bFlipV) - || (nConnectorAngle == 0 && !bFlipV)) - nEdge -= aConnSize.Height; - else - nEdge += aConnSize.Height; - } + nEdge += aConnSize.Height; } - xPropSet->setPropertyValue(u"EdgeLine1Delta"_ustr, Any(nEdge / 2)); } + xPropSet->setPropertyValue(u"EdgeLine1Delta"_ustr, Any(nEdge / 2)); } } // create connection between two shape with a connector shape. -void SlidePersist::createConnectorShapeConnection() +void SlidePersist::createConnectorShapeConnection(oox::drawingml::ShapePtr& pConnector) { - sal_Int32 nConnectorShapeCount = maConnectorShapeId.size(); - for (sal_Int32 i = 0; i < nConnectorShapeCount; i++) + oox::drawingml::ConnectorShapePropertiesList aConnectorShapeProperties + = pConnector->getConnectorShapeProperties(); + uno::Reference<drawing::XShape> xConnector(pConnector->getXShape(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xConnector, uno::UNO_QUERY); + + if (xConnector.is()) { - const auto& pIt = maShapeMap.find(maConnectorShapeId[i]); - if (pIt == maShapeMap.end()) - continue; - oox::drawingml::ConnectorShapePropertiesList aConnectorShapeProperties - = pIt->second->getConnectorShapeProperties(); - uno::Reference<drawing::XShape> xConnector(pIt->second->getXShape(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xConnector, uno::UNO_QUERY); - - if (xConnector.is()) + sal_Int32 nCount = aConnectorShapeProperties.size(); + for (sal_Int32 j = 0; j < nCount; j++) { - sal_Int32 nCount = aConnectorShapeProperties.size(); - for (sal_Int32 j = 0; j < nCount; j++) + OUString aDestShapeId = aConnectorShapeProperties[j].maDestShapeId; + const auto& pShape = maShapeMap.find(aDestShapeId); + if (pShape == maShapeMap.end()) + continue; + uno::Reference<drawing::XShape> xShape(pShape->second->getXShape(), uno::UNO_QUERY); + if (xShape.is()) { - OUString aDestShapeId = aConnectorShapeProperties[j].maDestShapeId; - const auto& pShape = maShapeMap.find(aDestShapeId); - if (pShape == maShapeMap.end()) - continue; - uno::Reference<drawing::XShape> xShape(pShape->second->getXShape(), uno::UNO_QUERY); - if (xShape.is()) - { - uno::Reference<drawing::XGluePointsSupplier> xSupplier(xShape, uno::UNO_QUERY); - css::uno::Reference<css::container::XIdentifierContainer> xGluePoints( - xSupplier->getGluePoints(), uno::UNO_QUERY); + uno::Reference<drawing::XGluePointsSupplier> xSupplier(xShape, uno::UNO_QUERY); + css::uno::Reference<css::container::XIdentifierContainer> xGluePoints( + xSupplier->getGluePoints(), uno::UNO_QUERY); - sal_Int32 nCountGluePoints = xGluePoints->getIdentifiers().getLength(); - sal_Int32 nGlueId = aConnectorShapeProperties[j].mnDestGlueId; + 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 + // The first 4 glue points belong to the bounding box. + if (nCountGluePoints > 4) + nGlueId += 4; + else + { + bool bFlipH = pShape->second->getFlipH(); + bool bFlipV = pShape->second->getFlipV(); + if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV)) { - bool bFlipH = pShape->second->getFlipH(); - bool bFlipV = pShape->second->getFlipV(); - if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV)) - { - // 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 - } + // 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(u"StartShape"_ustr, uno::Any(xShape)); - xPropertySet->setPropertyValue(u"StartGluePointIndex"_ustr, uno::Any(nGlueId)); - } - else - { - xPropertySet->setPropertyValue(u"EndShape"_ustr, uno::Any(xShape)); - xPropertySet->setPropertyValue(u"EndGluePointIndex"_ustr, uno::Any(nGlueId)); - } + bool bStart = aConnectorShapeProperties[j].mbStartShape; + if (bStart) + { + xPropertySet->setPropertyValue(u"StartShape"_ustr, uno::Any(xShape)); + xPropertySet->setPropertyValue(u"StartGluePointIndex"_ustr, uno::Any(nGlueId)); + } + else + { + xPropertySet->setPropertyValue(u"EndShape"_ustr, uno::Any(xShape)); + xPropertySet->setPropertyValue(u"EndGluePointIndex"_ustr, uno::Any(nGlueId)); } } - uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropertySet->getPropertySetInfo(); - if (xPropInfo->hasPropertyByName(u"EdgeKind"_ustr)) - { - ConnectorType aConnectorType; - xPropertySet->getPropertyValue(u"EdgeKind"_ustr) >>= aConnectorType; - if (aConnectorType == ConnectorType_STANDARD) - lcl_SetEdgeLineValue(xConnector, pIt->second); - } + } + uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropertySet->getPropertySetInfo(); + if (xPropInfo->hasPropertyByName(u"EdgeKind"_ustr)) + { + ConnectorType aConnectorType; + xPropertySet->getPropertyValue(u"EdgeKind"_ustr) >>= aConnectorType; + if (aConnectorType == ConnectorType_STANDARD) + lcl_SetEdgeLineValue(xConnector, pConnector); } } - maConnectorShapeId.clear(); } } diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index d2ae920a0071..fd11a02fc24a 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -385,40 +385,12 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testTdf152434) CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount()); } -CPPUNIT_TEST_FIXTURE(SdImportTest, testStandardConnectors) -{ - createSdImpressDoc("pptx/standardConnectors.pptx"); - - sal_Int32 aEdgeValue[] = { -1352, -2457, 3977, -2900, -1261, 4611, -1431, -2643, 3830, 3438 }; - - sal_Int32 nCount = 0; - sal_Int32 nEdgeLine = 0; - for (size_t i = 0; i < 10; i++) - { - uno::Reference<beans::XPropertySet> xConnector(getShapeFromPage(i, 0)); - bool bConnector = xConnector->getPropertySetInfo()->hasPropertyByName(u"EdgeKind"_ustr); - if (bConnector) - { - nEdgeLine = xConnector->getPropertyValue(u"EdgeLine1Delta"_ustr).get<sal_Int32>(); - CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLine); - nCount++; - - nEdgeLine = xConnector->getPropertyValue(u"EdgeLine2Delta"_ustr).get<sal_Int32>(); - if (nEdgeLine != 0) - { - CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLine); - nCount++; - } - } - } -} - CPPUNIT_TEST_FIXTURE(SdImportTest, testConnectors) { createSdImpressDoc("pptx/connectors.pptx"); sal_Int32 aEdgeValue[] = { -1167, -1167, -1591, 1476, 1356, -1357, 1604, -1540, - 607, 1296, -1638, -1060, -522, 1578, -1291, 333 }; + 607, 1296, -1638, -1060, 2402, 3313, -1834, 333 }; sal_Int32 nCount = 0; for (size_t i = 0; i < 18; i++) |