sw/qa/extras/uiwriter/data2/tdf135061.odt |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 36 ++++++++++++++++++++++++++++++ sw/qa/inc/swmodeltestbase.hxx | 8 ++++++ 3 files changed, 44 insertions(+)
New commits: commit 87749abd33effafca577cdd01580f57c79fb836a Author: Xisco Fauli <[email protected]> AuthorDate: Wed Dec 22 16:15:20 2021 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Thu Dec 23 17:56:39 2021 +0100 tdf#135061: sw_uiwriter3: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127326 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> (cherry picked from commit 22f3f806abc0ef3ef02cd6733bdb3f950085dd17) Change-Id: Ied2ae576810a9f66e51883375959d372af59abe4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127356 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/uiwriter/data2/tdf135061.odt b/sw/qa/extras/uiwriter/data2/tdf135061.odt new file mode 100644 index 000000000000..19b3afa31e47 Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf135061.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index e7566f1e7586..f19980387677 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -612,6 +612,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139922) getParagraph(2)->getString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf135061) +{ + createDoc("tdf135061.odt"); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + Scheduler::ProcessEventsToIdle(); + + lcl_dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + for (sal_Int32 i = 0; i < 5; ++i) + { + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(20, getShapes()); + + for (sal_Int32 i = 0; i < 5; ++i) + { + // Without the fix in place, this test would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf132236) { load(DATA_DIRECTORY, "tdf132236.odt"); diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index 8d4b25f1cf32..207198f0d703 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -895,6 +895,14 @@ protected: return xCursor->getPage(); } + /// Get shape count. + int getShapes() const + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); + return xDraws->getCount(); + } + /** * Given that some problem doesn't affect the result in the importer, we * test the resulting file directly, by opening the zip file, parsing an
