From d8c89fb920af747ec51ce966b5d7b65e9340afbd Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Fri, 4 Nov 2022 20:58:36 +0100 Subject: tdf#151891 PPTX import: fix regression of connector position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: László Németh --- oox/source/ppt/slidepersist.cxx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'oox') diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 126fc664bd3a..3b9a93ded03c 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -46,6 +46,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::oox::core; @@ -355,6 +356,7 @@ static void lcl_SetEdgeLineValue(uno::Reference& rXConnector, { sal_Int32 nEdge = 0; awt::Point aStartPt, aEndPt; + tools::Rectangle aStartRect, aEndRect; uno::Reference xStartSp, xEndSp; uno::Reference xPropSet(rXConnector, uno::UNO_QUERY); xPropSet->getPropertyValue("EdgeStartPoint") >>= aStartPt; @@ -366,6 +368,14 @@ static void lcl_SetEdgeLineValue(uno::Reference& 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") { @@ -375,16 +385,20 @@ static void lcl_SetEdgeLineValue(uno::Reference& 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 @@ -395,7 +409,7 @@ static void lcl_SetEdgeLineValue(uno::Reference& 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; -- cgit