sw/qa/extras/uiwriter/uiwriter.cxx | 20 +-- sw/qa/extras/uiwriter/uiwriter2.cxx | 42 ++----- sw/qa/extras/uiwriter/uiwriter3.cxx | 205 ++++++++---------------------------- sw/qa/extras/uiwriter/uiwriter5.cxx | 3 sw/qa/extras/uiwriter/uiwriter8.cxx | 42 +------ 5 files changed, 79 insertions(+), 233 deletions(-)
New commits: commit ddf81bb6371d28adbe3080a4c0997f822178885f Author: Xisco Fauli <[email protected]> AuthorDate: Tue Feb 28 10:44:12 2023 +0100 Commit: Noel Grandin <[email protected]> CommitDate: Sat Mar 18 16:19:16 2023 +0000 CppunitTest_sw_uiwriter*: use uno commands for copy/cut/paste In order to unify the code and to make sure Scheduler::ProcessEventsToIdle() is always called afterwards See 9027920783dd04db925c41b559abe6442cedf39e "improve reliability of CppunitTest_sw_uiwriter3 something in the paste stuff seems to need UI events to be processed" Initially, these uno commands were replaced in 9d08a0cea018226ce155104d8df146dc2a412aac "avoid uno:Paste in tests clipboard is a shared resource (except for svp) so interleaved tests are not guaranteed to get out what they put in" However, this is no longer a problem since e25ba7dc57229d1cb9794abd1ca23c0d87ebecb3 "use a dummy clipboard when running unit tests so the multiple unit tests don't stomp on each other. This fixes a couple of things in my earlier attempt (*) actually set the env variable on Windows (*) don't use a global variable to test the env var, because that variable might be initialised BEFORE the env var is actually set" Change-Id: Ifae66e522b0a1e57fa1fa6d16980c6491b397f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147957 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149001 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index be0cb790990a..47df30709462 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -225,8 +225,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149595) { pWrtShell->Down(false); pWrtShell->EndPara(/*bSelect=*/true); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // one shape is anchored in the middle, others at the start/end/at-para CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs() == nullptr); @@ -234,8 +233,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149595) CPPUNIT_ASSERT_EQUAL(size_t(3), pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetNext()->GetDrawObjs()->size()); pWrtShell->Up(false); - TransferableDataHelper aHelper(pTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs() != nullptr); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs()->size()); @@ -257,8 +255,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149595) pWrtShell->Down(false); pWrtShell->SttPara(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/true); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs() == nullptr); CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetNext()->GetDrawObjs() != nullptr); @@ -266,8 +263,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149595) CPPUNIT_ASSERT_EQUAL(size_t(3), pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetNext()->GetDrawObjs()->size()); pWrtShell->Up(false); - TransferableDataHelper aHelper(pTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs() != nullptr); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs()->size()); @@ -314,16 +310,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149548) } } - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); - TransferableDataHelper aHelper(pTransfer); // this was a use-after-free on nodes deleted by Copy - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testBookmarkCopy) diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 622512119faf..4292edfb2fdb 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -157,8 +157,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); pWrtShell->EndPara(/*bSelect=*/true); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Go to the second paragraph, assert that we have margins as direct // formatting. @@ -169,8 +168,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) // Make sure that direct formatting is preserved during paste. pWrtShell->EndPara(/*bSelect=*/false); - TransferableDataHelper aHelper(pTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); aSet.ClearItem(); pWrtShell->GetCurAttr(aSet); // This failed, direct formatting was lost. @@ -419,7 +417,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf136704) CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf134250) { createSwDoc("tdf134250.fodt"); - SwDoc* pDoc = getSwDoc(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), @@ -441,16 +438,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf134250) dispatchCommand(mxComponent, ".uno:SelectAll", {}); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - // .uno:Copy without touching shared clipboard - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); - - // .uno:Paste without touching shared clipboard - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Copy", {}); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); @@ -1347,8 +1337,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819) SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // remaining paragraph keeps its original style CPPUNIT_ASSERT_EQUAL(OUString("Standard"), @@ -1394,8 +1383,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819_keep_numbering_with_Undo) pWrtShell->Down(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // solved problem: changing paragraph style after deletion CPPUNIT_ASSERT_EQUAL(OUString("Standard"), @@ -1489,8 +1477,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, /*bBasicCall=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // solved problem: changing paragraph style after deletion CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), @@ -1592,8 +1579,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Reject) pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, /*bBasicCall=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // solved problem: changing paragraph style after deletion CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), @@ -2022,8 +2008,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571) pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // second paragraph changes its style in "Show changes" mode CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), @@ -2056,8 +2041,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf144058) pWrtShell->Down(/*bSelect=*/true); pWrtShell->Down(/*bSelect=*/true); pWrtShell->Down(/*bSelect=*/true); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // accept all: tables are deleted dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); @@ -2109,8 +2093,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119019) pWrtShell->Down(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/false); pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // check tracked text deletion CPPUNIT_ASSERT_EQUAL(OUString("tellus."), getRun(getParagraph(2), 3)->getString()); @@ -2150,8 +2133,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119824) pWrtShell->Down(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/false); pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 5, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // check tracking of the new text deletion CPPUNIT_ASSERT_EQUAL(OUString("orci."), getRun(getParagraph(3), 7)->getString()); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 4ea3ba0b20c2..f81232ddca62 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -532,22 +532,18 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf148868) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382) { createSwDoc("tdf129382.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(8, getShapes()); CPPUNIT_ASSERT_EQUAL(2, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(3, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(8, getShapes()); CPPUNIT_ASSERT_EQUAL(2, getPages()); @@ -563,20 +559,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135662) { createSwDoc("tdf135662.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(2, getShapes()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); // Without the fix in place, this test would have failed with // - Expected: 2 @@ -587,8 +579,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135662) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134227) { createSwDoc("tdf134227.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(4, getShapes()); @@ -596,13 +586,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134227) dispatchCommand(mxComponent, ".uno:SelectAll", {}); // Without the fix in place, it would have crashed here - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(4, getShapes()); @@ -629,8 +617,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139638) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412) { createSwDoc("tdf135412.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(4, getShapes()); uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); @@ -638,13 +624,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(4, getShapes()); @@ -756,8 +740,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135061) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132911) { createSwDoc("tdf132911.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -767,23 +749,18 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132911) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(4, getShapes()); // Without the fix in place, it would have crashed here - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(8, getShapes()); @@ -795,13 +772,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132911) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(4, getShapes()); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(8, getShapes()); @@ -978,16 +953,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135056) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132597) { createSwDoc("tdf132597.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Paste special as RTF uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -1005,15 +977,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132597) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139737) { createSwDoc("tdf139737.fodt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Paste special as RTF uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -1133,8 +1102,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147206) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144840) { createSwDoc("tdf144840.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(1, getPages()); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); @@ -1144,8 +1111,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144840) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); @@ -1173,15 +1139,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144840) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131963) { createSwDoc("tdf131963.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(11, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Paste special as RTF uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -1198,15 +1161,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131963) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132596) { createSwDoc("tdf132596.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(2, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Paste special as RTF uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -1223,30 +1183,26 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132596) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126626) { createSwDoc("tdf126626.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(2, getShapes()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); CPPUNIT_ASSERT_EQUAL(2, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(2, getShapes()); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(4, getShapes()); dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(2, getShapes()); // without the fix, it crashes - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(4, getShapes()); } @@ -1276,23 +1232,18 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133967) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132187) { createSwDoc("tdf132187.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(1, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); dispatchCommand(mxComponent, ".uno:GoToEndOfDoc", {}); - TransferableDataHelper aHelper(xTransfer); for (sal_Int32 i = 0; i < 10; ++i) { - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); } //without the fix in place, this test would fail with: @@ -1365,13 +1316,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135733) pWrtShell->Down(/*bSelect=*/true); pWrtShell->Down(/*bSelect=*/true); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); pWrtShell->SttPg(/*bSelect=*/false); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(1, getPages()); @@ -1394,20 +1343,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135733) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128739) { createSwDoc("tdf128739.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(OUString("Fehler: Verweis nicht gefunden"), getParagraph(1)->getString()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(OUString("Fehler: Verweis nicht gefunden"), getParagraph(1)->getString()); // without the fix, it crashes @@ -1418,20 +1363,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128739) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf124722) { createSwDoc("tdf124722.rtf"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(22, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); CPPUNIT_ASSERT_EQUAL(22, getPages()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(43, getPages()); dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -1629,8 +1570,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133990) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126504) { createSwDoc("tdf126504.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -1642,14 +1581,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126504) dispatchCommand(mxComponent, ".uno:SelectAll", {}); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); dispatchCommand(mxComponent, ".uno:GoToEndOfPage", {}); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xIndexAccess->getCount()); CPPUNIT_ASSERT_EQUAL(1, getPages()); @@ -1674,8 +1610,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126504) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133982) { createSwDoc("tdf133982.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -1687,21 +1621,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133982) dispatchCommand(mxComponent, ".uno:SelectAll", {}); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); //Without the fix in place, it would have crashed here - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134253) { createSwDoc("tdf134253.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -1714,10 +1644,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134253) dispatchCommand(mxComponent, ".uno:SelectAll", {}); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); //Without the fix in place, it would have crashed here dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -1973,8 +1901,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf124397) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf108124) { createSwDoc("tdf108124.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY); @@ -1985,11 +1911,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf108124) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); @@ -2021,8 +1945,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975) // This test also covers tdf#117185 tdf#110442 createSwDoc("tdf107975.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, @@ -2039,15 +1961,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); //Position the mouse cursor (caret) after "ABC" below the blue image dispatchCommand(mxComponent, ".uno:GoRight", {}); - { - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - } + dispatchCommand(mxComponent, ".uno:Paste", {}); // without the fix, it crashes CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); @@ -2076,15 +1994,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - xTransfer.set(new SwTransferable(*pWrtShell)); - xTransfer->Copy(); + dispatchCommand(mxComponent, ".uno:Copy", {}); //Position the mouse cursor (caret) after "ABC" below the blue image dispatchCommand(mxComponent, ".uno:GoRight", {}); - { - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - } + dispatchCommand(mxComponent, ".uno:Paste", {}); // without the fix, it crashes CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); @@ -2207,15 +2121,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130746) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129805) { createSwDoc("tdf129805.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(OUString("x"), getParagraph(1)->getString()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); // without the fix in place, it would crash here - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString()); dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -2225,26 +2136,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129805) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130685) { createSwDoc("tdf130685.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT_EQUAL(2, getPages()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(1, getPages()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); // Without fix in place, this test would have failed with: //- Expected: 2 //- Actual : 4 - Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(2, getPages()); dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -2290,8 +2195,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf104649) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134931) { createSwDoc("tdf134931.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -2301,17 +2204,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134931) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Copy", {}); dispatchCommand(mxComponent, ".uno:GoDown", {}); - TransferableDataHelper aHelper(xTransfer); for (sal_Int32 i = 0; i < 10; ++i) { - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); } CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xIndexAccess->getCount()); @@ -2327,8 +2226,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134931) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680) { createSwDoc("tdf130680.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -2340,14 +2237,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680) rtl::Reference<SwDoc> xClpDoc(new SwDoc()); xClpDoc->SetClipBoard(true); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); // without the fix, it crashes - xTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); xClpDoc.clear(); diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index baa7ef0c06c4..b7fcbd757ab1 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1078,8 +1078,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf125310) pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); - rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); - pTransfer->Cut(); + dispatchCommand(mxComponent, ".uno:Cut", {}); // copied paragraph style CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 519a14f736fc..ddce6feb0953 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -65,8 +65,6 @@ public: CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf131684) { createSwDoc("tdf131684.docx"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), @@ -78,16 +76,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf131684) dispatchCommand(mxComponent, ".uno:SelectAll", {}); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); // without the fix, it crashes @@ -125,7 +120,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf132744) { createSwDoc("tdf132744.odt"); SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); // disable change tracking to cut the table pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete @@ -138,15 +132,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf132744) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); //Without the fix in place, the image wouldn't be pasted CPPUNIT_ASSERT_EQUAL(1, getShapes()); @@ -1162,10 +1152,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf134626) dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Copy(); - Scheduler::ProcessEventsToIdle(); - TransferableDataHelper aHelper(xTransfer); + dispatchCommand(mxComponent, ".uno:Copy", {}); // Create a new document createSwDoc(); @@ -1176,13 +1163,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf134626) // Without the fix in place, this test would have crashed here for (sal_Int32 i = 0; i < 5; ++i) { - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(OUString("Apple"), getParagraph(1)->getString()); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(OUString("AppleApple"), getParagraph(1)->getString()); @@ -1773,28 +1758,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf135623) CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf133490) { createSwDoc("tdf133490.odt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT_EQUAL(1, getShapes()); dispatchCommand(mxComponent, ".uno:SelectAll", {}); - rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); - xTransfer->Cut(); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(0, getShapes()); - TransferableDataHelper aHelper(xTransfer); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(1, getShapes()); - SwTransferable::Paste(*pWrtShell, aHelper); - Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(2, getShapes());
