sd/qa/unit/data/pptx/tdf149551_SmartArt_Gear.pptx    |binary
 sd/qa/unit/data/pptx/tdf149551_SmartArt_Pie.pptx     |binary
 sd/qa/unit/data/pptx/tdf149551_SmartArt_Pyramid.pptx |binary
 sd/qa/unit/data/pptx/tdf149551_SmartArt_Venn.pptx    |binary
 sd/qa/unit/import-tests-smartart.cxx                 |  106 +++++++++++++++++++
 5 files changed, 106 insertions(+)

New commits:
commit 2f3b87d18a688b022a18a8b20b69b10cd6af7748
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Wed Jul 20 13:16:04 2022 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Wed Jul 20 20:48:22 2022 +0200

    tdf#149551 Unit tests for insets in SmartArt
    
    This is followup to commit 7e23cbdb. That commit contains for several
    types of shapes a correction of the position and size of the text area
    rectangle.
    That commit fixes bugs tdf#59802, tdf#136234, tdf#118009 and duplicate
    tdf#142841 were the here tested shape types are involved.
    
    Change-Id: I7c8c9676cf3dbdcc3f91fe25d75901b63d0ca4da
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137264
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>

diff --git a/sd/qa/unit/data/pptx/tdf149551_SmartArt_Gear.pptx 
b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Gear.pptx
new file mode 100644
index 000000000000..2b4781972a04
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Gear.pptx 
differ
diff --git a/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pie.pptx 
b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pie.pptx
new file mode 100644
index 000000000000..d7fa44431597
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pie.pptx 
differ
diff --git a/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pyramid.pptx 
b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pyramid.pptx
new file mode 100644
index 000000000000..4e9157e82ac3
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pyramid.pptx differ
diff --git a/sd/qa/unit/data/pptx/tdf149551_SmartArt_Venn.pptx 
b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Venn.pptx
new file mode 100644
index 000000000000..12e033a8b903
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149551_SmartArt_Venn.pptx 
differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index e41a635dff8b..8c28518c3b70 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -17,6 +17,7 @@
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 
+#include <svx/svdoashp.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdogrp.hxx>
 #include <comphelper/sequenceashashmap.hxx>
@@ -119,6 +120,10 @@ public:
     void testAutofitSync();
     void testSnakeRows();
     void testCompositeInferRight();
+    void testTdf149551Pie();
+    void testTdf149551Pyramid();
+    void testTdf149551Venn();
+    void testTdf149551Gear();
 
     CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -174,6 +179,10 @@ public:
     CPPUNIT_TEST(testAutofitSync);
     CPPUNIT_TEST(testSnakeRows);
     CPPUNIT_TEST(testCompositeInferRight);
+    CPPUNIT_TEST(testTdf149551Pie);
+    CPPUNIT_TEST(testTdf149551Pyramid);
+    CPPUNIT_TEST(testTdf149551Venn);
+    CPPUNIT_TEST(testTdf149551Gear);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1844,6 +1853,103 @@ void SdImportTestSmartArt::testCompositeInferRight()
     xDocShRef->DoClose();
 }
 
+void SdImportTestSmartArt::testTdf149551Pie()
+{
+    // The file contains a diagram of type "Basic Pie".
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pie.pptx"),
 PPTX);
+    uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+    // shape at index 0 is the background shape
+    uno::Reference<drawing::XShape> xShape = getChildShape(xGroup, 1);
+    CPPUNIT_ASSERT(xShape.is());
+    auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
+    CPPUNIT_ASSERT(pCustomShape);
+    tools::Rectangle aTextRect;
+    pCustomShape->TakeTextAnchorRect(aTextRect);
+    // without fix the text area rectangle had LT [7787,3420] and 
RB[16677,12312]. The values from
+    // txXfrm were ignored.
+    // The used tolerance is estimated.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(12658), 
sal_Int32(aTextRect.Left()), 4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5073), sal_Int32(aTextRect.Top()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15627), 
sal_Int32(aTextRect.Right()), 4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7990), 
sal_Int32(aTextRect.Bottom()), 4);
+
+    xDocShRef->DoClose();
+}
+
+void SdImportTestSmartArt::testTdf149551Pyramid()
+{
+    // The file contains a diagram of type "Basic Pyramid".
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149551_SmartArt_Pyramid.pptx"),
+        PPTX);
+    uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+    // shape at index 0 is the background shape
+    uno::Reference<drawing::XShape> xShape = getChildShape(xGroup, 1);
+    CPPUNIT_ASSERT(xShape.is());
+    auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
+    CPPUNIT_ASSERT(pCustomShape);
+    tools::Rectangle aTextRect;
+    pCustomShape->TakeTextAnchorRect(aTextRect);
+    // without fix the text area rectangle had LT [9369,2700] and 
RB[14632,6185]. The values from
+    // txXfrm were ignored.
+    // The used tolerance is estimated.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7591), sal_Int32(aTextRect.Left()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1515), sal_Int32(aTextRect.Top()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16410), 
sal_Int32(aTextRect.Right()), 4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7370), 
sal_Int32(aTextRect.Bottom()), 4);
+
+    xDocShRef->DoClose();
+}
+
+void SdImportTestSmartArt::testTdf149551Venn()
+{
+    // The file contains a diagram of type "Stacked Venn".
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149551_SmartArt_Venn.pptx"),
 PPTX);
+    uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+    // shape at index 0 is the background shape
+    uno::Reference<drawing::XShape> xShape = getChildShape(xGroup, 1);
+    CPPUNIT_ASSERT(xShape.is());
+    auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
+    CPPUNIT_ASSERT(pCustomShape);
+    tools::Rectangle aTextRect;
+    pCustomShape->TakeTextAnchorRect(aTextRect);
+    // without fix the text area rectangle had LT [6865,3396] and 
RB[17136,4600]. The values from
+    // txXfrm were ignored.
+    // The used tolerance is estimated.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(8772), sal_Int32(aTextRect.Left()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1834), sal_Int32(aTextRect.Top()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15229), 
sal_Int32(aTextRect.Right()), 4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(6162), 
sal_Int32(aTextRect.Bottom()), 4);
+
+    xDocShRef->DoClose();
+}
+
+void SdImportTestSmartArt::testTdf149551Gear()
+{
+    // The file contains a diagram of type "Gear".
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149551_SmartArt_Gear.pptx"),
 PPTX);
+    uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+    // shape at index 0 is the background shape
+    uno::Reference<drawing::XShape> xShape = getChildShape(xGroup, 1);
+    CPPUNIT_ASSERT(xShape.is());
+    auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
+    CPPUNIT_ASSERT(pCustomShape);
+    tools::Rectangle aTextRect;
+    pCustomShape->TakeTextAnchorRect(aTextRect);
+    // without fix the text area rectangle had LT [4101,1014] and 
RB[8019,4932]. The values from
+    // txXfrm were ignored.
+    // The used tolerance is estimated.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5501), sal_Int32(aTextRect.Left()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect.Top()), 
4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(11000), 
sal_Int32(aTextRect.Right()), 4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(9999), 
sal_Int32(aTextRect.Bottom()), 4);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to