summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2018-11-16 17:34:46 +0100
committerMiklos Vajna <vmiklos@collabora.com>2018-11-16 20:43:26 +0100
commitcd348a6244a092c251a8e1362cd78de562d7bef6 (patch)
tree466c0d97c656dd2b59d9dc1acb9c20b93a4eaa4b /oox
parentUpdate git submodules (diff)
downloadcore-cd348a6244a092c251a8e1362cd78de562d7bef6.tar.gz
core-cd348a6244a092c251a8e1362cd78de562d7bef6.zip
oox smartart, accent process: add support for zorder offsets
The oox::drawingml::Shape -> css::drawing::XShape converter doesn't support ZOrder, so just give each drawingml::Shape a default ZOrder. This way the offsets can be applied, and sorting can move the shapes to their correct place. This makes parent text of the bugdoc readable. Change-Id: Ib87a096fba66aad4a4f35d19473ea88dab340fd0 Reviewed-on: https://gerrit.libreoffice.org/63478 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/layoutatomvisitors.cxx32
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx2
-rw-r--r--oox/source/drawingml/shape.cxx2
3 files changed, 36 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index b85b5228407d..700b48080bc6 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -168,6 +168,38 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
std::remove_if(pCurrParent->getChildren().begin(), pCurrParent->getChildren().end(),
[] (const ShapePtr & aChild) { return aChild->getServiceName() == "com.sun.star.drawing.GroupShape" && aChild->getChildren().empty(); }),
pCurrParent->getChildren().end());
+
+ // Offset the children from their default z-order stacking, if necessary.
+ std::vector<ShapePtr>& rChildren = pCurrParent->getChildren();
+ for (size_t i = 0; i < rChildren.size(); ++i)
+ rChildren[i]->setZOrder(i);
+
+ for (size_t i = 0; i < rChildren.size(); ++i)
+ {
+ const ShapePtr& pChild = rChildren[i];
+ sal_Int32 nZOrderOff = pChild->getZOrderOff();
+ if (nZOrderOff <= 0)
+ continue;
+
+ // Increase my ZOrder by nZOrderOff.
+ pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
+ pChild->setZOrderOff(0);
+
+ for (sal_Int32 j = 0; j < nZOrderOff; ++j)
+ {
+ size_t nIndex = i + j + 1;
+ if (nIndex >= rChildren.size())
+ break;
+
+ // Decrease the ZOrder of the next nZOrderOff elements by one.
+ const ShapePtr& pNext = rChildren[nIndex];
+ pNext->setZOrder(pNext->getZOrder() - 1);
+ }
+ }
+
+ // Now that the ZOrders are adjusted, sort the children.
+ std::sort(rChildren.begin(), rChildren.end(),
+ [](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() < b->getZOrder(); });
}
void ShapeCreationVisitor::visit(ShapeAtom& /*rAtom*/)
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index d81cbdf74ae0..2cfeec2e8db6 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -210,6 +210,8 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
pShape->setDiagramRotation(rAttribs.getInteger(XML_rot, 0) * PER_DEGREE);
+ pShape->setZOrderOff(rAttribs.getInteger(XML_zOrderOff, 0));
+
ShapeAtomPtr pAtom( new ShapeAtom(mpNode->getLayoutNode(), pShape) );
LayoutAtom::connect(mpNode, pAtom);
return new ShapeContext( *this, ShapePtr(), pShape );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 1d1e4d8be5a1..2c3348fcf159 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -175,6 +175,8 @@ Shape::Shape( const ShapePtr& pSourceShape )
, maLinkedTxbxAttr()
, mbHasLinkedTxbx(false)
, maDiagramDoms( pSourceShape->maDiagramDoms )
+, mnZOrder(pSourceShape->mnZOrder)
+, mnZOrderOff(pSourceShape->mnZOrderOff)
{}
Shape::~Shape()