diff options
Diffstat (limited to 'oox/source/drawingml/diagram/diagram.cxx')
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 5a4fef99cfcb..8265ae7b3a88 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -82,6 +82,25 @@ static void sortChildrenByZOrder(const ShapePtr& pShape) sortChildrenByZOrder(rChild); } +/// Removes empty group shapes, now that their spacing influenced the layout. +static void removeUnneededGroupShapes(const ShapePtr& pShape) +{ + std::vector<ShapePtr>& rChildren = pShape->getChildren(); + + rChildren.erase(std::remove_if(rChildren.begin(), rChildren.end(), + [](const ShapePtr& aChild) { + return aChild->getServiceName() + == "com.sun.star.drawing.GroupShape" + && aChild->getChildren().empty(); + }), + rChildren.end()); + + for (const auto& pChild : rChildren) + { + removeUnneededGroupShapes(pChild); + } +} + void Diagram::addTo( const ShapePtr & pParentShape ) { if (pParentShape->getSize().Width == 0 || pParentShape->getSize().Height == 0) @@ -103,6 +122,7 @@ void Diagram::addTo( const ShapePtr & pParentShape ) mpLayout->getNode()->accept(aLayoutingVisitor); sortChildrenByZOrder(pParentShape); + removeUnneededGroupShapes(pParentShape); } ShapePtr pBackground = std::make_shared<Shape>("com.sun.star.drawing.CustomShape"); |