sw/qa/core/doc/doc.cxx | 4 -- sw/qa/core/undo/undo.cxx | 4 -- sw/qa/extras/tiledrendering/tiledrendering.cxx | 9 ++---- sw/qa/extras/uiwriter/uiwriter3.cxx | 4 +- sw/qa/extras/uiwriter/uiwriter5.cxx | 36 ++++++------------------- sw/qa/extras/uiwriter/uiwriter6.cxx | 12 +------- sw/qa/extras/uiwriter/uiwriter8.cxx | 17 ++++------- sw/qa/inc/swmodeltestbase.hxx | 3 ++ sw/qa/uibase/shells/shells.cxx | 8 +---- sw/qa/uibase/uiview/uiview.cxx | 17 ++--------- sw/qa/unit/swmodeltestbase.cxx | 17 +++++++++++ 11 files changed, 50 insertions(+), 81 deletions(-)
New commits: commit 9937d7cdde7de5ec7588c79f92a7508a3893c31e Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Feb 23 13:53:47 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Feb 23 16:02:34 2023 +0000 SwModelTestBase: add selectShape helper See discussion in https://gerrit.libreoffice.org/c/core/+/147506 Change-Id: If3f3b471d5053dbc1bf34383e64e9672d026aaae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147515 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 39680d3a632b..d827221f2717 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -155,9 +155,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextBoxMakeFlyFrame) SwDoc* pDoc = getSwDoc(); // When cutting the textbox and pasting it to a new document: - SwView* pView = pDoc->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - pView->StopShellTimer(); + selectShape(1); SwDocShell* pDocShell = pDoc->GetDocShell(); SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx index d4156c850476..cefe4e4051dd 100644 --- a/sw/qa/core/undo/undo.cxx +++ b/sw/qa/core/undo/undo.cxx @@ -66,10 +66,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTextboxCutUndo) SwDocShell* pDocShell = pTextDoc->GetDocShell(); SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); SwDoc* pDoc = pDocShell->GetDoc(); - SwView* pView = pDoc->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - pView->StopShellTimer(); + selectShape(1); rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); pTransfer->Cut(); SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index bc11df124418..d302e6413ea7 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1818,11 +1818,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testCommentInsert) SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); SwView* pView = pDoc->GetDocShell()->GetView(); - // Select the image. - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the - // SwView ctor. - pView->StopShellTimer(); + selectShape(1); // Add a comment. uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); @@ -2988,9 +2984,10 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testClipText) CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAnchorTypes) { SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + selectShape(1); + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); SwView* pView = pXTextDocument->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); SfxItemSet aSet(pDoc->GetAttrPool(), svl::Items<FN_TOOL_ANCHOR_PAGE, FN_TOOL_ANCHOR_PAGE>); SfxBoolItem aItem(FN_TOOL_ANCHOR_PAGE); aSet.Put(aItem); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index d8ce0a3c7be8..4ea3ba0b20c2 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1783,7 +1783,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140975) createSwDoc("tdf140975.docx"); // Set the Anchor of the shape to As_Char - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); dispatchCommand(mxComponent, ".uno:SetAnchorToChar", {}); // Get the layout of the textbox @@ -1885,7 +1885,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140828) CPPUNIT_ASSERT(xShp); uno::Reference<beans::XPropertySet> ShpProps(xShp, uno::UNO_QUERY_THROW); - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); dispatchCommand(mxComponent, ".uno:SetAnchorAtChar", {}); diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 90b994ffc2f2..615f77e42f20 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1155,7 +1155,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testImageComment) pWrtShell->Delete(); // Select the image. - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + selectShape(1); // Insert a comment while the image is selected. pView->GetViewFrame().GetDispatcher()->Execute(FN_POSTIT, SfxCallMode::SYNCHRON); @@ -1179,7 +1179,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testImageComment) SfxStringItem aItem(FN_INSERT_STRING, "x"); pView->GetViewFrame().GetDispatcher()->ExecuteList(FN_INSERT_STRING, SfxCallMode::SYNCHRON, { &aItem }); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + selectShape(1); #if !defined(MACOSX) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); @@ -1248,7 +1248,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testImageCommentAtChar) SwView* pView = pDoc->GetDocShell()->GetView(); // Select the image. - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + selectShape(1); // Insert a comment while the image is selected. pView->GetViewFrame().GetDispatcher()->Execute(FN_POSTIT, SfxCallMode::SYNCHRON); @@ -1272,7 +1272,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testImageCommentAtChar) SfxStringItem aItem(FN_INSERT_STRING, "x"); pView->GetViewFrame().GetDispatcher()->ExecuteList(FN_INSERT_STRING, SfxCallMode::SYNCHRON, { &aItem }); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + selectShape(1); // Now delete the image. pView->GetViewFrame().GetDispatcher()->Execute(SID_DELETE, SfxCallMode::SYNCHRON); // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual: @@ -1318,7 +1318,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTrackImageDeletion) SwView* pView = pDoc->GetDocShell()->GetView(); // select the image - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + selectShape(1); // turn on red-lining and show changes IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); @@ -1452,10 +1452,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testShapePageMove) calcLayout(); // Select the shape. - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the - // SwView ctor. - pView->StopShellTimer(); + selectShape(1); // Move the shape down to the 2nd page. SfxInt32Item aXItem(SID_ATTR_TRANSFORM_POS_X, 4000); @@ -1684,11 +1681,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testOleSaveWhileEdit) createSwDoc("ole-save-while-edit.odt"); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - pWrtShell->GotoObj(/*bNext=*/true, GotoObjFlags::Any); - // Select the frame and switch to the frame shell. - SwView* pView = pDoc->GetDocShell()->GetView(); - pView->StopShellTimer(); + selectShape(1); // Start editing the OLE object. pWrtShell->LaunchOLEObj(); @@ -2397,10 +2391,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128335) // Select the 3rd textbox. SwView* pView = pDoc->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the - // SwView ctor. - pView->StopShellTimer(); + selectShape(1); SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); @@ -2414,11 +2405,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128335) // Paste it: this makes the 3rd textbox anchored in the 2nd one. pView->GetViewFrame().GetDispatcher()->Execute(SID_PASTE, SfxCallMode::SYNCHRON); - // Select all shapes. - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xModel->getCurrentController(), - uno::UNO_QUERY); - xSelectionSupplier->select(pXTextDocument->getDrawPages()->getByIndex(0)); + selectShape(1); // Cut them. // Without the accompanying fix in place, this test would have crashed as the textboxes were @@ -2793,10 +2780,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128603) // Select the 3rd textbox. SwView* pView = pDoc->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the - // SwView ctor. - pView->StopShellTimer(); + selectShape(1); SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 3450085e7757..5e232f006d45 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -38,7 +38,6 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> #include <o3tl/cppunittraitshelper.hxx> #include <swdtflvr.hxx> #include <comphelper/propertysequence.hxx> @@ -2264,16 +2263,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testCrashOnExit) // Get the textbox selected CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + selectShape(1); auto xShape = getShape(1); - CPPUNIT_ASSERT(xShape); - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - CPPUNIT_ASSERT(xModel); - uno::Reference<frame::XController> xController = xModel->getCurrentController(); - CPPUNIT_ASSERT(xController); - uno::Reference<view::XSelectionSupplier> xSelection(xController, uno::UNO_QUERY); - CPPUNIT_ASSERT(xSelection); - CPPUNIT_ASSERT(xSelection->select(uno::Any(xShape))); - CPPUNIT_ASSERT(xSelection->getSelection().hasValue()); uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY); // Check if the textbox is selected diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 6f659480a96c..9e5bb3856c30 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -18,7 +18,6 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> #include <com/sun/star/text/XPageCursor.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> #include <comphelper/propertysequence.hxx> #include <boost/property_tree/json_parser.hpp> #include <frameformats.hxx> @@ -1710,7 +1709,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf138130) awt::Point aPos = xShape->getPosition(); //select shape and change the anchor - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); // Without the fix in place, this test would have crashed here dispatchCommand(mxComponent, ".uno:SetAnchorToPage", {}); @@ -1735,7 +1734,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf136385) awt::Point aPos = xShape->getPosition(); //select shape and change the anchor - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); dispatchCommand(mxComponent, ".uno:SetAnchorToPage", {}); @@ -1761,7 +1760,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf145207) CPPUNIT_ASSERT_EQUAL(3, getShapes()); //select one shape and use the TAB key to iterate over the different shapes - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); for (sal_Int32 i = 0; i < 10; ++i) { @@ -1785,8 +1784,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf128782) aPos[1] = xShape2->getPosition(); //select shape 2 and move it down - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(2); pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); Scheduler::ProcessEventsToIdle(); @@ -1823,7 +1821,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf135623) aPos[1] = xShape2->getPosition(); //select shape 1 and move it down - dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + selectShape(1); pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); Scheduler::ProcessEventsToIdle(); @@ -1884,10 +1882,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf133490) aPos[1] = xShape2->getPosition(); //select shape 2 and move it to the right - SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - uno::Reference<view::XSelectionSupplier> xSelectionSupplier( - pXTextDocument->getCurrentController(), uno::UNO_QUERY); - xSelectionSupplier->select(uno::Any(getShape(2))); + selectShape(2); for (sal_Int32 i = 0; i < 5; ++i) { diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index c64a3ab13f47..ca235e722f83 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -266,6 +266,9 @@ protected: /// Get shape (counted from 1) css::uno::Reference<css::drawing::XShape> getShape(int number); + /// Select shape (counted from 1) + void selectShape(int number); + /// Get shape by name css::uno::Reference<css::drawing::XShape> getShapeByName(std::u16string_view aName); diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index dc1b0e2cee75..8f67e6821da3 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -68,10 +68,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testTdf130179) CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); SwView* pView = pDoc->GetDocShell()->GetView(); - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the - // SwView ctor. - pView->StopShellTimer(); + selectShape(1); std::unique_ptr<SfxPoolItem> pItem; pView->GetViewFrame().GetBindings().QueryState(FN_POSTIT, pItem); @@ -99,8 +96,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testShapeTextAlignment) // Start shape text edit. SwView* pView = pDoc->GetDocShell()->GetView(); // Select the shape. - pView->GetViewFrame().GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); - pView->StopShellTimer(); + selectShape(1); // Start the actual text edit. SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index 10b5eaa6eeee..5a0f1db584e2 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -261,14 +261,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testSwitchBetweenImages) pInterceptor->m_nDisabled = 0; // When selecting the first image: - uno::Reference<text::XTextGraphicObjectsSupplier> xGraphicObjectsSupplier(mxComponent, - uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xGraphicObjects( - xGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY); - pInterceptor->m_xSelectionSupplier->select(xGraphicObjects->getByIndex(0)); - Scheduler::ProcessEventsToIdle(); - SwView* pView = pDoc->GetDocShell()->GetView(); - pView->StopShellTimer(); + selectShape(1); // Then make sure the UNO command is disabled: CPPUNIT_ASSERT_EQUAL(0, pInterceptor->m_nEnabled); @@ -279,9 +272,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testSwitchBetweenImages) pInterceptor->m_nDisabled = 0; // When selecting the second image: - pInterceptor->m_xSelectionSupplier->select(xGraphicObjects->getByIndex(1)); - Scheduler::ProcessEventsToIdle(); - pView->StopShellTimer(); + selectShape(2); // Then make sure the UNO command is enabled: CPPUNIT_ASSERT_GREATEREQUAL(1, pInterceptor->m_nEnabled); @@ -292,9 +283,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testSwitchBetweenImages) pInterceptor->m_nDisabled = 0; // When selecting the first image, again (this time not changing the selection type): - pInterceptor->m_xSelectionSupplier->select(xGraphicObjects->getByIndex(0)); - Scheduler::ProcessEventsToIdle(); - pView->StopShellTimer(); + selectShape(1); // Then make sure the UNO command is disabled: CPPUNIT_ASSERT_EQUAL(0, pInterceptor->m_nEnabled); diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 1163ace48efa..2a47327287a3 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> @@ -26,6 +27,7 @@ #include <docsh.hxx> #include <rootfrm.hxx> #include <unotxdoc.hxx> +#include <view.hxx> #include <viewsh.hxx> using namespace css; @@ -407,6 +409,21 @@ uno::Reference<drawing::XShape> SwModelTestBase::getShape(int number) return xShape; } +void SwModelTestBase::selectShape(int number) +{ + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + uno::Reference<view::XSelectionSupplier> xSelectionSupplier( + pXTextDocument->getCurrentController(), uno::UNO_QUERY); + xSelectionSupplier->select(uno::Any(getShape(number))); + CPPUNIT_ASSERT(xSelectionSupplier->getSelection().hasValue()); + + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the + // SwView ctor. + pView->StopShellTimer(); +} + uno::Reference<drawing::XShape> SwModelTestBase::getShapeByName(std::u16string_view aName) { uno::Reference<drawing::XShape> xRet;