summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-08-04 10:58:00 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-08-04 15:30:00 +0200
commit3c185bf386b4c9609ab32d19bf95b83fe0eeeea3 (patch)
tree24fc710e710527cac444e177b72e957a88da01df /oox
parent16a3a548d4e8e1132689de5615e025d0d4b3d564 (diff)
oox smartart: add support for <dgm:layoutNode ... chOrder="t">
This changes the order of children, which matters when they have no explicit ZOrder. With this, the text shapes on the arrow shape are on top of the arrow, not behind it. The trick is that nominally chOrder can be "t"(op) or "b"(ottom), defaulting to bottom, but there is a difference between an explicit "b" and not setting it. When not setting it, the layout node is expected to inherit it from its parent layout node, recursively. This would probably make sense for other algorithms as well, but set it only for the linear algorithm for now, as that's where we have a bug document showing the PowerPoint behavior. Change-Id: I433f92c620149ef5590aebc8cbf43110e1d2fb85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100047 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx22
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.hxx1
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx19
3 files changed, 41 insertions, 1 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 89fc12546165..e4980991795a 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1146,6 +1146,28 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
if (aCurrShape->getSubType() == XML_conn)
aCurrShape->setRotation(nConnectorAngle * PER_DEGREE);
}
+
+ // Newer shapes are behind older ones by default. Reverse this if requested.
+ sal_Int32 nChildOrder = XML_b;
+ const LayoutNode* pParentLayoutNode = nullptr;
+ for (LayoutAtomPtr pAtom = getParent(); pAtom; pAtom = pAtom->getParent())
+ {
+ auto pLayoutNode = dynamic_cast<LayoutNode*>(pAtom.get());
+ if (pLayoutNode)
+ {
+ pParentLayoutNode = pLayoutNode;
+ break;
+ }
+ }
+ if (pParentLayoutNode)
+ {
+ nChildOrder = pParentLayoutNode->getChildOrder();
+ }
+ if (nChildOrder == XML_t)
+ {
+ std::reverse(rShape->getChildren().begin(), rShape->getChildren().end());
+ }
+
break;
}
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index cb34f7a005f1..f36224f0f882 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -271,6 +271,7 @@ public:
{ msStyleLabel = sLabel; }
void setChildOrder( sal_Int32 nOrder )
{ mnChildOrder = nOrder; }
+ sal_Int32 getChildOrder() const { return mnChildOrder; }
void setExistingShape( const ShapePtr& pShape )
{ mpExistingShape = pShape; }
const ShapePtr& getExistingShape() const
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 80ae1d5bb6a9..93f927531cf6 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -198,7 +198,24 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
{
LayoutNodePtr pNode = std::make_shared<LayoutNode>(mpNode->getLayoutNode().getDiagram());
LayoutAtom::connect(mpNode, pNode);
- pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
+
+ if (rAttribs.hasAttribute(XML_chOrder))
+ {
+ pNode->setChildOrder(rAttribs.getToken(XML_chOrder, XML_b));
+ }
+ else
+ {
+ for (LayoutAtomPtr pAtom = mpNode; pAtom; pAtom = pAtom->getParent())
+ {
+ auto pLayoutNode = dynamic_cast<LayoutNode*>(pAtom.get());
+ if (pLayoutNode)
+ {
+ pNode->setChildOrder(pLayoutNode->getChildOrder());
+ break;
+ }
+ }
+ }
+
pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() );
pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).get() );
return new LayoutNodeContext( *this, rAttribs, pNode );