summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/diagram
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-01-18 11:10:28 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-01-18 18:14:16 +0100
commitae34f471030869dfc0da1784597cae6f9131f8c5 (patch)
tree96a7901205ca3d4f6ece1db21cc7c3975a8aa627 /oox/source/drawingml/diagram
parente3cc5506d695b602fbd3c6ee816e36e6a76d9d96 (diff)
oox smartart, org chart: implement support for hierBranch conditions
The relevant part of the layout is the <dgm:layoutNode name="hierChild2"> element that has a <dgm:choose> with two branches: <dgm:if name="Name34" func="var" arg="hierBranch" op="equ" val="std"> <dgm:if name="Name36" func="var" arg="hierBranch" op="equ" val="init"> The connectors were missing as we took the first branch (ConditionAtom::getDecision() returned true if the arg was hierBranch), even hierBranch on the parent layout node was set to "init". With this, the correct number of connectors are created, previously all employee connectors were missing. Their size / position is still incorrect, though. Change-Id: I74a705b13f82a065fc0b9b9d306bfb0dcaf0f7f4 Reviewed-on: https://gerrit.libreoffice.org/66579 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox/source/drawingml/diagram')
-rw-r--r--oox/source/drawingml/diagram/datamodelcontext.cxx2
-rw-r--r--oox/source/drawingml/diagram/diagram.hxx3
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx41
3 files changed, 42 insertions, 4 deletions
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx
index 326b4f933ed6..b98d0ee87ccf 100644
--- a/oox/source/drawingml/diagram/datamodelcontext.cxx
+++ b/oox/source/drawingml/diagram/datamodelcontext.cxx
@@ -111,7 +111,7 @@ public:
mrPoint.mnDirection = rAttribs.getToken( XML_val, XML_norm );
break;
case DGM_TOKEN( hierBranch ):
- mrPoint.mnHierarchyBranch = rAttribs.getToken( XML_val, XML_std );
+ mrPoint.moHierarchyBranch = rAttribs.getToken( XML_val );
break;
case DGM_TOKEN( orgChart ):
mrPoint.mbOrgChartEnabled = rAttribs.getBool( XML_val, false );
diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx
index 1a981a858c29..242ff09fa152 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -73,7 +73,6 @@ struct Point
mnMaxChildren(-1),
mnPreferredChildren(-1),
mnDirection(XML_norm),
- mnHierarchyBranch(XML_std),
mnResizeHandles(XML_rel),
mnCustomAngle(-1),
mnPercentageNeighbourWidth(-1),
@@ -118,7 +117,7 @@ struct Point
sal_Int32 mnMaxChildren;
sal_Int32 mnPreferredChildren;
sal_Int32 mnDirection;
- sal_Int32 mnHierarchyBranch;
+ OptValue<sal_Int32> moHierarchyBranch;
sal_Int32 mnResizeHandles;
sal_Int32 mnCustomAngle;
sal_Int32 mnPercentageNeighbourWidth;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index fc5b1c059410..4495ae8a570d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -346,8 +346,32 @@ bool ConditionAtom::getDecision() const
case XML_var:
{
const dgm::Point* pPoint = getPresNode();
- if (pPoint && maCond.mnArg == XML_dir)
+ if (!pPoint)
+ break;
+
+ if (maCond.mnArg == XML_dir)
return compareResult(maCond.mnOp, pPoint->mnDirection, maCond.mnVal);
+ else if (maCond.mnArg == XML_hierBranch)
+ {
+ sal_Int32 nHierarchyBranch = pPoint->moHierarchyBranch.get(XML_std);
+ if (!pPoint->moHierarchyBranch.has())
+ {
+ // If <dgm:hierBranch> is missing in the current presentation
+ // point, ask the parent.
+ OUString aParent = navigate(mrLayoutNode, XML_presParOf, pPoint->msModelId,
+ /*bSourceToDestination*/ false);
+ DiagramData::PointNameMap& rPointNameMap
+ = mrLayoutNode.getDiagram().getData()->getPointNameMap();
+ auto it = rPointNameMap.find(aParent);
+ if (it != rPointNameMap.end())
+ {
+ const dgm::Point* pParent = it->second;
+ if (pParent->moHierarchyBranch.has())
+ nHierarchyBranch = pParent->moHierarchyBranch.get();
+ }
+ }
+ return compareResult(maCond.mnOp, nHierarchyBranch, maCond.mnVal);
+ }
break;
}
@@ -595,6 +619,15 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
sal_Int32 nCount = rShape->getChildren().size();
+ if (mnType == XML_hierChild)
+ {
+ // Connectors should not influence the size of non-connect
+ // shapes.
+ nCount = std::count_if(
+ rShape->getChildren().begin(), rShape->getChildren().end(),
+ [](const ShapePtr& pShape) { return pShape->getSubType() != XML_conn; });
+ }
+
// A manager node's height should be independent from if it has
// assistants and employees, compensate for that.
bool bTop = mnType == XML_hierRoot && rShape->getInternalName() == "hierRoot1";
@@ -632,6 +665,12 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
pChild->setPosition(aChildPos);
pChild->setSize(aChildSize);
pChild->setChildSize(aChildSize);
+
+ if (mnType == XML_hierChild && pChild->getSubType() == XML_conn)
+ // Connectors should not influence the position of
+ // non-connect shapes.
+ continue;
+
if (nDir == XML_fromT)
aChildPos.Y += aChildSize.Height;
else