oox/source/drawingml/diagram/diagram.cxx | 12 +++++++++--- oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 15 ++++++++++----- oox/source/drawingml/diagram/layoutatomvisitors.cxx | 9 +++++++-- oox/source/drawingml/diagram/layoutnodecontext.cxx | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-)
New commits: commit a7b7614c7cab42cd0839752635db81e25e1e50a1 Author: Grzegorz Araminowicz <[email protected]> Date: Fri Jun 30 13:30:27 2017 +0200 SmartArt: reuse existing diagram shape for root shape it prevents creating unnecessary expanded shape hierarchy and allows layout algorithm to know parent's size Change-Id: Ieb991a74bd662e359f5cf479a7480893e0b13d45 Reviewed-on: https://gerrit.libreoffice.org/39410 Tested-by: Jenkins <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 467d7005b534..533156bbfb86 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -317,13 +317,19 @@ void Diagram::addTo( const ShapePtr & pParentShape ) // collect data, init maps build( ); + if (pParentShape->getSize().Width == 0 || pParentShape->getSize().Height == 0) + SAL_WARN("oox.drawingml", "Diagram cannot be correctly laid out. Size: " + << pParentShape->getSize().Width << "x" << pParentShape->getSize().Height); + pParentShape->setChildSize(pParentShape->getSize()); - // create Shape hierarchy - ShapeCreationVisitor aCreationVisitor(pParentShape, *this); if( mpLayout->getNode() ) + { + // create Shape hierarchy + ShapeCreationVisitor aCreationVisitor(pParentShape, *this); + mpLayout->getNode()->setExistingShape(pParentShape); mpLayout->getNode()->accept( aCreationVisitor ); - + } pParentShape->setDiagramDoms( getDomsAsPropertyValues() ); } diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index 2df1af060ec2..d5b9fcdf9e29 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -238,10 +238,14 @@ public: { msStyleLabel = sLabel; } void setChildOrder( sal_Int32 nOrder ) { mnChildOrder = nOrder; } - void setShape( const ShapePtr& pShape ) - { mpShape = pShape; } - const ShapePtr& getShape() const - { return mpShape; } + void setShapeTemplate( const ShapePtr& pShape ) + { mpShapeTemplate = pShape; } + void setExistingShape( const ShapePtr& pShape ) + { mpExistingShape = pShape; } + const ShapePtr& getShapeTemplate() const + { return mpShapeTemplate; } + const ShapePtr& getExistingShape() const + { return mpExistingShape; } bool setupShape( const ShapePtr& rShape, const Diagram& rDgm, @@ -251,7 +255,8 @@ private: VarMap mVariables; OUString msMoveWith; OUString msStyleLabel; - ShapePtr mpShape; + ShapePtr mpShapeTemplate; + ShapePtr mpExistingShape; sal_Int32 mnChildOrder; }; diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx b/oox/source/drawingml/diagram/layoutatomvisitors.cxx index a0c1609ba927..fd6e9d7b7e1b 100755 --- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx +++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx @@ -94,8 +94,13 @@ void ShapeCreationVisitor::visit(ChooseAtom& rAtom) void ShapeCreationVisitor::visit(LayoutNode& rAtom) { ShapePtr pCurrParent(mpParentShape); - ShapePtr pCurrShape(rAtom.getShape()); - if( pCurrShape ) + ShapePtr pCurrShape(rAtom.getShapeTemplate()); + + if (rAtom.getExistingShape()) + { + rAtom.setupShape(rAtom.getExistingShape(), mrDgm, mnCurrIdx); + } + else if( pCurrShape ) { SAL_INFO( "oox.drawingml", diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx index d96a49b0529e..5d66de142c96 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -263,7 +263,7 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, pShape.reset( new Shape("com.sun.star.drawing.GroupShape") ); } - pNode->setShape( pShape ); + pNode->setShapeTemplate( pShape ); return new ShapeContext( *this, ShapePtr(), pShape ); } else _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
