summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <grzegorz.araminowicz@collabora.com>2019-05-19 15:40:14 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-21 09:28:55 +0200
commitc91302d8818587a6b817ee1325b920578f06d5c5 (patch)
treec842d81d41211747b5c5af7ee64b3335a5a4c4cc
parent15d0cc8cb1287f9e6c3f0a67866890eef2d2599c (diff)
SmartArt: Support ctrShpMap cycle algorithm parameter
it allows to lay out first node in the center and others around it Change-Id: Ie9d7d66df638767d8713e301dee2a89a63900fbe Reviewed-on: https://gerrit.libreoffice.org/72589 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx22
-rw-r--r--sd/qa/unit/data/pptx/smartart-center-cycle.pptxbin0 -> 44405 bytes
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx30
3 files changed, 49 insertions, 3 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 323fafe12045..cab140cc84e8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -661,18 +661,34 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
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 nRotationPath = maMap.count(XML_rotPath) ? maMap.find(XML_rotPath)->second : XML_none;
- const sal_Int32 nShapes = rShape->getChildren().size();
+ const sal_Int32 nctrShpMap = maMap.count(XML_ctrShpMap) ? maMap.find(XML_ctrShpMap)->second : XML_none;
const awt::Size aCenter(rShape->getSize().Width / 2, rShape->getSize().Height / 2);
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));
+
+ std::vector<oox::drawingml::ShapePtr> aCycleChildren = rShape->getChildren();
+
+ if (nctrShpMap == XML_fNode)
+ {
+ // first node placed in center, others around
+ oox::drawingml::ShapePtr pCenterShape = aCycleChildren.front();
+ aCycleChildren.erase(aCycleChildren.begin());
+ const awt::Point aCurrPos(aCenter.Width - aChildSize.Width / 2,
+ aCenter.Height - aChildSize.Height / 2);
+ pCenterShape->setPosition(aCurrPos);
+ pCenterShape->setSize(aChildSize);
+ pCenterShape->setChildSize(aChildSize);
+ }
+
+ const sal_Int32 nShapes = aCycleChildren.size();
+ const sal_Int32 nConnectorRadius = nRadius * cos(basegfx::deg2rad(nSpanAngle / nShapes));
const sal_Int32 nConnectorAngle = nSpanAngle > 0 ? 0 : 180;
sal_Int32 idx = 0;
- for (auto & aCurrShape : rShape->getChildren())
+ for (auto & aCurrShape : aCycleChildren)
{
const double fAngle = static_cast<double>(idx)*nSpanAngle/nShapes + nStartAngle;
awt::Size aCurrSize = aChildSize;
diff --git a/sd/qa/unit/data/pptx/smartart-center-cycle.pptx b/sd/qa/unit/data/pptx/smartart-center-cycle.pptx
new file mode 100644
index 000000000000..72f3685fb2ab
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-center-cycle.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index a1acd88cc213..1e726a5d1339 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -74,6 +74,7 @@ public:
void testInteropGrabBag();
void testBackground();
void testBackgroundDrawingmlFallback();
+ void testCenterCycle();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -110,6 +111,7 @@ public:
CPPUNIT_TEST(testInteropGrabBag);
CPPUNIT_TEST(testBackground);
CPPUNIT_TEST(testBackgroundDrawingmlFallback);
+ CPPUNIT_TEST(testCenterCycle);
CPPUNIT_TEST_SUITE_END();
};
@@ -1136,6 +1138,34 @@ void SdImportTestSmartArt::testBackgroundDrawingmlFallback()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testCenterCycle()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-center-cycle.pptx"), PPTX);
+ uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroup.is());
+
+ uno::Reference<drawing::XShapes> xGroupNested(xGroup->getByIndex(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroupNested.is());
+
+ uno::Reference<drawing::XShape> xShapeCenter(xGroupNested->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShapeA(xGroupNested->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShapeB(xGroupNested->getByIndex(2), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShapeC(xGroupNested->getByIndex(3), uno::UNO_QUERY);
+
+ uno::Reference<text::XText> xTextCenter(xShapeCenter, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xTextCenter.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("center"), xTextCenter->getString());
+
+ CPPUNIT_ASSERT_LESS(xShapeCenter->getPosition().Y, xShapeA->getPosition().Y);
+ CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().X, xShapeB->getPosition().X);
+ CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().Y, xShapeB->getPosition().Y);
+ CPPUNIT_ASSERT_LESS(xShapeCenter->getPosition().X, xShapeC->getPosition().X);
+ CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().Y, xShapeC->getPosition().Y);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();