Kaydet (Commit) e49c42d1 authored tarafından Miklos Vajna's avatar Miklos Vajna

oox smartart, vertical bracket list: fix node counter condition

The visible effect of this was that the 2nd level text nodes were
missing from the layout result.

The cause is that when it comes to counting nodes of a condition, we
assumed that the current layout node is a presentation of a model node,
but this is not necessarily true.

Fix the problem doing a "first presentation child of", then a "presentation
of" navigation in that case, which leads us to the correct model node,
so counting its children works.

(An alternative way of getting non-zero children would be a
"presentation parent of" navigation, followed by a "presentation of"
navigation, but that would lead us to the document root, so we would
count the number of 1st level elements, not the correct 2nd level
elements.)

Change-Id: Iccebe0e2e56b7acb7fbe2c38a7c9ebb2abb309b9
Reviewed-on: https://gerrit.libreoffice.org/62703Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
üst 98718dc3
...@@ -146,6 +146,36 @@ const dgm::Point* ConditionAtom::getPresNode() const ...@@ -146,6 +146,36 @@ const dgm::Point* ConditionAtom::getPresNode() const
return nullptr; return nullptr;
} }
namespace
{
/**
* Takes the connection list from rLayoutNode, navigates from rFrom on an edge
* of type nType, using a direction determined by bSourceToDestination.
*/
OUString navigate(const LayoutNode& rLayoutNode, sal_Int32 nType, const OUString& rFrom,
bool bSourceToDestination)
{
for (const auto& rConnection : rLayoutNode.getDiagram().getData()->getConnections())
{
if (rConnection.mnType != nType)
continue;
if (bSourceToDestination)
{
if (rConnection.msSourceId == rFrom)
return rConnection.msDestId;
}
else
{
if (rConnection.msDestId == rFrom)
return rConnection.msSourceId;
}
}
return OUString();
}
}
sal_Int32 ConditionAtom::getNodeCount() const sal_Int32 ConditionAtom::getNodeCount() const
{ {
sal_Int32 nCount = 0; sal_Int32 nCount = 0;
...@@ -154,9 +184,21 @@ sal_Int32 ConditionAtom::getNodeCount() const ...@@ -154,9 +184,21 @@ sal_Int32 ConditionAtom::getNodeCount() const
{ {
OUString sNodeId = ""; OUString sNodeId = "";
for (const auto& aCxn : mrLayoutNode.getDiagram().getData()->getConnections()) sNodeId
if (aCxn.mnType == XML_presOf && aCxn.msDestId == pPoint->msModelId) = navigate(mrLayoutNode, XML_presOf, pPoint->msModelId, /*bSourceToDestination*/ false);
sNodeId = aCxn.msSourceId;
if (sNodeId.isEmpty())
{
// The current layout node is not a presentation of anything. Look
// up the first presentation child of the layout node.
OUString sFirstPresChildId = navigate(mrLayoutNode, XML_presParOf, pPoint->msModelId,
/*bSourceToDestination*/ true);
if (!sFirstPresChildId.isEmpty())
// It has a presentation child: is that a presentation of a
// model node?
sNodeId = navigate(mrLayoutNode, XML_presOf, sFirstPresChildId,
/*bSourceToDestination*/ false);
}
if (!sNodeId.isEmpty()) if (!sNodeId.isEmpty())
{ {
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
void testSegmentedCycle(); void testSegmentedCycle();
void testBaseRtoL(); void testBaseRtoL();
void testVertialBoxList(); void testVertialBoxList();
void testVertialBracketList();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt); CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
...@@ -66,6 +67,7 @@ public: ...@@ -66,6 +67,7 @@ public:
CPPUNIT_TEST(testSegmentedCycle); CPPUNIT_TEST(testSegmentedCycle);
CPPUNIT_TEST(testBaseRtoL); CPPUNIT_TEST(testBaseRtoL);
CPPUNIT_TEST(testVertialBoxList); CPPUNIT_TEST(testVertialBoxList);
CPPUNIT_TEST(testVertialBracketList);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -397,6 +399,23 @@ void SdImportTestSmartArt::testVertialBoxList() ...@@ -397,6 +399,23 @@ void SdImportTestSmartArt::testVertialBoxList()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTestSmartArt::testVertialBracketList()
{
sd::DrawDocShellRef xDocShRef = loadURL(
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/vertical-bracket-list.pptx"), PPTX);
uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xShapeGroup->getCount());
uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xFirstChild.is());
// Without the accompanying fix in place, this test would have failed with
// 'actual: 2', i.e. one child shape (with its "A" text) was missing.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xFirstChild->getCount());
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment