diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2023-03-29 09:00:47 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-05-13 20:05:19 +0200 |
commit | fd854b0110228ffa5f44f335091dae0671df98c0 (patch) | |
tree | 128c89252bb9e06d165efd422af23e9e2cbcf96e /oox | |
parent | 9518b389e4ec9a25b1ab459e5cc6bb650c58cba1 (diff) |
tdf#154363 sd: fix line connectors regression of mirrored shapes
caused by commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
(tdf#89449 PPTX import: fix line connectors).
Note: partial revert of commit 9ab16e2738b4b9bd324c9aded8acb2ecba0fd2b0
"oox: fix crash in lcl_GetGluePointId by removing unused code".
Change-Id: Icc45c93c4fa3a22c0f34866ccb64ea6b9037d936
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149676
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150202
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/shapes.cxx | 37 | ||||
-rw-r--r-- | oox/source/ppt/slidepersist.cxx | 15 |
2 files changed, 39 insertions, 13 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 971d112a6402..6e839f32e9c5 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1640,17 +1640,38 @@ static void lcl_GetConnectorAdjustValue(const Reference<XShape>& xShape, tools:: } } -static sal_Int32 lcl_GetGluePointId(sal_Int32 nGluePointId) +static sal_Int32 lcl_GetGluePointId(const Reference<XShape>& xShape, sal_Int32 nGluePointId) { if (nGluePointId > 3) return nGluePointId - 4; else { - // change id of the bounding box (1 <-> 3) - if (nGluePointId == 1) - return 3; // Right - else if (nGluePointId == 3) - return 1; // Left + bool bFlipH = false; + bool bFlipV = false; + Reference<XPropertySet> xShapeProps(xShape, UNO_QUERY); + if (xShapeProps->getPropertySetInfo()->hasPropertyByName("CustomShapeGeometry")) + { + Sequence<PropertyValue> aGeometrySeq; + xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeometrySeq; + for (int i = 0; i < aGeometrySeq.getLength(); i++) + { + const PropertyValue& rProp = aGeometrySeq[i]; + if (rProp.Name == "MirroredX") + rProp.Value >>= bFlipH; + + if (rProp.Name == "MirroredY") + rProp.Value >>= bFlipV; + } + } + + if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV)) + { + // change id of the bounding box (1 <-> 3) + if (nGluePointId == 1) + nGluePointId = 3; // Right + else if (nGluePointId == 3) + nGluePointId = 1; // Left + } } return nGluePointId; @@ -1708,12 +1729,12 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape if (GetProperty(rXPropSet, "StartGluePointIndex")) mAny >>= nStartGlueId; if (nStartGlueId != -1) - nStartGlueId = lcl_GetGluePointId(nStartGlueId); + nStartGlueId = lcl_GetGluePointId(rXShapeA, nStartGlueId); if (GetProperty(rXPropSet, "EndGluePointIndex")) mAny >>= nEndGlueId; if (nEndGlueId != -1) - nEndGlueId = lcl_GetGluePointId(nEndGlueId); + nEndGlueId = lcl_GetGluePointId(rXShapeB, nEndGlueId); // Position is relative to group in Word, but relative to anchor of group in API. if (GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes && m_xParent.is()) diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 7298eea1247c..349262fc6b8f 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -654,11 +654,16 @@ void SlidePersist::createConnectorShapeConnection() nGlueId += 4; else { - // 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 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 + } } bool bStart = aConnectorShapeProperties[j].mbStartShape; |