oox/source/ppt/slidepersist.cxx | 24 +++++++++++++++++++----- sd/qa/unit/data/pptx/connectors.pptx |binary sd/qa/unit/import-tests.cxx | 16 ++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-)
New commits: commit 8abf381416e4cad90027542c1d230736cc1b4d96 Author: Tibor Nagy <[email protected]> AuthorDate: Fri Nov 4 20:58:36 2022 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Nov 25 13:32:11 2022 +0100 tdf#151891 PPTX import: fix regression of connector position If the connector shape is connected to the glue point which there is inside the bounding box, then the position of connector appear incorrectly, for example different direction of the arrow head. Regression likely from commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8 "tdf#89449 PPTX import: fix line connectors", as tdf#148926. Follow-up to commit eec48130271188cab63665acedbabf1ff5e850a2 "tdf#148926 tdf#151678 PPTX import: position of standard connector - part1". Change-Id: I5671bc70e663a979c43bad1b786118a6a9e92972 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142293 Reviewed-by: László Németh <[email protected]> Tested-by: László Németh <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143287 Tested-by: Jenkins diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 137a9c437a4b..d4f56aba5a7e 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/container/XIdentifierContainer.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp> #include <com/sun/star/drawing/ConnectorType.hpp> +#include <svx/svdobj.hxx> using namespace ::com::sun::star; using namespace ::oox::core; @@ -356,6 +357,7 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector, { sal_Int32 nEdge = 0; awt::Point aStartPt, aEndPt; + tools::Rectangle aStartRect, aEndRect; uno::Reference<drawing::XShape> xStartSp, xEndSp; uno::Reference<beans::XPropertySet> xPropSet(rXConnector, uno::UNO_QUERY); xPropSet->getPropertyValue("EdgeStartPoint") >>= aStartPt; @@ -367,6 +369,14 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector, xPropSet->setPropertyValue("EdgeNode2HorzDist", Any(sal_Int32(0))); xPropSet->setPropertyValue("EdgeNode2VertDist", Any(sal_Int32(0))); + SdrObject* pStartObj = xStartSp.is() ? SdrObject::getSdrObjectFromXShape(xStartSp) : nullptr; + SdrObject* pEndObj = xEndSp.is() ? SdrObject::getSdrObjectFromXShape(xEndSp) : nullptr; + + if (pStartObj) + aStartRect = pStartObj->GetSnapRect(); + if (pEndObj) + aEndRect = pEndObj->GetSnapRect(); + const OUString sConnectorName = rShapePtr->getConnectorName(); if (sConnectorName == "bentConnector2") { @@ -376,16 +386,20 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector, if (aConnSize.Height < aConnSize.Width) { if (xStartSp.is()) - nEdge = (aStartPt.Y > aEndPt.Y) ? -aConnSize.Height : aConnSize.Height; + nEdge -= (aStartPt.Y > aEndPt.Y) ? (aStartRect.Top() - aEndPt.Y) + : (aStartRect.Bottom() - aEndPt.Y); else - nEdge = (aStartPt.Y > aEndPt.Y) ? aConnSize.Height : -aConnSize.Height; + nEdge -= (aStartPt.Y > aEndPt.Y) ? (aEndRect.Bottom() - aStartPt.Y) + : (aEndRect.Top() - aStartPt.Y); } else { if (xStartSp.is()) - nEdge = (aStartPt.X > aEndPt.X) ? -aConnSize.Width : aConnSize.Width; + nEdge -= (aStartPt.X > aEndPt.X) ? (aStartRect.Left() - aEndPt.X) + : (aStartRect.Right() - aEndPt.X); else - nEdge = (aStartPt.X > aEndPt.X) ? aConnSize.Width : -aConnSize.Width; + nEdge -= (aStartPt.X > aEndPt.X) ? (aEndRect.Right() - aStartPt.X) + : (aEndRect.Left() - aStartPt.X); } } else @@ -396,7 +410,7 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector, if (aConnSize.Height < aConnSize.Width) { if ((nConnectorAngle == 90 && bFlipH && bFlipV) || (nConnectorAngle == 180) - || (nConnectorAngle == 180 && bFlipV) || (nConnectorAngle == 270 && bFlipH)) + || (nConnectorAngle == 270 && bFlipH)) nEdge -= aConnSize.Width; else nEdge += aConnSize.Width; diff --git a/sd/qa/unit/data/pptx/connectors.pptx b/sd/qa/unit/data/pptx/connectors.pptx index fa03ef0f6046..ba959068663c 100644 Binary files a/sd/qa/unit/data/pptx/connectors.pptx and b/sd/qa/unit/data/pptx/connectors.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 87d282a8a8f9..17b0f894c75f 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -311,12 +311,20 @@ void SdImportTest::testConnectors() ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/connectors.pptx"), PPTX); - sal_Int32 aEdgeValue[] = { -1167, -1167, -1591, 1476, 1357, -1357, 1604, -1540 }; - for (size_t i = 1; i < 9; i++) + sal_Int32 aEdgeValue[] = { -1167, -1167, -1591, 1476, 1356, -1357, 1604, -1540, + 607, 1296, -1638, -1060, -522, 1578, -1291, 333 }; + + sal_Int32 nCount = 0; + for (size_t i = 0; i < 18; i++) { uno::Reference<beans::XPropertySet> xConnector(getShapeFromPage(i, 0, xDocShRef)); - sal_Int32 nEdgeLine = xConnector->getPropertyValue("EdgeLine1Delta").get<sal_Int32>(); - CPPUNIT_ASSERT_EQUAL(aEdgeValue[i-1], nEdgeLine); + bool bConnector = xConnector->getPropertySetInfo()->hasPropertyByName("EdgeLine1Delta"); + if (bConnector) + { + sal_Int32 nEdgeLine = xConnector->getPropertyValue("EdgeLine1Delta").get<sal_Int32>(); + CPPUNIT_ASSERT_EQUAL(aEdgeValue[nCount], nEdgeLine); + nCount++; + } } xDocShRef->DoClose(); }
