oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 22 ++++++++++++++++++++ oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 1 oox/source/drawingml/diagram/layoutnodecontext.cxx | 19 ++++++++++++++++- sd/qa/unit/import-tests-smartart.cxx | 5 ++-- 4 files changed, 44 insertions(+), 3 deletions(-)
New commits: commit 8c653a9badf2b3383215ac5cfd2630a7af1853e7 Author: Miklos Vajna <[email protected]> AuthorDate: Tue Aug 4 10:58:00 2020 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Aug 5 10:46:31 2020 +0200 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. (cherry picked from commit 3c185bf386b4c9609ab32d19bf95b83fe0eeeea3) Change-Id: I433f92c620149ef5590aebc8cbf43110e1d2fb85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100115 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 13e684d7b76f..44a66f819e98 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1147,6 +1147,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 8904e525a181..ab152bed0b70 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -272,6 +272,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 7157176053d8..f7308b6623bf 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -195,7 +195,24 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, { LayoutNodePtr pNode( new 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 ); diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 4425c560d676..110b7d2c81ea 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -1498,8 +1498,9 @@ void SdImportTestSmartArt::testLinearRule() sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-linear-rule.pptx"), PPTX); uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); - // Last child, then again last child. - uno::Reference<drawing::XShape> xShape = getChildShape(getChildShape(xGroup, 1), 3); + // Last child, then first child inside that. + // It is first as backgroundArrow is last, but chOrder="t" is set to reverse the order. + uno::Reference<drawing::XShape> xShape = getChildShape(getChildShape(xGroup, 1), 0); // Without the accompanying fix in place, this test would have failed with: // - Expected greater than: 17500 (19867) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
