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>
This commit is contained in:
parent
2afdc61dd3
commit
a14531e413
3 changed files with 56 additions and 28 deletions
BIN
oox/qa/unit/data/connectorConnection.pptx
Normal file
BIN
oox/qa/unit/data/connectorConnection.pptx
Normal file
Binary file not shown.
|
@ -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");
|
||||
|
|
|
@ -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,43 +177,42 @@ 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);
|
||||
|
||||
if(!aConnectorShapeMap.empty())
|
||||
{
|
||||
for (auto& pIt : aConnectorShapeMap)
|
||||
{
|
||||
SdrObject* pObj = SdrObject::getSdrObjectFromXShape(pIt.second->getXShape());
|
||||
SdrModel& rModel(pObj->getSdrModelFromSdrObject());
|
||||
rModel.setLock(false);
|
||||
|
||||
ConnectorHelper::applyConnections(pIt.second, getShapeMap());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() );
|
||||
}
|
||||
}
|
||||
|
||||
if (!aConnectorShapeMap.empty())
|
||||
{
|
||||
for (auto& pIt : aConnectorShapeMap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY);
|
||||
if( !xNodeSupplier.is() )
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue