oox/source/export/shapes.cxx | 37 ++++++++++++++++++++++++++++-------- oox/source/ppt/slidepersist.cxx | 15 +++++++++----- sd/qa/unit/data/pptx/tdf154363.pptx |binary sd/qa/unit/import-tests.cxx | 24 +++++++++++++++++++++++ 4 files changed, 63 insertions(+), 13 deletions(-)
New commits: commit b7c542b5085374f1d031183cb86ceeefcf24964d Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Wed Mar 29 09:00:47 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Apr 11 19:32:45 2023 +0200 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 <nem...@numbertext.org> Tested-by: László Németh <nem...@numbertext.org> diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 372b4376fe22..eab82a86336d 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 bb673b52442e..0f7479e8ede9 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -659,11 +659,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; diff --git a/sd/qa/unit/data/pptx/tdf154363.pptx b/sd/qa/unit/data/pptx/tdf154363.pptx new file mode 100644 index 000000000000..b549fda90135 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf154363.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index d934b963f6ef..8bd818d442ea 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -191,6 +191,30 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testDocumentLayout) } } +CPPUNIT_TEST_FIXTURE(SdImportTest, testTdf154363) +{ + sal_Int32 nGlueId; + createSdImpressDoc("pptx/tdf154363.pptx"); + { + uno::Reference<beans::XPropertySet> xConnector1(getShapeFromPage(1, 0), uno::UNO_SET_THROW); + uno::Reference<beans::XPropertySet> xConnector2(getShapeFromPage(3, 0), uno::UNO_SET_THROW); + nGlueId = xConnector1->getPropertyValue("StartGluePointIndex").get<sal_Int32>(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId); + nGlueId = xConnector2->getPropertyValue("EndGluePointIndex").get<sal_Int32>(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId); + } + + saveAndReload("Impress MS PowerPoint 2007 XML"); + { + uno::Reference<beans::XPropertySet> xConnector1(getShapeFromPage(1, 0), uno::UNO_SET_THROW); + uno::Reference<beans::XPropertySet> xConnector2(getShapeFromPage(3, 0), uno::UNO_SET_THROW); + nGlueId = xConnector1->getPropertyValue("StartGluePointIndex").get<sal_Int32>(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId); + nGlueId = xConnector2->getPropertyValue("EndGluePointIndex").get<sal_Int32>(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId); + } +} + CPPUNIT_TEST_FIXTURE(SdImportTest, testTdf153466) { createSdImpressDoc("pptx/tdf153466.pptx");