diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-31 16:38:05 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-11-01 07:36:08 +0100 |
commit | e49c42d17f50c8b0cac9db08dedc375dd5aa8a98 (patch) | |
tree | a4b82795f226dedb243a3151f3db46cd1b765cbf /oox/source/drawingml/diagram/diagramlayoutatoms.cxx | |
parent | 98718dc375df991afe8136a48b9ec11051f58054 (diff) |
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/62703
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'oox/source/drawingml/diagram/diagramlayoutatoms.cxx')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 8acceb2a942f..2ef5ffef2151 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -146,6 +146,36 @@ const dgm::Point* ConditionAtom::getPresNode() const 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 nCount = 0; @@ -154,9 +184,21 @@ sal_Int32 ConditionAtom::getNodeCount() const { OUString sNodeId = ""; - for (const auto& aCxn : mrLayoutNode.getDiagram().getData()->getConnections()) - if (aCxn.mnType == XML_presOf && aCxn.msDestId == pPoint->msModelId) - sNodeId = aCxn.msSourceId; + sNodeId + = navigate(mrLayoutNode, XML_presOf, pPoint->msModelId, /*bSourceToDestination*/ false); + + 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()) { |