diff options
author | Grzegorz Araminowicz <g.araminowicz@gmail.com> | 2017-07-22 19:03:03 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-07-24 15:43:32 +0200 |
commit | 64cd173f346d35c28909b4ac8f9c2d2a939049b7 (patch) | |
tree | 3043e63d623960cfe0a7d32fe039d9f997de4776 /oox | |
parent | 96773c0f3cb3104ae92e50c69be0361f02880bf7 (diff) |
SmartArt: cycle layout algorithm
Change-Id: Ia6863ed6ee8f8bc3240f0ab16a58e59141b2a2d1
Reviewed-on: https://gerrit.libreoffice.org/40314
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 49 |
1 files changed, 18 insertions, 31 deletions
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; } |