tdf#152211 PPTX import: fix connector position based on line width
Thick shape line changed the connector, e.g. direction of
its arrow head.
Follow-up to commit d8c89fb920af747ec51ce966b5d7b65e9340afbd
"tdf#151891 PPTX import: fix regression of connector position"
Regression from commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
"tdf#89449 PPTX import: fix line connectors".
Change-Id: I99d22409ec65e10609b1e371cc4d301fd73c7c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143467
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 400e44cebd993f4b9b3d878fb9264f99e005c9fb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143589
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index d4f56ab..4536e7c 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -372,10 +372,24 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector,
SdrObject* pStartObj = xStartSp.is() ? SdrObject::getSdrObjectFromXShape(xStartSp) : nullptr;
SdrObject* pEndObj = xEndSp.is() ? SdrObject::getSdrObjectFromXShape(xEndSp) : nullptr;
sal_Int32 nStartSpLineW = 0;
if (pStartObj)
{
aStartRect = pStartObj->GetSnapRect();
uno::Reference<beans::XPropertySet> xPropxStartSp(xStartSp, uno::UNO_QUERY);
xPropxStartSp->getPropertyValue("LineWidth") >>= nStartSpLineW;
if (nStartSpLineW)
nStartSpLineW = nStartSpLineW / 2;
}
sal_Int32 nEndSpLineW = 0;
if (pEndObj)
{
aEndRect = pEndObj->GetSnapRect();
uno::Reference<beans::XPropertySet> xPropxEndSp(xEndSp, uno::UNO_QUERY);
xPropxEndSp->getPropertyValue("LineWidth") >>= nEndSpLineW;
if (nEndSpLineW)
nEndSpLineW = nEndSpLineW / 2;
}
const OUString sConnectorName = rShapePtr->getConnectorName();
if (sConnectorName == "bentConnector2")
@@ -386,20 +400,24 @@ static void lcl_SetEdgeLineValue(uno::Reference<drawing::XShape>& rXConnector,
if (aConnSize.Height < aConnSize.Width)
{
if (xStartSp.is())
nEdge -= (aStartPt.Y > aEndPt.Y) ? (aStartRect.Top() - aEndPt.Y)
: (aStartRect.Bottom() - aEndPt.Y);
nEdge = (aStartPt.Y > aEndPt.Y)
? (nStartSpLineW - (aStartRect.Top() - aEndPt.Y))
: ((aEndPt.Y - aStartRect.Bottom()) - nStartSpLineW);
else
nEdge -= (aStartPt.Y > aEndPt.Y) ? (aEndRect.Bottom() - aStartPt.Y)
: (aEndRect.Top() - aStartPt.Y);
nEdge = (aStartPt.Y > aEndPt.Y)
? ((aStartPt.Y - aEndRect.Bottom()) - nEndSpLineW)
: (nEndSpLineW - (aEndRect.Top() - aStartPt.Y));
}
else
{
if (xStartSp.is())
nEdge -= (aStartPt.X > aEndPt.X) ? (aStartRect.Left() - aEndPt.X)
: (aStartRect.Right() - aEndPt.X);
nEdge = (aStartPt.X > aEndPt.X)
? (nStartSpLineW - (aStartRect.Left() - aEndPt.X))
: ((aEndPt.X - aStartRect.Right()) - nStartSpLineW);
else
nEdge -= (aStartPt.X > aEndPt.X) ? (aEndRect.Right() - aStartPt.X)
: (aEndRect.Left() - aStartPt.X);
nEdge = (aStartPt.X > aEndPt.X)
? ((aStartPt.X - aEndRect.Right()) - nEndSpLineW)
: (nEndSpLineW - (aEndRect.Left() - aStartPt.X));
}
}
else
diff --git a/sd/qa/unit/data/pptx/connectors.pptx b/sd/qa/unit/data/pptx/connectors.pptx
index ba95906..2f65acb 100644
--- a/sd/qa/unit/data/pptx/connectors.pptx
+++ b/sd/qa/unit/data/pptx/connectors.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 17b0f894..66653f7 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -311,8 +311,8 @@ 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, 1356, -1357, 1604, -1540,
607, 1296, -1638, -1060, -522, 1578, -1291, 333 };
sal_Int32 aEdgeValue[] = { -1123, -1123, -1547, 1432, 1356, -1357, 1604, -1540,
599, 1288, -1629, -1052, -513, 1569, -1283, 333 };
sal_Int32 nCount = 0;
for (size_t i = 0; i < 18; i++)