diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-05-14 15:42:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-15 08:42:04 +0200 |
commit | 36e62098c8c541c4a3fb63eced591cf29ac56e4a (patch) | |
tree | 2a8b87b9049338819e0cef1997d00fac3b56d135 /sw/qa/extras/ooxmlimport | |
parent | 44006d2fdc67c1b2ff68407b16b4b4939012282c (diff) |
CppUnittest: sw: simplify code. use getShapes and getShape
Change-Id: I494349b99a122f67ed1f2881faf1a37e4358c55b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94214
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 24 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 8 |
2 files changed, 9 insertions, 23 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 5cf893bb0937..e08fadcc6b70 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -503,10 +503,7 @@ DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx") * Another problem tested with this document is the unnecessary loading of the shapes * anchored to a discarded header or footer */ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage(); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), drawPage->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); } DECLARE_OOXMLIMPORT_TEST(testN779627b, "n779627b.docx") @@ -566,12 +563,9 @@ DECLARE_OOXMLIMPORT_TEST(testWordArtResizing, "WordArt.docx") /* The Word-Arts and watermarks were getting resized automatically, It was as if they were getting glued to the fallback geometry(the sdrObj) and were getting bound to the font size. The test-case ensures the original height and width of the word-art is not changed while importing*/ + CPPUNIT_ASSERT_EQUAL(1, getShapes()); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); - - uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(10105), xShape->getSize().Width); CPPUNIT_ASSERT_EQUAL(sal_Int32(4755), xShape->getSize().Height); } @@ -589,17 +583,15 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx") * xray ThisComponent.DrawPage(1).getByIndex(0).Position 'x: 1272, y: 2286 * xray ThisComponent.DrawPage(1).getByIndex(0).Size 'width: 10160, height: 0 */ - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDrawPage->getCount()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); - uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2656), xShape->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(339), xShape->getPosition().Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(3270), xShape->getSize().Width); CPPUNIT_ASSERT_EQUAL(sal_Int32(1392), xShape->getSize().Height); - uno::Reference<drawing::XShapes> xGroupShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xGroupShape(getShape(2), uno::UNO_QUERY); xShape.set(xGroupShape->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1272), xShape->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(2286), xShape->getPosition().Y); @@ -811,9 +803,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx") uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL_MESSAGE("# of tables", sal_Int32(1), xTables->getCount() ); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("# of frames/shapes", sal_Int32(0), xDraws->getCount() ); + CPPUNIT_ASSERT_EQUAL_MESSAGE("# of frames/shapes", 0, getShapes() ); CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() ); } diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 6047a97f7c8c..be99a8b9c47a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -414,10 +414,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf121804, "tdf121804.docx") DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx") { - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); // This was 1, multi-page table was imported as a floating one. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); } DECLARE_OOXMLIMPORT_TEST(testTdf116486, "tdf116486.docx") @@ -443,9 +441,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf115094, "tdf115094.docx") { // anchor of graphic has to be the text in the text frame // xray ThisComponent.DrawPage(1).Anchor.Text - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<text::XTextContent> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + uno::Reference<text::XTextContent> xShape(getShape(2), uno::UNO_QUERY); uno::Reference<text::XTextRange> xText1 = xShape->getAnchor()->getText(); // xray ThisComponent.TextTables(0).getCellByName("A1") |