diff options
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 29 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx | bin | 0 -> 46204 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 31 |
3 files changed, 47 insertions, 13 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index f99126be9bed..bea44faf8784 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -536,22 +536,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, const sal_Int32 nIncX = nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0); const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0); - // TODO: get values from constraints sal_Int32 nCount = rShape->getChildren().size(); double fSpace = 0.3; - awt::Size aChildSize = rShape->getSize(); - if (nDir == XML_fromL || nDir == XML_fromR) - aChildSize.Width /= (nCount + (nCount-1)*fSpace); - else if (nDir == XML_fromT || nDir == XML_fromB) - aChildSize.Height /= (nCount + (nCount-1)*fSpace); - - awt::Point aCurrPos(0, 0); - if (nIncX == -1) - aCurrPos.X = rShape->getSize().Width - aChildSize.Width; - if (nIncY == -1) - aCurrPos.Y = rShape->getSize().Height - aChildSize.Height; - // Find out which constraint is relevant for which (internal) name. LayoutPropertyMap aProperties; for (const auto& rConstraint : rConstraints) @@ -562,8 +549,24 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, LayoutProperty& rProperty = aProperties[rConstraint.msForName]; if (rConstraint.mnType == XML_w) rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor; + + // TODO: get values from differently named constraints as well + if (rConstraint.msForName == "sibTrans" && rConstraint.mnType == XML_w) + fSpace = rConstraint.mfFactor; } + awt::Size aChildSize = rShape->getSize(); + if (nDir == XML_fromL || nDir == XML_fromR) + aChildSize.Width /= (nCount + (nCount-1)*fSpace); + else if (nDir == XML_fromT || nDir == XML_fromB) + aChildSize.Height /= (nCount + (nCount-1)*fSpace); + + awt::Point aCurrPos(0, 0); + if (nIncX == -1) + aCurrPos.X = rShape->getSize().Width - aChildSize.Width; + if (nIncY == -1) + aCurrPos.Y = rShape->getSize().Height - aChildSize.Height; + // See if children requested more than 100% space in total: scale // down in that case. sal_Int32 nTotalWidth = 0; diff --git a/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx b/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx Binary files differnew file mode 100644 index 000000000000..b2ef58f0bbb3 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 1f30ba36e394..5eda257f6bf0 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -47,6 +47,7 @@ public: void testVertialBracketList(); void testTableList(); void testAccentProcess(); + void testContinuousBlockProcess(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -76,6 +77,7 @@ public: CPPUNIT_TEST(testVertialBracketList); CPPUNIT_TEST(testTableList); CPPUNIT_TEST(testAccentProcess); + CPPUNIT_TEST(testContinuousBlockProcess); CPPUNIT_TEST_SUITE_END(); }; @@ -619,6 +621,35 @@ void SdImportTestSmartArt::testAccentProcess() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testContinuousBlockProcess() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx"), + PPTX); + uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xGroup.is()); + // 2 children: background, foreground. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup->getCount()); + + uno::Reference<drawing::XShapes> xLinear(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xLinear.is()); + // 3 children: A, B and C. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xLinear->getCount()); + + uno::Reference<text::XText> xA(xLinear->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xA.is()); + CPPUNIT_ASSERT_EQUAL(OUString("A"), xA->getString()); + uno::Reference<drawing::XShape> xAShape(xA, uno::UNO_QUERY); + CPPUNIT_ASSERT(xAShape.is()); + // Without the accompanying fix in place, this test would have failed: the + // theoretically correct value is 5462 mm100 (16933 is the total width, and + // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value + // was 4703 and the new one is 5461. + CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(5000), xAShape->getSize().Width); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); |