oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 49 +++++++------------- 1 file changed, 18 insertions(+), 31 deletions(-)
New commits: commit 64cd173f346d35c28909b4ac8f9c2d2a939049b7 Author: Grzegorz Araminowicz <g.araminow...@gmail.com> Date: Sat Jul 22 19:03:03 2017 +0200 SmartArt: cycle layout algorithm Change-Id: Ia6863ed6ee8f8bc3240f0ab16a58e59141b2a2d1 Reviewed-on: https://gerrit.libreoffice.org/40314 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index d1c172862541..a9ebdff157e0 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -167,39 +167,26 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, if (rShape->getChildren().empty()) break; - const sal_Int32 nStartAngle=maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0; - const sal_Int32 nSpanAngle=maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360; - - std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin(); - const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end(); - const sal_Int32 nShapes=aLastShape-aCurrShape; - - // find biggest shape - awt::Size aMaxSize; - while( aCurrShape != aLastShape ) - { - const awt::Size& sz=(*aCurrShape)->getSize(); - - aMaxSize.Width = std::max( - aMaxSize.Width, - sz.Width); - aMaxSize.Height = std::max( - aMaxSize.Height, - sz.Height); - - ++aCurrShape; - } - - // layout shapes - const sal_Int32 nMaxDim=std::max(aMaxSize.Width,aMaxSize.Height); - aCurrShape=rShape->getChildren().begin(); - for( sal_Int32 i=0; i<nShapes; ++i, ++aCurrShape ) + const sal_Int32 nStartAngle = maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0; + const sal_Int32 nSpanAngle = maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360; + const sal_Int32 nShapes = rShape->getChildren().size(); + const awt::Size aCenter(rShape->getSize().Width / 2, rShape->getSize().Height / 2); + const awt::Size aChildSize(rShape->getSize().Width / 5, rShape->getSize().Height / 5); + const sal_Int32 r = std::min( + (rShape->getSize().Width - aChildSize.Width) / 2, + (rShape->getSize().Height - aChildSize.Height) / 2); + + sal_Int32 idx = 0; + for (auto & aCurrShape : rShape->getChildren()) { - const double r=nShapes*nMaxDim/F_2PI * 360.0/nSpanAngle; const awt::Point aCurrPos( - r + r*sin( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ), - r - r*cos( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) ); - (*aCurrShape)->setPosition(aCurrPos); + aCenter.Width + r*sin( (double(idx)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) - aChildSize.Width/2, + aCenter.Height - r*cos( (double(idx)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) - aChildSize.Height/2); + + aCurrShape->setPosition(aCurrPos); + aCurrShape->setSize(aChildSize); + aCurrShape->setChildSize(aChildSize); + idx++; } break; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits