Kaydet (Commit) c91302d8 authored tarafından Grzegorz Araminowicz's avatar Grzegorz Araminowicz Kaydeden (comit) Miklos Vajna

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: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 15d0cc8c
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment