summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <grzegorz.araminowicz@collabora.com>2019-04-10 16:19:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-04-12 09:48:38 +0200
commitc9c9c5ad3fa41f78042b44092c44a181c3b846b8 (patch)
treefcfc20743de151e8f7db4f108ecc50dfaa09b102 /oox
parenta293630bb4dfed200c1c1e246acab4226a0ff08f (diff)
SmartArt: improve cycle algorithm
connector arrows are now correctly positioned and rotated Change-Id: I6407ec5e2d6e29d250f751f8dc5feae878d3c74c Reviewed-on: https://gerrit.libreoffice.org/70525 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx28
1 files changed, 22 insertions, 6 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 9b7d5323e518..7d64e82059af 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -672,6 +672,11 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
awt::Size aSize;
aSize.Width = rParent[XML_w];
aSize.Height = rParent[XML_h];
+ // keep center position
+ awt::Point aPos = rShape->getPosition();
+ aPos.X += (rShape->getSize().Width - aSize.Width) / 2;
+ aPos.Y += (rShape->getSize().Height - aSize.Height) / 2;
+ rShape->setPosition(aPos);
rShape->setSize(aSize);
break;
}
@@ -686,24 +691,35 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
const sal_Int32 nRotationPath = maMap.count(XML_rotPath) ? maMap.find(XML_rotPath)->second : XML_none;
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 awt::Size aChildSize(rShape->getSize().Width / 4, rShape->getSize().Height / 4);
+ const awt::Size aConnectorSize(rShape->getSize().Width / 12, rShape->getSize().Height / 12);
const sal_Int32 nRadius = std::min(
(rShape->getSize().Width - aChildSize.Width) / 2,
(rShape->getSize().Height - aChildSize.Height) / 2);
+ const sal_Int32 nConnectorRadius = nRadius * cos(basegfx::deg2rad(nSpanAngle/nShapes));
sal_Int32 idx = 0;
for (auto & aCurrShape : rShape->getChildren())
{
const double fAngle = static_cast<double>(idx)*nSpanAngle/nShapes + nStartAngle;
+ awt::Size aCurrSize = aChildSize;
+ sal_Int32 nCurrRadius = nRadius;
+ if (aCurrShape->getSubType() == XML_conn)
+ {
+ aCurrSize = aConnectorSize;
+ nCurrRadius = nConnectorRadius;
+ }
const awt::Point aCurrPos(
- aCenter.Width + nRadius*sin(basegfx::deg2rad(fAngle)) - aChildSize.Width/2,
- aCenter.Height - nRadius*cos(basegfx::deg2rad(fAngle)) - aChildSize.Height/2);
+ aCenter.Width + nCurrRadius*sin(basegfx::deg2rad(fAngle)) - aCurrSize.Width/2,
+ aCenter.Height - nCurrRadius*cos(basegfx::deg2rad(fAngle)) - aCurrSize.Height/2);
aCurrShape->setPosition(aCurrPos);
- aCurrShape->setSize(aChildSize);
- aCurrShape->setChildSize(aChildSize);
+ aCurrShape->setSize(aCurrSize);
+ aCurrShape->setChildSize(aCurrSize);
- if (nRotationPath == XML_alongPath)
+ // connectors should be handled in conn, but we don't have
+ // reference to previous and next child, so it's easier here
+ if (nRotationPath == XML_alongPath || aCurrShape->getSubType() == XML_conn)
aCurrShape->setRotation(fAngle * PER_DEGREE);
idx++;