diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-23 13:53:47 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-03-16 20:57:56 +0000 |
commit | 5114eee1158623f933dfb214e26631fedd2ca7bd (patch) | |
tree | 1686e229b88e8399e261978048cd333e7174d1cd /sw | |
parent | e5ee1a4653e508a943d5c458143f7ac85dbb1cd2 (diff) |
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 <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148985
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/doc/doc.cxx | 4 | ||||
-rw-r--r-- | sw/qa/core/undo/undo.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter5.cxx | 36 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter6.cxx | 12 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter8.cxx | 17 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 3 | ||||
-rw-r--r-- | sw/qa/uibase/shells/shells.cxx | 8 | ||||
-rw-r--r-- | sw/qa/uibase/uiview/uiview.cxx | 17 | ||||
-rw-r--r-- | sw/qa/unit/swmodeltestbase.cxx | 17 |
11 files changed, 50 insertions, 81 deletions
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index cec9525eb9e8..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 154226d2129f..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 40d8316b857b..42e11ed6ca3d 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1776,11 +1776,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(); @@ -2946,9 +2942,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 57c3d724887b..baa7ef0c06c4 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1170,7 +1170,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); @@ -1194,7 +1194,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()); @@ -1263,7 +1263,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); @@ -1287,7 +1287,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: @@ -1333,7 +1333,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()); @@ -1467,10 +1467,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); @@ -1699,11 +1696,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(); @@ -2412,10 +2406,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); @@ -2429,11 +2420,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 @@ -2808,10 +2795,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 62ddb4b2463e..ea9617fed283 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> @@ -2262,16 +2261,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 be886297a4e8..519a14f736fc 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> @@ -1634,7 +1633,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", {}); @@ -1659,7 +1658,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", {}); @@ -1685,7 +1684,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) { @@ -1709,8 +1708,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(); @@ -1747,7 +1745,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(); @@ -1808,10 +1806,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 dda083f76539..62d9ad8eda25 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 a9625ad9a59f..79b3c49fb30f 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -63,10 +63,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); @@ -94,8 +91,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 05918c52397a..2e500b0bb8dc 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; |