diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-09-07 19:40:42 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-09-08 09:45:20 +0200 |
commit | cdcbd61a88ea38a8db08274700901d16430c5133 (patch) | |
tree | 644fb499404ae6a5e0dfc1fbd4ce471a9e4c1d06 /sw/qa | |
parent | da4f9b77a6cd39b1ae5babdd476d1575c8b9371c (diff) |
tdf#120547: sw_ooxmlimport2: Add unittest
Change-Id: Ic3ec35740236feb62889584ef24c3d6e5a84cac4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102190
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf120547.docx | bin | 0 -> 40512 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 50 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf120547.docx b/sw/qa/extras/ooxmlimport/data/tdf120547.docx Binary files differnew file mode 100644 index 000000000000..9d3cf307272b --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf120547.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index b0d0da8ffc1b..c8f8c514c3a6 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -144,6 +144,56 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx") getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth")); } +DECLARE_OOXMLIMPORT_TEST(testTdf120547, "tdf120547.docx") +{ + uno::Reference<drawing::XShape> xGroupShape = getShape(1); + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup->getCount()); + + awt::Point aPosGroup = xGroupShape->getPosition(); + awt::Size aSizeGroup = xGroupShape->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosGroup.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosGroup.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9091), aSizeGroup.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(27940), aSizeGroup.Height); + + // Without the fix in place, this test would have failed at many places + // as the three shapes in the group would have had an incorrect position, + // an incorrect width or an incorrect height. + + uno::Reference<drawing::XShape> xShape1(xGroup->getByIndex(0), uno::UNO_QUERY_THROW); + awt::Point aPosShape1 = xShape1->getPosition(); + awt::Size aSizeShape1 = xShape1->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape1.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape1.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9066), aSizeShape1.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(27905), aSizeShape1.Height); + + uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(1), uno::UNO_QUERY_THROW); + awt::Point aPosShape2 = xShape2->getPosition(); + awt::Size aSizeShape2 = xShape2->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape2.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(20745), aPosShape2.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9066), aSizeShape2.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7195), aSizeShape2.Height); + + // The second shape is a group of 3 shapes + uno::Reference<container::XIndexAccess> xGroup2(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup2->getCount()); + + uno::Reference<drawing::XShape> xShape3(xGroup->getByIndex(2), uno::UNO_QUERY_THROW); + awt::Point aPosShape3 = xShape3->getPosition(); + awt::Size aSizeShape3 = xShape3->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape3.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPosShape3.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9091), aSizeShape3.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(8073), aSizeShape3.Height); +} + DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx") { // Font names inside a group shape were not imported |