summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2022-11-04 20:58:36 +0100
committerLászló Németh <nemeth@numbertext.org>2022-11-14 13:31:36 +0100
commitd8c89fb920af747ec51ce966b5d7b65e9340afbd (patch)
tree2a42543500fdfb214980deeb9ad17f10b57c0c89 /oox
parent0b224cc5f3c896d8b0064d5cbadc6fce66c8beb9 (diff)
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 <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ppt/slidepersist.cxx24
1 files changed, 19 insertions, 5 deletions
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 <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
#include <com/sun/star/drawing/ConnectorType.hpp>
#include <utility>
+#include <svx/svdobj.hxx>
using namespace ::com::sun::star;
using namespace ::oox::core;
@@ -355,6 +356,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;
@@ -366,6 +368,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")
{
@@ -375,16 +385,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
@@ -395,7 +409,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;