From c6965c5bcc95430c2a2d01051791d23f2c2f5a5b Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Thu, 21 Jul 2022 10:51:47 +0200 Subject: tdf#145528 add round1Rect to SmartArt text area corrections Some SmartArt types use text area rectangles different from defaults. The new rectangle is available in element . This patch adds the needed corrections for type round1Rect. It is four times used in SmartArt 'Titled Matrix' with rotations 0deg, 90deg, 180deg and 270deg. Change-Id: I8c82b446a982ad93026e976b2a47d509b858858d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137287 Tested-by: Jenkins Reviewed-by: Regina Henschel --- .../unit/data/pptx/tdf145528_SmartArt_Matrix.pptx | Bin 0 -> 26693 bytes sd/qa/unit/import-tests-smartart.cxx | 36 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx (limited to 'sd/qa') diff --git a/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx b/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx new file mode 100644 index 000000000000..b48cc223cf0e Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 8c28518c3b70..1d2728b5bee4 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -124,6 +124,7 @@ public: void testTdf149551Pyramid(); void testTdf149551Venn(); void testTdf149551Gear(); + void testTdf145528Matrix(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -183,6 +184,7 @@ public: CPPUNIT_TEST(testTdf149551Pyramid); CPPUNIT_TEST(testTdf149551Venn); CPPUNIT_TEST(testTdf149551Gear); + CPPUNIT_TEST(testTdf145528Matrix); CPPUNIT_TEST_SUITE_END(); }; @@ -1950,6 +1952,40 @@ void SdImportTestSmartArt::testTdf149551Gear() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testTdf145528Matrix() +{ + // The file contains a diagram of type "Titled Matrix". Such is build from shapes of type + // 'round1Rect'. + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx"), PPTX); + uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + // expected values + sal_Int32 nLeft[]{ 4001, 12001, 12001, 18501 }; + sal_Int32 nTop[]{ 9999, 1999, 12499, 5999 }; + // nWidth = 10292, nHeight = 4499 + // Without the fix in place the values were + // nLeft {2001, 12001, 12001, 22001} + // nTop {7999. 1999, 13999, 7999} + // nWidth {6000, 10000, 10000, 6000} + // nHeight {10000, 6000, 6000, 10000} + tools::Rectangle aTextRect; + for (auto i : { 1, 2, 3, 4 }) // shape at index 0 is the background shape + { + uno::Reference xShape = getChildShape(xGroup, i); + CPPUNIT_ASSERT(xShape.is()); + auto pCustomShape + = dynamic_cast(SdrObject::getSdrObjectFromXShape(xShape)); + CPPUNIT_ASSERT(pCustomShape); + pCustomShape->TakeTextAnchorRect(aTextRect); + CPPUNIT_ASSERT_DOUBLES_EQUAL(nLeft[i - 1], sal_Int32(aTextRect.Left()), 4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(nTop[i - 1], sal_Int32(aTextRect.Top()), 4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(10293), sal_Int32(aTextRect.GetWidth()), 4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect.GetHeight()), 4); + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit