[Libreoffice-commits] core.git: oox/source sd/qa
Grzegorz Araminowicz (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 12 07:49:20 UTC 2019
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 28 +++++++++++++++-----
sd/qa/unit/import-tests-smartart.cxx | 17 +++++++++++-
2 files changed, 38 insertions(+), 7 deletions(-)
New commits:
commit c9c9c5ad3fa41f78042b44092c44a181c3b846b8
Author: Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
AuthorDate: Wed Apr 10 16:19:32 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 12 09:48:38 2019 +0200
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 at collabora.com>
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++;
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 33bdf6532966..001bb07678a8 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -401,10 +401,25 @@ void SdImportTestSmartArt::testCycle()
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle.pptx"), PPTX);
uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
CPPUNIT_ASSERT(xGroup.is());
+
// 10 children: 5 shapes, 5 connectors
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10), xGroup->getCount());
- //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
+ uno::Reference<drawing::XShape> xShape0(xGroup->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(1), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(2), uno::UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xText0(xShape0, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString());
+ uno::Reference<text::XText> xText2(xShape2, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("b"), xText2->getString());
+
+ // xShapeConn is connector between shapes 0 and 2
+ // it should lay between them and be rotated 0 -> 2
+ CPPUNIT_ASSERT(xShape0->getPosition().X < xShapeConn->getPosition().X);
+ CPPUNIT_ASSERT(xShape0->getPosition().Y < xShapeConn->getPosition().Y && xShapeConn->getPosition().Y < xShape2->getPosition().Y);
+ uno::Reference<beans::XPropertySet> xPropSetConn(xShapeConn, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(32400), xPropSetConn->getPropertyValue("RotateAngle").get<sal_Int32>());
}
void SdImportTestSmartArt::testHierarchy()
More information about the Libreoffice-commits
mailing list