summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTibor Nagy <tibor.nagy.extern@allotropia.de>2024-07-05 08:37:21 +0200
committerNagy Tibor <tibor.nagy.extern@allotropia.de>2024-07-05 11:00:31 +0200
commita14531e4135a82df53615254cac5e9ea0c357ef4 (patch)
treed00ada16c77051316edf12f8bee61e950d93a255 /oox
parent2afdc61dd3138b383fb73dae2242ba1a9c8de901 (diff)
The connector shape is losing its connection
The issue is that we are trying to set the connector shape properties too early, but the shapes that we want to connect to have not been created yet. Follow-up to commit Ie95ccd5bcd4d5c3f9c45c7dcc4f88acc0c9438aa "tdf#157172 tdf#157460 PPTX import: fix connectors adjustment values" Change-Id: I63c76535cc718bc46d5c3ed5489b752925cd6a77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170007 Tested-by: Jenkins Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/qa/unit/data/connectorConnection.pptxbin0 -> 33296 bytes
-rw-r--r--oox/qa/unit/shape.cxx28
-rw-r--r--oox/source/ppt/slidepersist.cxx54
3 files changed, 55 insertions, 27 deletions
diff --git a/oox/qa/unit/data/connectorConnection.pptx b/oox/qa/unit/data/connectorConnection.pptx
new file mode 100644
index 000000000000..e8a86a157151
--- /dev/null
+++ b/oox/qa/unit/data/connectorConnection.pptx
Binary files differ
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index 3e4c270162c1..28266b8783c6 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -92,6 +92,34 @@ uno::Reference<drawing::XShape> OoxShapeTest::getShapeByName(std::u16string_view
return xRet;
}
+CPPUNIT_TEST_FIXTURE(OoxShapeTest, testConnectorConnection)
+{
+ loadFromFile(u"connectorConnection.pptx");
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+
+ uno::Reference<drawing::XShape> xConnector(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xConnectorProps(xConnector, uno::UNO_QUERY);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : -1
+ // i.e. the connector shape is not attaching to the shape
+ sal_Int32 nStartGlueId;
+ xConnectorProps->getPropertyValue("StartGluePointIndex") >>= nStartGlueId;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nStartGlueId);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2
+ // - Actual : -1
+ // i.e. the connector shape is not attaching to the shape
+ sal_Int32 nEndGlueId;
+ xConnectorProps->getPropertyValue("EndGluePointIndex") >>= nEndGlueId;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nEndGlueId);
+}
+
CPPUNIT_TEST_FIXTURE(OoxShapeTest, testElbowConnectors)
{
loadFromFile(u"elbowConnectors.pptx");
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 2164311a0bfb..915ce1a1d733 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -164,6 +164,7 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
Reference< XShapes > xShapes( getPage() );
std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() );
+ oox::drawingml::ShapeIdMap aConnectorShapeMap;
for (auto const& shape : rShapes)
{
@@ -176,40 +177,39 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
{
pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap() );
- oox::drawingml::ShapeIdMap aConnectorShapeMap;
const auto& pIter = maShapeMap.find(pPPTShape->getId());
if (pIter != maShapeMap.end())
lcl_createShapeMap(pIter->second, aConnectorShapeMap);
+ }
+ else
+ child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() );
+ }
+ }
- if(!aConnectorShapeMap.empty())
- {
- for (auto& pIt : aConnectorShapeMap)
- {
- SdrObject* pObj = SdrObject::getSdrObjectFromXShape(pIt.second->getXShape());
- SdrModel& rModel(pObj->getSdrModelFromSdrObject());
- rModel.setLock(false);
+ if (!aConnectorShapeMap.empty())
+ {
+ for (auto& pIt : aConnectorShapeMap)
+ {
+ ConnectorHelper::applyConnections(pIt.second, getShapeMap());
- ConnectorHelper::applyConnections(pIt.second, getShapeMap());
+ SdrObject* pObj = SdrObject::getSdrObjectFromXShape(pIt.second->getXShape());
+ SdrModel& rModel(pObj->getSdrModelFromSdrObject());
+ rModel.setLock(false);
- if (pIt.second->getConnectorName() == u"bentConnector3"_ustr
- || pIt.second->getConnectorName() == u"bentConnector4"_ustr
- || pIt.second->getConnectorName() == u"bentConnector5"_ustr)
- {
- ConnectorHelper::applyBentHandleAdjustments(pIt.second);
- }
- else if (pIt.second->getConnectorName() == u"curvedConnector3"_ustr
- || pIt.second->getConnectorName() == u"curvedConnector4"_ustr
- || pIt.second->getConnectorName() == u"curvedConnector5"_ustr)
- {
- ConnectorHelper::applyCurvedHandleAdjustments(pIt.second);
- }
- else // bentConnector2
- createConnectorShapeConnection(pIt.second);
- }
- }
+ if (pIt.second->getConnectorName() == u"bentConnector3"_ustr
+ || pIt.second->getConnectorName() == u"bentConnector4"_ustr
+ || pIt.second->getConnectorName() == u"bentConnector5"_ustr)
+ {
+ ConnectorHelper::applyBentHandleAdjustments(pIt.second);
}
- else
- child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() );
+ else if (pIt.second->getConnectorName() == u"curvedConnector3"_ustr
+ || pIt.second->getConnectorName() == u"curvedConnector4"_ustr
+ || pIt.second->getConnectorName() == u"curvedConnector5"_ustr)
+ {
+ ConnectorHelper::applyCurvedHandleAdjustments(pIt.second);
+ }
+ else // bentConnector2
+ createConnectorShapeConnection(pIt.second);
}
}