[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 2 commits - oox/source sd/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 5 09:27:02 UTC 2020
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 34 ++++++++++++++++++++
oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 1
oox/source/drawingml/diagram/layoutnodecontext.cxx | 19 ++++++++++-
sd/qa/unit/import-tests-smartart.cxx | 11 +++++-
4 files changed, 62 insertions(+), 3 deletions(-)
New commits:
commit 06afd008a453b261b120062589b0b961acdaadd3
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Aug 4 10:58:00 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 5 11:26:42 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/+/100107
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index cc0e456fa25d..7493464842ef 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 );
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index c8825f15fcc4..28dafbc1d9af 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1516,8 +1516,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)
commit 1a16bb0de0d40084fdbcb5d7a875037b34e336e4
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 3 11:18:49 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 5 11:26:28 2020 +0200
oox smartart, linear layout: limit height of children to parent size
Constraints are OK to request more, but it seems PowerPoint doesn't
allow leaving the parent, which simplifies the layout as well.
(cherry picked from commit b7481a026348c3417fa13a440312521dccee9ec8)
Change-Id: Id67a8740f1eff506e4beae0c797ad50e0218dfe6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100105
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 24e5422ce654..cc0e456fa25d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -926,9 +926,21 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
LayoutProperty& rProperty = aProperties[rConstraint.msForName];
if (rConstraint.mnType == XML_w)
+ {
rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor;
+ if (rProperty[XML_w] > rShape->getSize().Width)
+ {
+ rProperty[XML_w] = rShape->getSize().Width;
+ }
+ }
if (rConstraint.mnType == XML_h)
+ {
rProperty[XML_h] = rShape->getSize().Height * rConstraint.mfFactor;
+ if (rProperty[XML_h] > rShape->getSize().Height)
+ {
+ rProperty[XML_h] = rShape->getSize().Height;
+ }
+ }
// TODO: get values from differently named constraints as well
if (rConstraint.msForName == "sp" || rConstraint.msForName == "space" || rConstraint.msForName == "sibTrans")
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 1a4818e8474a..c8825f15fcc4 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1538,6 +1538,12 @@ void SdImportTestSmartArt::testLinearRule()
sal_Int32 nArrowLeft = xShape->getPosition().X;
CPPUNIT_ASSERT_EQUAL(nGroupLeft, nArrowLeft);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected less or equal than: 10092
+ // - Actual : 20183
+ // i.e. the arrow height was larger than the canvas given to the smartart on slide 1.
+ CPPUNIT_ASSERT_LESSEQUAL(static_cast<sal_Int32>(10092), xShape->getSize().Height);
+
xDocShRef->DoClose();
}
More information about the Libreoffice-commits
mailing list