sw/qa/core/doc/doc.cxx                           |   15 
 sw/qa/core/edit/edit.cxx                         |    3 
 sw/qa/core/txtnode/txtnode.cxx                   |    3 
 sw/qa/core/undo/undo.cxx                         |    2 
 sw/qa/core/unocore/unocore.cxx                   |    3 
 sw/qa/extras/autocorrect/autocorrect.cxx         |  149 +++------
 sw/qa/extras/mailmerge/mailmerge2.cxx            |    9 
 sw/qa/extras/odfexport/odfexport2.cxx            |    3 
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx       |    6 
 sw/qa/extras/tiledrendering/tiledrendering.cxx   |  364 ++++++++++-------------
 sw/qa/extras/tiledrendering2/tiledrendering2.cxx |   25 -
 sw/qa/extras/uiwriter/uiwriter.cxx               |   13 
 sw/qa/extras/uiwriter/uiwriter2.cxx              |   30 -
 sw/qa/extras/uiwriter/uiwriter3.cxx              |   35 +-
 sw/qa/extras/uiwriter/uiwriter4.cxx              |   52 +--
 sw/qa/extras/uiwriter/uiwriter5.cxx              |   26 -
 sw/qa/extras/uiwriter/uiwriter6.cxx              |  133 +++-----
 sw/qa/extras/uiwriter/uiwriter7.cxx              |   10 
 sw/qa/extras/uiwriter/uiwriter8.cxx              |   37 +-
 sw/qa/extras/uiwriter/uiwriter9.cxx              |   52 +--
 sw/qa/extras/unowriter/unowriter.cxx             |    5 
 sw/qa/extras/ww8import/ww8import.cxx             |    6 
 sw/qa/inc/swmodeltestbase.hxx                    |    9 
 sw/qa/uibase/shells/shells.cxx                   |    3 
 sw/qa/uibase/uiview/uiview.cxx                   |    3 
 sw/qa/uibase/uno/uno.cxx                         |   24 -
 sw/qa/unit/swmodeltestbase.cxx                   |   30 +
 27 files changed, 465 insertions(+), 585 deletions(-)

New commits:
commit fc2e8daa4bdcac9ce79400269baee8e3d59f9e3d
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Oct 29 17:20:18 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Oct 30 00:30:53 2024 +0100

    sw/qa: use more getSwDocShell()
    
    Change-Id: I4df04a94bb63709e43fb887972fcab9756f6233b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175797
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 2484d52c548f..eb7502025b15 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -317,8 +317,8 @@ void SwTiledRenderingTest::callbackImpl(int nType, const 
char* pPayload)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testRegisterCallback)
 {
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     // Insert a character at the beginning of the document.
     pWrtShell->Insert(u"x"_ustr);
@@ -332,8 +332,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRegisterCallback)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPostKeyEvent)
 {
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
     // Did we manage to go after the first character?
@@ -347,7 +347,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPostKeyEvent)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPostMouseEvent)
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
     // Did we manage to go after the first character?
@@ -365,7 +365,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPostMouseEvent)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSetTextSelection)
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Move the cursor into the second word.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 5, 
/*bBasicCall=*/false);
     // Create a selection on the word.
@@ -393,7 +393,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetTextSelection)
     // No crash, just empty output for unexpected mime type.
     CPPUNIT_ASSERT_EQUAL(OString(), 
apitest::helper::transferable::getTextSelection(pXTextDocument->getSelection(), 
"foo/bar"_ostr));
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Move the cursor into the first word.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, 
/*bBasicCall=*/false);
     // Create a selection by on the word.
@@ -424,7 +424,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetTextSelectionLineLimit)
 
     SwXTextDocument* pXTextDocument = createDoc("estonian.odt");
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Move the cursor into the first word.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, 
/*bBasicCall=*/false);
     // Create a selection.
@@ -466,7 +466,7 @@ Heading on second page");
 
     SwXTextDocument* pXTextDocument = createDoc("multiline.odt");
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Create a selection.
     pWrtShell->SelAll();
 
@@ -484,7 +484,7 @@ Heading on second page");
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSetGraphicSelection)
 {
     SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     pWrtShell->SelectObj(Point(), 0, pObject);
@@ -508,7 +508,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSetGraphicSelection)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testResetSelection)
 {
     SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Select one character.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
@@ -535,7 +535,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testResetSelection)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testInsertShape)
 {
     SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
 
     pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
     comphelper::dispatchCommand(u".uno:BasicShapes.circle"_ustr, 
uno::Sequence<beans::PropertyValue>());
@@ -563,8 +563,8 @@ static void lcl_search(bool bBackward)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearch)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     SwNodeOffset nNode = 
pWrtShell->getShellCursor(false)->Start()->GetNode().GetIndex();
 
@@ -603,8 +603,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearch)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchViewArea)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Go to the second page, 1-based.
     pWrtShell->GotoPage(2, false);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
@@ -628,8 +628,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSearchViewArea)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchTextFrame)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence(
                 {
@@ -643,8 +643,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSearchTextFrame)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchTextFrameWrapAround)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence(
                 {
@@ -662,7 +662,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDocumentSizeChanged)
 {
     // Get the current document size.
     SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     Size aSize = pXTextDocument->getDocumentSize();
 
@@ -677,8 +677,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDocumentSizeChanged)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchAll)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence(
                 {
@@ -695,8 +695,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchAll)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSearchAllNotifications)
 {
-    SwXTextDocument* pXTextDocument = createDoc("search.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("search.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     // Reset notification counter before search.
     m_nSelectionBeforeSearchResult = 0;
@@ -723,7 +723,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPageDownInvalidation)
                 {".uno:HideWhitespace", uno::Any(true)},
                 }));
     pXTextDocument->initializeForTiledRendering(aPropertyValues);
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     comphelper::dispatchCommand(u".uno:PageDown"_ustr, 
uno::Sequence<beans::PropertyValue>());
 
@@ -981,13 +981,13 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testMissingInvalidation)
 
     // First view: put the cursor into the first word.
     SfxLokHelper::setView(nView1);
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
 
     // Second view: select the first word.
     SfxLokHelper::setView(nView2);
-    CPPUNIT_ASSERT(pXTextDocument->GetDocShell()->GetWrtShell() != pWrtShell);
-    pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(getSwDocShell()->GetWrtShell() != pWrtShell);
+    pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
     pWrtShell->SelWrd();
 
@@ -1004,7 +1004,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testMissingInvalidation)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testViewCursors)
 {
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+    createDoc("dummy.fodt");
     ViewCallback aView1;
     SfxLokHelper::createView();
     ViewCallback aView2;
@@ -1023,7 +1023,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testViewCursors)
     aView1.m_bViewSelectionSet = false;
     aView2.m_bOwnSelectionSet = false;
     aView2.m_bViewSelectionSet = false;
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Move the cursor into the second word.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 5, 
/*bBasicCall=*/false);
     // Create a selection on the word.
@@ -1048,7 +1048,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeViewCursors)
     SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
     ViewCallback aView2;
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
 
     // Start shape text in the second view.
     SdrPage* pPage = 
pWrtShell2->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
@@ -1088,7 +1088,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testViewCursorVisibility)
 
     // Click on the shape in the second view.
     aView1.m_bViewCursorVisible = true;
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     Point aCenter = pObject->GetSnapRect().Center();
@@ -1110,7 +1110,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testViewCursorCleanup)
         ViewCallback aView2;
 
         // Click on the shape in the second view.
-        SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+        SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
         SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
         SdrObject* pObject = pPage->GetObj(0);
         Point aCenter = pObject->GetSnapRect().Center();
@@ -1140,7 +1140,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testViewLock)
 
     // Begin text edit in the second view and assert that the first gets a lock
     // notification.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -1164,7 +1164,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTextEditViewInvalidations)
     ViewCallback aView2;
 
     // Begin text edit in the second view.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -1192,7 +1192,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoInvalidations)
     SfxLokHelper::setView(nView1);
 
     // Insert a character the end of the document.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->EndOfSection();
     emulateTyping(u"c");
     // ProcessEventsToIdle resets the view; set it again
@@ -1215,13 +1215,13 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoLimiting)
 {
     // Load a document and create two views.
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
 
     // Insert a character the end of the document in the second view.
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
     pWrtShell2->EndOfSection();
     emulateTyping(u"c");
     SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
@@ -1241,11 +1241,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReordering)
 {
     // Create two views and a document of 2 paragraphs.
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
     pWrtShell2->SplitNode();
     SfxLokHelper::setView(nView1);
     pWrtShell1->SttEndDoc(/*bStt=*/true);
@@ -1281,11 +1281,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingRedo)
 {
     // Create two views and a document of 2 paragraphs.
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
     pWrtShell2->SplitNode();
     SfxLokHelper::setView(nView1);
     pWrtShell1->SttEndDoc(/*bStt=*/true);
@@ -1327,11 +1327,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingRedo2)
 {
     // Create two views.
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
 
     // Type in the first view.
     SfxLokHelper::setView(nView1);
@@ -1369,11 +1369,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingMulti)
 {
     // Create two views and a document of 2 paragraphs.
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
     pWrtShell2->SplitNode();
     SfxLokHelper::setView(nView1);
     pWrtShell1->SttEndDoc(/*bStt=*/true);
@@ -1412,11 +1412,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoShapeLimiting)
 {
     // Load a document and create a view.
     SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     int nView1 = SfxLokHelper::getView();
     int nView2 = SfxLokHelper::createView();
     
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
 
     // Start shape text in the second view.
     SdrPage* pPage = 
pWrtShell2->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
@@ -1427,7 +1427,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoShapeLimiting)
     pWrtShell2->EndTextEdit();
 
     // Assert that the first view can't and the second view can undo the 
insertion.
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+    SwDoc* pDoc = getSwDocShell()->GetDoc();
     sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
     rUndoManager.SetView(&pWrtShell1->GetView());
     // This was 1: first view could undo the change of the second view.
@@ -1458,7 +1458,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoDispatch)
 
     // Click before the first word in the second view.
     SfxLokHelper::setView(nView2);
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
     Point aStart = pShellCursor->GetSttPos();
     aStart.setX(aStart.getX() - 1000);
@@ -1495,7 +1495,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairDispatch)
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+    SwDoc* pDoc = getSwDocShell()->GetDoc();
     sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), 
rUndoManager.GetUndoActionCount());
     comphelper::dispatchCommand(u".uno:Undo"_ustr, {});
@@ -1523,11 +1523,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairDispatch)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testShapeTextUndoShells)
 {
     // Load a document and create a view.
-    SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+    createDoc("shape.fodt");
     sal_Int32 nView1 = SfxLokHelper::getView();
 
     // Begin text edit.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -1536,7 +1536,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoShells)
     pWrtShell->EndTextEdit();
 
     // Make sure that the undo item remembers who created it.
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+    SwDoc* pDoc = getSwDocShell()->GetDoc();
     sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
     CPPUNIT_ASSERT_EQUAL(size_t(1), rUndoManager.GetUndoActionCount());
     CPPUNIT_ASSERT_EQUAL(u"Edit text of Shape 'Shape1'"_ustr, 
rUndoManager.GetUndoActionComment(0));
@@ -1553,7 +1553,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
     sal_Int32 nView1 = SfxLokHelper::getView();
 
     // Begin text edit.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -1564,7 +1564,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
     Scheduler::ProcessEventsToIdle();
 
     // Make sure that the undo item remembers who created it.
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+    SwDoc* pDoc = getSwDocShell()->GetDoc();
     sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
     CPPUNIT_ASSERT_EQUAL(size_t(0), rUndoManager.GetUndoActionCount());
 
@@ -1603,12 +1603,12 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChanges)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+    createDoc("dummy.fodt");
 
     // Turn on track changes, type "zzz" at the end, and move to the start.
     uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, 
uno::UNO_QUERY);
     xPropertySet->setPropertyValue(u"RecordChanges"_ustr, uno::Any(true));
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     ViewCallback aView(pWrtShell->GetSfxViewShell());
     pWrtShell->EndOfSection();
     pWrtShell->Insert(u"zzz"_ustr);
@@ -1636,8 +1636,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTrackChanges)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChangesCallback)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Turn on track changes and type "x".
@@ -1663,8 +1663,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTrackChangesCallback)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testRedlineUpdateCallback)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Turn on track changes, type "xx" and delete the second one.
@@ -1708,7 +1708,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
         SwViewOption aViewOptions;
         aViewOptions.SetViewMetaChars(true);
         aViewOptions.SetOnlineSpell(true);
-        
pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
+        getSwDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
     }
     CPPUNIT_ASSERT_EQUAL("PS;Default"_ostr, 
pXTextDocument->getViewRenderState());
 
@@ -1721,7 +1721,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
         SwViewOption aViewOptions;
         aViewOptions.SetViewMetaChars(false);
         aViewOptions.SetOnlineSpell(true);
-        
pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
+        getSwDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
     }
     CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, 
pXTextDocument->getViewRenderState());
 
@@ -1732,8 +1732,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
     // Switch back to the second view, and change to dark mode
     SfxLokHelper::setView(nSecondViewId);
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1804,8 +1803,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testThemeViewSeparation)
     ViewCallback aView1;
     // Set first view to light scheme
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1822,8 +1820,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testThemeViewSeparation)
     ViewCallback aView2;
     // Set second view to dark scheme
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1841,8 +1838,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testThemeViewSeparation)
     CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 
255));
     // Switch second view back to light scheme
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1865,8 +1861,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testInvertBackgroundViewSeparation)
     ViewCallback aView1;
     // Set view to dark scheme
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1883,8 +1878,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testInvertBackgroundViewSeparation)
     ViewCallback aView2;
     // Set second view to dark scheme
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1898,8 +1892,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testInvertBackgroundViewSeparation)
     // Set view 1 to invert document background
     SfxLokHelper::setView(nFirstViewId);
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1917,8 +1910,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testInvertBackgroundViewSeparation)
 
     // Set view 2 to invert document background
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1937,8 +1929,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testInvertBackgroundViewSeparation)
     SfxLokHelper::setView(nSecondViewId);
     // Set view 2 to regular document background
     {
-        SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-        SwView* pView = pDoc->GetDocShell()->GetView();
+        SwView* pView = getSwDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
         uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
             {
@@ -1960,11 +1951,10 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testThemeChangeBackgroundCallback)
 {
     Color aDarkColor(0x1c, 0x1c, 0x1c);
     addDarkLightThemes(aDarkColor, COL_WHITE);
-    SwXTextDocument* pXTextDocument = createDoc();
+    createDoc();
     ViewCallback aView;
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    SwView* pView = getSwDocShell()->GetView();
     uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
 
     {
@@ -2000,7 +1990,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSetViewGraphicSelection)
     SfxLokHelper::setView(nView1);
 
     // Mark the textframe in the first view.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -2016,11 +2006,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSetViewGraphicSelection)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testCreateViewGraphicSelection)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("frame.odt");
+    createDoc("frame.odt");
     ViewCallback aView1;
 
     // Mark the textframe in the first view.
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
@@ -2049,11 +2039,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testCreateViewGraphicSelection)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testCreateViewTextSelection)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+    createDoc("dummy.fodt");
     ViewCallback aView1;
 
     // Create a text selection:
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     // Move the cursor into the second word.
     pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 5, 
/*bBasicCall=*/false);
     // Create a selection on the word.
@@ -2079,7 +2069,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineColors)
     // Turn on track changes, type "zzz" at the end.
     uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, 
uno::UNO_QUERY);
     xPropertySet->setPropertyValue(u"RecordChanges"_ustr, uno::Any(true));
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->EndOfSection();
     pWrtShell->Insert(u"zzz"_ustr);
 
@@ -2129,9 +2119,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testCommentInsert)
 {
     // Load a document with an as-char image in it.
     comphelper::LibreOfficeKit::setTiledAnnotations(false);
-    SwXTextDocument* pXTextDocument = createDoc("image-comment.odt");
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    createDoc("image-comment.odt");
+    SwView* pView = getSwDocShell()->GetView();
 
     selectShape(1);
 
@@ -2293,8 +2282,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDisableUndoRepair)
     int nView2 = SfxLokHelper::getView();
 
     {
-        SfxItemSet 
aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
-        SfxItemSet 
aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
+        SfxItemSet aItemSet1(getSwDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
+        SfxItemSet aItemSet2(getSwDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
         pView1->GetState(aItemSet1);
         CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, 
aItemSet1.GetItemState(SID_UNDO));
         pView2->GetState(aItemSet2);
@@ -2310,8 +2299,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDisableUndoRepair)
     SfxLokHelper::setView(nView2);
     emulateTyping(u"u");
     {
-        SfxItemSet 
aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
-        SfxItemSet 
aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
+        SfxItemSet aItemSet1(getSwDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
+        SfxItemSet aItemSet2(getSwDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
         // second view, undo enabled
         pView2->GetState(aItemSet2);
         CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, 
aItemSet2.GetItemState(SID_UNDO));
@@ -2550,14 +2539,13 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTdf115088)
 
     mxComponent->dispose();
     mxComponent.clear();
-    comphelper::LibreOfficeKit::setActive(false);
 }
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testRedlineField)
 {
     // Load a document.
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
 
     // Turn on track changes and type "x".
     uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, 
uno::UNO_QUERY);
@@ -2606,7 +2594,6 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testIMESupport)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testIMEFormattingAtEndOfParagraph)
 {
-    comphelper::LibreOfficeKit::setActive();
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
     VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow();
 
@@ -2710,7 +2697,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testIMEFormattingAtEndOfParagraph)
 
     // check the actual weight format of the text
     SvxWeightItem aBoldWeightItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
-    SfxItemSet aSet(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT>);
+    SfxItemSet aSet(getSwDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT>);
     pShellCursor->GetPoint()->GetNode().GetTextNode()->GetParaAttr(aSet, 0, 1);
     SfxPoolItem const* pPoolItem = aSet.GetItem(RES_CHRATR_WEIGHT);
     CPPUNIT_ASSERT(*pPoolItem != aBoldWeightItem); // b not bold
@@ -2726,7 +2713,6 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testIMEFormattingAtEndOfParagraph)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testIMEFormattingAfterHeader)
 {
-    comphelper::LibreOfficeKit::setActive();
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
     VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow();
 
@@ -2796,7 +2782,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSplitNodeRedlineCallback)
 {
     // Load a document.
     SwXTextDocument* pXTextDocument = 
createDoc("splitnode_redline_callback.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // 1. test case
@@ -2854,7 +2840,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDeleteNodeRedlineCallback)
 {
     // Load a document.
     SwXTextDocument* pXTextDocument = 
createDoc("removenode_redline_callback.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // 1. test case
@@ -2991,7 +2977,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testVisCursorInvalidation)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testDeselectCustomShape)
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
     Point aStart = pShellCursor->GetSttPos();
     aStart.setX(aStart.getX() - 1000);
@@ -3294,11 +3280,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testClipText)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAnchorTypes)
 {
-    SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+    createDoc("shape.fodt");
     selectShape(1);
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pXTextDocument->GetDocShell()->GetView();
+    SwDoc* pDoc = getSwDocShell()->GetDoc();
+    SwView* pView = getSwDocShell()->GetView();
     SfxItemSet aSet(pDoc->GetAttrPool(), svl::Items<FN_TOOL_ANCHOR_PAGE, 
FN_TOOL_ANCHOR_PAGE>);
     SfxBoolItem aItem(FN_TOOL_ANCHOR_PAGE);
     aSet.Put(aItem);
@@ -3311,8 +3297,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testAnchorTypes)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testLanguageStatus)
 {
-    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwView* pView = pXTextDocument->GetDocShell()->GetView();
+    createDoc("dummy.fodt");
+    SwView* pView = getSwDocShell()->GetView();
     std::unique_ptr<SfxPoolItem> pItem;
     pView->GetViewFrame().GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem);
     auto pStringListItem = dynamic_cast<SfxStringListItem*>(pItem.get());
@@ -3327,8 +3313,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineNotificationDuringSave)
 {
     // Load a document with redlines which are hidden at a layout level.
     // It's an empty document, just settings.xml and content.xml are custom.
-    SwXTextDocument* pXTextDocument = 
createDoc("redline-notification-during-save.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc("redline-notification-during-save.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Save the document.
@@ -3344,7 +3330,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testHyperlink)
 {
     comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
     SwXTextDocument* pXTextDocument = createDoc("hyperlink.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     
m_callbackWrapper.setLOKViewId(SfxLokHelper::getView(pWrtShell->GetSfxViewShell()));
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
@@ -3372,7 +3358,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButton)
     SwXTextDocument* pXTextDocument = createDoc("drop_down_form_field.odt");
     pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Move the cursor to trigger displaying of the field button.
@@ -3445,7 +3431,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonEditing)
     SwXTextDocument* pXTextDocument = createDoc("drop_down_form_field2.odt");
     pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Move the cursor to trigger displaying of the field button.
@@ -3502,7 +3488,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonNoSelectio
     SwXTextDocument* pXTextDocument = 
createDoc("drop_down_form_field_noselection.odt");
     pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Move the cursor to trigger displaying of the field button.
@@ -3552,10 +3538,9 @@ static void lcl_extractHandleParameters(std::string_view 
selection, sal_Int32& i
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testMoveShapeHandle)
 {
-    comphelper::LibreOfficeKit::setActive();
-    SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+    createDoc("shape.fodt");
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
@@ -3588,7 +3573,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonNoItem)
     SwXTextDocument* pXTextDocument = 
createDoc("drop_down_form_field_noitem.odt");
     pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
 
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
 
     // Move the cursor to trigger displaying of the field button.
@@ -3625,7 +3610,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTablePaintInvalidate)
 {
     // Load a document with a table in it.
     SwXTextDocument* pXTextDocument = createDoc("table-paint-invalidate.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     // Enter the table.
     pWrtShell->Down(/*bSelect=*/false);
@@ -3654,12 +3639,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTablePaintInvalidate)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTableCommentRemoveCallback)
 {
-    comphelper::LibreOfficeKit::setActive();
     comphelper::LibreOfficeKit::setTiledAnnotations(false);
 
     // Load a document with a comment in a table.
     SwXTextDocument* pXTextDocument = 
createDoc("testTableCommentRemoveCallback.odt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     ViewCallback aView;
 
@@ -3678,7 +3662,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTableCommentRemoveCallback)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSpellOnlineRenderParameter)
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     const SwViewOption* pOpt = pWrtShell->GetViewOptions();
     bool bSet = pOpt->IsOnlineSpell();
 
@@ -3710,7 +3694,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testExtTextInputReadOnly)
     CPPUNIT_ASSERT(getParagraph(1)->getString().isEmpty());
 
     // Try to type into the protected section, is it still empty?
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->SttEndDoc(/*bStt=*/true);
     SfxLokHelper::postExtTextEventAsync(pEditWin, LOK_EXT_TEXTINPUT, 
u"x"_ustr);
     SfxLokHelper::postExtTextEventAsync(pEditWin, LOK_EXT_TEXTINPUT_END, 
u"x"_ustr);
@@ -3733,8 +3717,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testExtTextInputReadOnly)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testBulletDeleteInvalidation)
 {
     // Given a document with 3 paragraphs: first 2 is bulleted, the last is 
not.
-    SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->SplitNode();
     pWrtShell->Up(/*bSelect=*/false);
     pWrtShell->StartAllAction();
@@ -3764,8 +3748,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testBulletDeleteInvalidation)
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf155349)
 {
-    SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     Scheduler::ProcessEventsToIdle();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     pWrtShell->Insert2(u"a"_ustr);
@@ -3780,8 +3764,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf155349)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testBulletNoNumInvalidation)
 {
     // Given a document with 3 paragraphs: all are bulleted.
-    SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->StartAllAction();
     pWrtShell->BulletOn();
     pWrtShell->EndAllAction();
@@ -3812,8 +3796,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testBulletNoNumInvalidation)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testBulletMultiDeleteInvalidation)
 {
     // Given a document with 5 paragraphs: all are bulleted.
-    SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    createDoc();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->StartAllAction();
     pWrtShell->BulletOn();
     pWrtShell->EndAllAction();
@@ -3853,7 +3837,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testCondCollCopy)
         = { comphelper::makePropertyValue(u"Style"_ustr, u"Text body"_ustr),
             comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"ParagraphStyles"_ustr) };
     dispatchCommand(mxComponent, u".uno:StyleApply"_ustr, aPropertyValues);
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->SelAll();
 
     // When getting the text selection, then make sure it doesn't crash:
@@ -3871,8 +3855,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlinePortions)
 {
     // Given a document with 3 portions: before insert redline (foo), the 
insert redline (ins) and after insert
     // redline (bar):
-    SwXTextDocument* pXTextDocument = createDoc();
-    SwDocShell* pDocShell = pXTextDocument->GetDocShell();
+    createDoc();
+    SwDocShell* pDocShell = getSwDocShell();
     SwView* pView = pDocShell->GetView();
     pView->SetRedlineAuthor(u"first"_ustr);
     pDocShell->SetView(pView);
@@ -3918,7 +3902,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testContentControl)
     uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, 
uno::UNO_QUERY);
     xContentControlProps->setPropertyValue(u"Alias"_ustr, uno::Any(u"my 
alias"_ustr));
     xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     pWrtShell->SttEndDoc(/*bStt=*/true);
     m_aContentControl.clear();
@@ -3959,7 +3943,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownContentControl)
 {
     // Given a document with a dropdown content control:
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
@@ -4034,7 +4018,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPictureContentControl)
 {
     // Given a document with a picture content control:
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
@@ -4100,7 +4084,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDateContentControl)
 {
     // Given a document with a date content control:
     SwXTextDocument* pXTextDocument = createDoc();
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
@@ -4273,8 +4257,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSwitchingChartToDarkMode)
     SwXTextDocument* pXTextDocument = createDoc("large-chart-labels.odt");
     CPPUNIT_ASSERT(pXTextDocument);
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    SwView* pView = getSwDocShell()->GetView();
     uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
     uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
         {
@@ -4319,8 +4302,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTdf159626_yellowPatternFill)
     SwXTextDocument* pXTextDocument = 
createDoc("tdf159626_yellowPatternFill.docx");
     CPPUNIT_ASSERT(pXTextDocument);
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    SwView* pView = getSwDocShell()->GetView();
     uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
 
     Bitmap aBitmap(getTile(pXTextDocument));
@@ -4351,8 +4333,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTdf159626_yellowPatternFillB)
     SwXTextDocument* pXTextDocument = 
createDoc("tdf159626_yellowPatternFillB.docx");
     CPPUNIT_ASSERT(pXTextDocument);
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    SwView* pView = getSwDocShell()->GetView();
     uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
 
     Bitmap aBitmap(getTile(pXTextDocument));
@@ -4381,10 +4362,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTdf159626_yellowPatternFillB)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf159626_blackPatternFill)
 {
     SwXTextDocument* pXTextDocument = 
createDoc("tdf159626_blackPatternFill.docx");
-    CPPUNIT_ASSERT(pXTextDocument);
 
-    SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
-    SwView* pView = pDoc->GetDocShell()->GetView();
+    SwView* pView = getSwDocShell()->GetView();
     uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
 
     Bitmap aBitmap(getTile(pXTextDocument));
diff --git a/sw/qa/extras/tiledrendering2/tiledrendering2.cxx 
b/sw/qa/extras/tiledrendering2/tiledrendering2.cxx
index 8ee7b7af5c56..42f769ed1a17 100644
--- a/sw/qa/extras/tiledrendering2/tiledrendering2.cxx
+++ b/sw/qa/extras/tiledrendering2/tiledrendering2.cxx
@@ -165,7 +165,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testStatusBarPageNumber)
     // Given a document with 2 pages, first view on page 1, second view on 
page 2:
     SwXTextDocument* pXTextDocument = createDoc();
     int nView1 = SfxLokHelper::getView();
-    SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell1 = getSwDocShell()->GetWrtShell();
     pWrtShell1->InsertPageBreak();
     SwRootFrame* pLayout = 
pWrtShell1->getIDocumentLayoutAccess().GetCurrentLayout();
     SwFrame* pPage1 = pLayout->GetLower();
@@ -182,7 +182,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testStatusBarPageNumber)
     pWrtShell1->GetView().SetVisArea(pPage1->getFrameArea().SVRect());
     SfxLokHelper::setView(nView2);
     ViewCallback aView2;
-    SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell2 = getSwDocShell()->GetWrtShell();
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     pWrtShell2->Insert(u"end"_ustr);
     pWrtShell2->GetView().SetVisArea(pPage2->getFrameArea().SVRect());
@@ -219,10 +219,9 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPasteInvalidateNumRules)
 {
     // Given a document with 3 pages: first page is ~empty, then page break, 
then pages 2 & 3 have
     // bullets:
-    SwXTextDocument* pXTextDocument = createDoc("numrules.odt");
-    CPPUNIT_ASSERT(pXTextDocument);
+    createDoc("numrules.odt");
     ViewCallback aView;
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->SttEndDoc(/*bStt=*/true);
     pWrtShell->Down(/*bSelect=*/false);
     pWrtShell->Insert(u"test"_ustr);
@@ -251,10 +250,9 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPasteInvalidateNumRulesBullet)
 {
     // Given a document with 3 pages: first page is ~empty, then page break, 
then pages 2 & 3 have
     // bullets:
-    SwXTextDocument* pXTextDocument = createDoc("numrules.odt");
-    CPPUNIT_ASSERT(pXTextDocument);
+    createDoc("numrules.odt");
     ViewCallback aView;
-    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     pWrtShell->SttEndDoc(/*bStt=*/true);
     pWrtShell->Down(/*bSelect=*/false);
     pWrtShell->Insert(u"test"_ustr);
@@ -284,8 +282,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPasteInvalidateNumRulesBullet)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAsyncLayout)
 {
     // Given a document with 3 pages, the first page is visible:
-    SwXTextDocument* pXTextDocument = createDoc();
-    CPPUNIT_ASSERT(pXTextDocument);
+    createDoc();
     ViewCallback aView;
     SwDocShell* pDocShell = getSwDocShell();
     SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
@@ -321,8 +318,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAsyncLayout)
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAnyInput)
 {
     // Given a document with 3 pages, the first page is visible:
-    SwXTextDocument* pXTextDocument = createDoc();
-    CPPUNIT_ASSERT(pXTextDocument);
+    createDoc();
     ViewCallback aView;
     SwDocShell* pDocShell = getSwDocShell();
     SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
@@ -363,7 +359,6 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSignatureState)
 {
     // Given a document with a signature where the digest matches:
     SwXTextDocument* pXTextDocument = createDoc("signed-doc.odt");
-    CPPUNIT_ASSERT(pXTextDocument);
 
     // When initializing tiled rendering with an author name:
     uno::Sequence<beans::PropertyValue> aPropertyValues
@@ -383,7 +378,6 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testFormatInsertStartList)
 {
     // Given a document containing a list where the text has a changed font
     SwXTextDocument* pXTextDocument = createDoc("format-insert-list.docx");
-    CPPUNIT_ASSERT(pXTextDocument);
     VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow();
     SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
     assert(pView);
commit 42ca17dd19a5a03c6c26c9b5e524cbb3499ffced
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Oct 25 12:23:36 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Oct 30 00:30:44 2024 +0100

    SwModelTestBase: add getSwTextDoc and use it everywhere
    
    Change-Id: I09f132a9c79f0aa4c3f4d3ca5f2fed233d0dcb06
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175641
    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 4933451f4468..9b724e4d77c0 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -212,17 +212,15 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, 
testTextBoxMakeFlyFrame)
     rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
     pTransfer->Cut();
     TransferableDataHelper aHelper(pTransfer);
-    uno::Reference<lang::XComponent> xDoc2 = loadFromDesktop(
-        u"private:factory/swriter"_ustr, 
u"com.sun.star.text.TextDocument"_ustr, {});
-    SwXTextDocument* pTextDoc2 = dynamic_cast<SwXTextDocument*>(xDoc2.get());
+    mxComponent2 = loadFromDesktop(u"private:factory/swriter"_ustr,
+                                   u"com.sun.star.text.TextDocument"_ustr, {});
+    SwXTextDocument* pTextDoc2 = 
dynamic_cast<SwXTextDocument*>(mxComponent2.get());
     SwDocShell* pDocShell2 = pTextDoc2->GetDocShell();
     SwWrtShell* pWrtShell2 = pDocShell2->GetWrtShell();
     SwTransferable::Paste(*pWrtShell2, aHelper);
 
     // Then make sure its fly frame is created.
-    mxComponent->dispose();
-    mxComponent = xDoc2;
-    xmlDocUniquePtr pLayout = parseLayoutDump();
+    xmlDocUniquePtr pLayout = parseLayoutDump(mxComponent2);
     // Without the accompanying fix in place, this test would have failed, 
because the first text
     // frame in the body frame had an SwAnchoredDrawObject anchored to it, but 
not a fly frame, so
     // a blank square was painted, not the image.
@@ -663,11 +661,10 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testAtCharImageCopy)
     rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell1);
     xTransfer->Copy();
     // Don't use createSwDoc(), UnoApiTest::loadWithParams() would dispose the 
first document.
-    uno::Reference<lang::XComponent> xComponent2 = 
loadFromDesktop(u"private:factory/swriter"_ustr);
-    comphelper::ScopeGuard g([xComponent2] { xComponent2->dispose(); });
+    mxComponent2 = loadFromDesktop(u"private:factory/swriter"_ustr);
 
     // When copying the body text from that document to a new one:
-    auto pXTextDocument2 = dynamic_cast<SwXTextDocument*>(xComponent2.get());
+    auto pXTextDocument2 = dynamic_cast<SwXTextDocument*>(mxComponent2.get());
     SwDocShell* pDocShell2 = pXTextDocument2->GetDocShell();
     SwWrtShell* pWrtShell2 = pDocShell2->GetWrtShell();
     TransferableDataHelper aHelper(xTransfer);
diff --git a/sw/qa/core/edit/edit.cxx b/sw/qa/core/edit/edit.cxx
index 934cb6346d24..b8ad7ff58743 100644
--- a/sw/qa/core/edit/edit.cxx
+++ b/sw/qa/core/edit/edit.cxx
@@ -49,10 +49,9 @@ CPPUNIT_TEST_FIXTURE(Test, testAutocorrect)
 
     // When typing a string, which contains a "-", then make sure no memory 
corruption happens when
     // it gets auto-corrected to "–":
-    auto pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
     // Without the accompanying fix in place, this test would have failed with 
a
     // heap-use-after-free:
-    emulateTyping(*pTextDoc, u"But not now - with ");
+    emulateTyping(u"But not now - with ");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testDeleteSelNormalize)
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index beea0c986c1e..1882602c8d93 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -169,8 +169,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testTitleFieldInvalidate)
 
     // Given a document with a title field:
     createSwDoc("title-field-invalidate.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    pTextDoc->initializeForTiledRendering({});
+    getSwTextDoc()->initializeForTiledRendering({});
     SwDocShell* pShell = getSwDocShell();
     SwDoc* pDoc = pShell->GetDoc();
     SwWrtShell* pWrtShell = pShell->GetWrtShell();
diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx
index 0857f3c232de..3a4c86976bf9 100644
--- a/sw/qa/core/undo/undo.cxx
+++ b/sw/qa/core/undo/undo.cxx
@@ -100,9 +100,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTableCopyRedline)
 CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testImagePropsCreateUndoAndModifyDoc)
 {
     createSwDoc("image-as-character.odt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     SwDocShell* pDocShell = getSwDocShell();
     SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    SwXTextDocument* pTextDoc = getSwTextDoc();
     css::uno::Reference<css::beans::XPropertySet> xImage(
         pTextDoc->getGraphicObjects()->getByName(u"Image1"_ustr), 
css::uno::UNO_QUERY_THROW);
 
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 9e27428717b0..250d9a2826f9 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -802,8 +802,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControls)
 {
     // Given an empty document:
     createSwDoc();
-    auto pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    uno::Reference<container::XIndexAccess> xContentControls = 
pXTextDocument->getContentControls();
+    uno::Reference<container::XIndexAccess> xContentControls = 
getSwTextDoc()->getContentControls();
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), 
xContentControls->getCount());
 
     // When inserting content controls:
diff --git a/sw/qa/extras/autocorrect/autocorrect.cxx 
b/sw/qa/extras/autocorrect/autocorrect.cxx
index 6f57a53b52f6..203dcd979ec6 100644
--- a/sw/qa/extras/autocorrect/autocorrect.cxx
+++ b/sw/qa/extras/autocorrect/autocorrect.cxx
@@ -35,12 +35,10 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf92029)
 {
     createSwDoc("nl-BE.fodt");
 
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-
     // Without the fix in place, this test would have failed with
     // - Expected: Ik ben ’s morgens opgestaan
     // - Actual  : Ik ben ‘s morgens opgestaan
-    emulateTyping(*pTextDoc, u"Ik ben 's morgens opgestaan");
+    emulateTyping(u"Ik ben 's morgens opgestaan");
     OUString sReplaced(u"Ik ben ’s morgens opgestaan"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -48,48 +46,40 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf92029)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf158703)
 {
     createSwDoc("fr-FR.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
 
     // Typing ":" after the spaces should start auto-correction, which is 
expected to
     // remove the spaces, and insert an NBSP instead. It must not crash.
-    emulateTyping(*pTextDoc, u"Foo             :");
+    emulateTyping(u"Foo             :");
     CPPUNIT_ASSERT_EQUAL(u"Foo\u00A0:"_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf38394)
 {
     createSwDoc("fr-FR.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
 
     // testing autocorrect of French l'" -> l'« (instead of l'»)
-    emulateTyping(*pTextDoc, u"l'\"");
+    emulateTyping(u"l'\"");
     CPPUNIT_ASSERT_EQUAL(u"l\u2019« "_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf132301)
 {
     createSwDoc("fr-FR.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
 
     // autocorrect of qu'«
-    emulateTyping(*pTextDoc, u" qu'\"");
+    emulateTyping(u" qu'\"");
     CPPUNIT_ASSERT_EQUAL(u" qu\u2019« "_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, tdfTdf44293)
 {
     createSwDoc("pt-BR.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
 
-    emulateTyping(*pTextDoc, u"1a 1o ");
+    emulateTyping(u"1a 1o ");
     CPPUNIT_ASSERT_EQUAL(u"1.a 1.o "_ustr, getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u"1ra 1ro ");
+    emulateTyping(u"1ra 1ro ");
     CPPUNIT_ASSERT_EQUAL(u"1.a 1.o 1.a 1.o "_ustr, 
getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u"43as 43os 43ras 43ros ");
+    emulateTyping(u"43as 43os 43ras 43ros ");
     CPPUNIT_ASSERT_EQUAL(u"1.a 1.o 1.a 1.o 43.as 43.os 43.as 43.os "_ustr,
                          getParagraph(1)->getString());
 }
@@ -111,18 +101,17 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf151801)
     pBatch->commit();
 
     createSwDoc("de-DE.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
     // Single starting quote: 'word -> ›word
-    emulateTyping(*pTextDoc, u"'word");
+    emulateTyping(u"'word");
     OUString sReplaced(u"\u203Aword"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // Single ending quote: ›word' -> ›word‹
-    emulateTyping(*pTextDoc, u"'");
+    emulateTyping(u"'");
     sReplaced += u"\u2039";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // Use apostrophe without preceding starting quote: word' -> word’
-    emulateTyping(*pTextDoc, u" word'");
+    emulateTyping(u" word'");
     sReplaced += u" word\u2019";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -130,18 +119,17 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf151801)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf128860)
 {
     createSwDoc("de-DE.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
     // Second level ending quote: ‚word' -> ,word‘
-    emulateTyping(*pTextDoc, u",word'");
+    emulateTyping(u",word'");
     OUString sReplaced2(u",word\u2019"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString());
     // Us apostrophe without preceding starting quote: word' -> word’
-    emulateTyping(*pTextDoc, u" word'");
+    emulateTyping(u" word'");
     sReplaced2 += u" word\u2019";
     CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString());
     // But only after letters: word.' -> word.‘
-    emulateTyping(*pTextDoc, u" word.'");
+    emulateTyping(u" word.'");
     sReplaced2 += u" word.‘";
     CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString());
 }
@@ -157,17 +145,16 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf123786)
     aOptions.SetIgnoreLanguageChange(true);
     aOptions.Commit();
 
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     // Second level ending quote: „word' -> „word“
-    emulateTyping(*pTextDoc, u"„слово'");
+    emulateTyping(u"„слово'");
     OUString sReplaced(u"„слово“"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // Us apostrophe without preceding starting quote: word' -> word’
-    emulateTyping(*pTextDoc, u" слово'");
+    emulateTyping(u" слово'");
     sReplaced += u" слово’";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // But only after letters: word.' -> word.“
-    emulateTyping(*pTextDoc, u" слово.'");
+    emulateTyping(u" слово.'");
     sReplaced += u" слово.“";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -175,31 +162,28 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf123786)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf106164)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     // Testing autocorrect of we're -> We're on start of first paragraph
-    emulateTyping(rTextDoc, u"we're ");
+    emulateTyping(u"we're ");
     CPPUNIT_ASSERT_EQUAL(u"We\u2019re "_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf59666)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     // Testing missing autocorrect of single Greek letters
-    emulateTyping(rTextDoc, u"π ");
+    emulateTyping(u"π ");
     CPPUNIT_ASSERT_EQUAL(u"\u03C0 "_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf74363)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     //testing autocorrect of initial capitals on start of first paragraph
     //Inserting one all-lowercase word into the first paragraph
-    emulateTyping(rTextDoc, u"testing ");
+    emulateTyping(u"testing ");
     //The word should be capitalized due to autocorrect
     CPPUNIT_ASSERT_EQUAL(u"Testing "_ustr, getParagraph(1)->getString());
 }
@@ -207,16 +191,15 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf74363)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf155407)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
-    emulateTyping(rTextDoc, u"Foo - 11’--’22 ");
+    emulateTyping(u"Foo - 11’--’22 ");
     OUString sReplaced(u"Foo – 11’—’22 "_ustr);
     // Without the fix in place, this would fail with
     // - Expected: Foo – 11’—’22
     // - Actual  : Foo – 11’--’22
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
-    emulateTyping(rTextDoc, u"Bar -- 111--222 ");
+    emulateTyping(u"Bar -- 111--222 ");
     sReplaced += u"Bar – 111–222 "_ustr;
     // Without the fix in place, this would fail with
     // - Expected: Bar – 111–222
@@ -227,9 +210,8 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf155407)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf159797)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
-    emulateTyping(rTextDoc, u"This - is replaced. - But this is not replaced 
");
+    emulateTyping(u"This - is replaced. - But this is not replaced ");
     // Without the fix in place, this would fail with
     // - Expected: This – is replaced. – But this is not replaced.
     // - Actual  : This – is replaced. - But this is not replaced.
@@ -240,18 +222,17 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf159797)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf54409)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     // testing autocorrect of "tset -> "test with typographical double 
quotation mark U+201C
-    emulateTyping(rTextDoc, u"\"test ");
+    emulateTyping(u"\"test ");
     OUString sReplaced(u"\u201Ctest "_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // testing autocorrect of test" -> test" with typographical double 
quotation mark U+201D
-    emulateTyping(rTextDoc, u"and tset\" ");
+    emulateTyping(u"and tset\" ");
     OUString sReplaced2(sReplaced + u"and test\u201D ");
     CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString());
     // testing autocorrect of "tset" -> "test" with typographical double 
quotation mark U+201C and U+201D
-    emulateTyping(rTextDoc, u"\"tset\" ");
+    emulateTyping(u"\"tset\" ");
     OUString sReplaced3(sReplaced2 + u"\u201Ctest\u201D ");
     CPPUNIT_ASSERT_EQUAL(sReplaced3, getParagraph(1)->getString());
 }
@@ -259,14 +240,13 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf54409)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf108423)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     // testing autocorrect of i' -> I' on start of first paragraph
-    emulateTyping(rTextDoc, u"i'");
+    emulateTyping(u"i'");
     // The word "i" should be capitalized due to autocorrect, followed by a 
typographical apostrophe
     OUString sIApostrophe(u"I\u2019"_ustr);
     CPPUNIT_ASSERT_EQUAL(sIApostrophe, getParagraph(1)->getString());
-    emulateTyping(rTextDoc, u" i'");
+    emulateTyping(u" i'");
     OUString sText(sIApostrophe + u" " + sIApostrophe);
     CPPUNIT_ASSERT_EQUAL(sText, getParagraph(1)->getString());
 }
@@ -274,64 +254,60 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf108423)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf57640)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     // Without the fix in place, this test would have failed with
     // - Expected: Dž
     // - Actual  : DŽ
-    emulateTyping(rTextDoc, u"dž  ");
+    emulateTyping(u"dž  ");
     CPPUNIT_ASSERT_EQUAL(u"Dž  "_ustr, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf62923)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     OUString sReplaced(u"1–2 "_ustr);
     // Without the fix in place, this test would have failed with
     // - Expected: 1—2
     // - Actual  : 1–2
-    emulateTyping(rTextDoc, u"1--2 ");
+    emulateTyping(u"1--2 ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     sReplaced += u"a—b "_ustr;
-    emulateTyping(rTextDoc, u"a--b ");
+    emulateTyping(u"a--b ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf42893)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     OUString sReplaced(u"Foo. Bar "_ustr);
-    emulateTyping(rTextDoc, u"foo. bar ");
+    emulateTyping(u"foo. bar ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     // Without the fix in place, this test would have failed with
     // - Expected: F.o.o. bar
     // - Actual  : F.o.o. Bar
     sReplaced += u"F.o.o. bar "_ustr;
-    emulateTyping(rTextDoc, u"F.o.o. bar ");
+    emulateTyping(u"F.o.o. bar ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf55693)
 {
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     OUString sReplaced(u"Test-Test "_ustr);
-    emulateTyping(rTextDoc, u"TEst-TEst ");
+    emulateTyping(u"TEst-TEst ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     sReplaced += u"Test/Test "_ustr;
-    emulateTyping(rTextDoc, u"TEst/TEst ");
+    emulateTyping(u"TEst/TEst ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     sReplaced += u"Test. Test "_ustr;
-    emulateTyping(rTextDoc, u"Test. test ");
+    emulateTyping(u"Test. test ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
 
@@ -377,58 +353,56 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, 
testUnderlineWeight)
     pBatch->commit();
 
     createSwDoc(); // Default lang is en-US
-    SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent);
 
     //bold
     OUString sReplaced(u"Foo "_ustr);
-    emulateTyping(rTextDoc, u"*foo* ");
+    emulateTyping(u"*foo* ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     //underline
     sReplaced += u"foo "_ustr;
-    emulateTyping(rTextDoc, u"_foo_ ");
+    emulateTyping(u"_foo_ ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     //italic
     sReplaced += u"foo "_ustr;
-    emulateTyping(rTextDoc, u"/foo/ ");
+    emulateTyping(u"/foo/ ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 
     //strikeout
     sReplaced += u"foo "_ustr;
-    emulateTyping(rTextDoc, u"-foo- ");
+    emulateTyping(u"-foo- ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf133524)
 {
     createSwDoc("hu-HU.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     // 1. Testing autocorrect of >> and <<
     // Example: »word«
-    emulateTyping(*pTextDoc, u">>");
+    emulateTyping(u">>");
     OUString sReplaced(u"»"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // <<
-    emulateTyping(*pTextDoc, u"word<<");
+    emulateTyping(u"word<<");
     sReplaced += u"word«";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // 2. Testing autocorrect of " to >> and << inside „...”
     // Example: „Sentence and »word«.”
     // opening primary level quote
-    emulateTyping(*pTextDoc, u" \"");
+    emulateTyping(u" \"");
     sReplaced += u" „";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // opening second level quote
-    emulateTyping(*pTextDoc, u"Sentence and \"");
+    emulateTyping(u"Sentence and \"");
     sReplaced += u"Sentence and »";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // closing second level quote
-    emulateTyping(*pTextDoc, u"word\"");
+    emulateTyping(u"word\"");
     sReplaced += u"word«";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // closing primary level quote
-    emulateTyping(*pTextDoc, u".\"");
+    emulateTyping(u".\"");
     sReplaced += u".”";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -436,13 +410,12 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf133524)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf134940)
 {
     createSwDoc("hu-HU.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
     // avoid premature replacement of "--" in "-->"
-    emulateTyping(*pTextDoc, u" -->");
+    emulateTyping(u" -->");
     // This was "–>" instead of "-->"
     CPPUNIT_ASSERT_EQUAL(u" -->"_ustr, getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u" ");
+    emulateTyping(u" ");
     // This was "–>" instead of "→"
     CPPUNIT_ASSERT_EQUAL(u" → "_ustr, getParagraph(1)->getString());
 }
@@ -450,18 +423,17 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf134940)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf83037)
 {
     createSwDoc("hu-HU.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
-    emulateTyping(*pTextDoc, u"-> ");
+    emulateTyping(u"-> ");
     OUString sReplaced(u"→ "_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u"<- ");
+    emulateTyping(u"<- ");
     sReplaced += u"← ";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u"<-- ");
+    emulateTyping(u"<-- ");
     sReplaced += u"← ";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
-    emulateTyping(*pTextDoc, u"<--> ");
+    emulateTyping(u"<--> ");
     sReplaced += u"↔ ";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -469,31 +441,30 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf83037)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf133524_Romanian)
 {
     createSwDoc("ro-RO.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     // 1. Testing autocorrect of " to << and >> inside „...”
     // Example: „Sentence and «word».”
     // opening primary level quote
-    emulateTyping(*pTextDoc, u"\"");
+    emulateTyping(u"\"");
     OUString sReplaced(u"„"_ustr);
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // opening second level quote
-    emulateTyping(*pTextDoc, u"Sentence and \"");
+    emulateTyping(u"Sentence and \"");
     sReplaced += u"Sentence and «";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // closing second level quote
-    emulateTyping(*pTextDoc, u"word\"");
+    emulateTyping(u"word\"");
     sReplaced += u"word»";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // closing primary level quote
-    emulateTyping(*pTextDoc, u".\"");
+    emulateTyping(u".\"");
     sReplaced += u".”";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // 2. Testing recognition of closing double quotation mark ”
-    emulateTyping(*pTextDoc, u" \"");
+    emulateTyping(u" \"");
     sReplaced += u" „";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
     // 3. Testing recognition of alternative closing double quotation mark “
-    emulateTyping(*pTextDoc, u"Alternative.“ \"");
+    emulateTyping(u"Alternative.“ \"");
     sReplaced += u"Alternative.“ „";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
@@ -501,12 +472,11 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, 
testTdf133524_Romanian)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf158051)
 {
     createSwDoc("el-GR.fodt");
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
     // Without the fix in place, this test would have failed with
     // - Expected: Π Τάκης σ’ ευχαριστώ
     // - Actual  : Π Τάκης ς’ ευχαριστώ
-    emulateTyping(*pTextDoc, u"π Τάκης σ’ ευχαριστώ");
+    emulateTyping(u"π Τάκης σ’ ευχαριστώ");
 
 #if !defined(_WIN32) // For some reason it fails on Window. the manual test 
works fine
     CPPUNIT_ASSERT_EQUAL(u"Π Τάκης σ’ ευχαριστώ"_ustr, 
getParagraph(1)->getString());
@@ -516,9 +486,8 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf158051)
 CPPUNIT_TEST_FIXTURE(SwAutoCorrectTest, testTdf162911)
 {
     createSwDoc();
-    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
 
-    emulateTyping(*pTextDoc, u"f...@bar.com f...@bar.com ");
+    emulateTyping(u"f...@bar.com f...@bar.com ");
 
     CPPUNIT_ASSERT_EQUAL(u"mailto:f...@bar.com"_ustr,
                          getProperty<OUString>(getRun(getParagraph(1), 1, 
u"f...@bar.com"_ustr),
diff --git a/sw/qa/extras/mailmerge/mailmerge2.cxx 
b/sw/qa/extras/mailmerge/mailmerge2.cxx
index 5cac9ee611dc..1ba13874dfc1 100644
--- a/sw/qa/extras/mailmerge/mailmerge2.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge2.cxx
@@ -386,20 +386,19 @@ DECLARE_MAILMERGE_TEST(testGrabBag, "grabbagtest.docx", 
"onecell.xlsx", "Sheet1"
 
     loadMailMergeDocument(0, ".docx");
 
-    SwXTextDocument *const pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
-
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
getSwDocShell()->GetWrtShell()->GetPhyPageNum());
 
     // check grabbag
     uno::Reference<beans::XPropertySet> const xModel(
         mxComponent, uno::UNO_QUERY_THROW);
     uno::Sequence<beans::PropertyValue> aInteropGrabBag;
-    pTextDoc->getPropertyValue(u"InteropGrabBag"_ustr) >>= aInteropGrabBag;
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
+    xTextDocumentPropertySet->getPropertyValue(u"InteropGrabBag"_ustr) >>= 
aInteropGrabBag;
     CPPUNIT_ASSERT_EQUAL(sal_Int32(12), aInteropGrabBag.getLength());
 
     // check table border - comes from table style "Tabellenraster"
-    uno::Reference<text::XTextTable> const xTable(getParagraphOrTable(1, 
pTextDoc->getText()), uno::UNO_QUERY_THROW);
+    uno::Reference<text::XTextTable> const xTable(getParagraphOrTable(1, 
xTextDocument->getText()), uno::UNO_QUERY_THROW);
     uno::Reference<beans::XPropertySet> const xTableProps(xTable, 
uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT_EQUAL(table::TableBorder(
                 table::BorderLine(util::Color(0), 0, 18, 0), true,
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx 
b/sw/qa/extras/odfexport/odfexport2.cxx
index c32c62ea4163..662fab0f5f9a 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -1276,8 +1276,7 @@ DECLARE_ODFEXPORT_TEST(testTdf78510, "WordTest_edit.odt")
     // some Mac has 3110
 #if !defined(_WIN32) && !defined(MACOSX)
     {
-        SwDocShell *const 
pShell(dynamic_cast<SwXTextDocument&>(*mxComponent).GetDocShell());
-        std::shared_ptr<GDIMetaFile> pMetaFile = pShell->GetPreviewMetaFile();
+        std::shared_ptr<GDIMetaFile> pMetaFile = 
getSwDocShell()->GetPreviewMetaFile();
         MetafileXmlDump aDumper;
         xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *pMetaFile);
 
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 6d6462fe42b1..1e5552b7a4b5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -752,12 +752,8 @@ CPPUNIT_TEST_FIXTURE(Test, TestPuzzleExport)
 {
     loadAndReload("TestPuzzleExport.odt");
     // See tdf#148342 for details
-    // Get the doc
-    uno::Reference<text::XTextDocument> xTextDoc(mxComponent, 
uno::UNO_QUERY_THROW);
-    auto pSwDoc = dynamic_cast<SwXTextDocument*>(xTextDoc.get());
-    CPPUNIT_ASSERT(pSwDoc);
     // Create a metafile
-    auto pMeta = pSwDoc->GetDocShell()->GetPreviewMetaFile();
+    auto pMeta = getSwDocShell()->GetPreviewMetaFile();
     CPPUNIT_ASSERT(pMeta);
     MetafileXmlDump aDumper;
     auto pMetaXml = dumpAndParse(aDumper, *pMeta);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ccff88a6809d..2484d52c548f 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -151,14 +151,10 @@ void SwTiledRenderingTest::tearDown()
 {
     if (mxComponent.is())
     {
-        SwXTextDocument* pTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-        if (pTextDocument)
+        SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+        if (pWrtShell)
         {
-            SwWrtShell* pWrtShell = 
pTextDocument->GetDocShell()->GetWrtShell();
-            if (pWrtShell)
-            {
-                
pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(nullptr);
-            }
+            
pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(nullptr);
         }
         mxComponent->dispose();
         mxComponent.clear();
@@ -176,8 +172,7 @@ SwXTextDocument* SwTiledRenderingTest::createDoc(const 
char* pName)
     else
         createSwDoc(pName);
 
-    SwXTextDocument* pTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDocument);
+    SwXTextDocument* pTextDocument = getSwTextDoc();
     
pTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
     return pTextDocument;
 }
@@ -344,7 +339,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPostKeyEvent)
     // Did we manage to go after the first character?
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
pShellCursor->GetPoint()->GetContentIndex());
 
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     // Did we manage to insert the character after the first one?
     CPPUNIT_ASSERT_EQUAL(u"Axaa bbb."_ustr, 
pShellCursor->GetPoint()->GetNode().GetTextNode()->GetText());
 }
@@ -1060,7 +1055,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeViewCursors)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell2->GetDrawView();
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell2->GetWin());
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     // Press a key in the second view, while the first one observes this.
     aView1.m_bViewCursorInvalidated = false;
     aView2.m_bOwnCursorInvalidated = false;
@@ -1069,7 +1064,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeViewCursors)
     const tools::Rectangle aLastOwnCursor2 = aView2.m_aOwnCursor;
     const tools::Rectangle aLastViewCursor2 = aView2.m_aViewCursor;
 
-    emulateTyping(*pXTextDocument, u"y");
+    emulateTyping(u"y");
     // Make sure that aView1 gets a view-only cursor notification, while
     // aView2 gets a real cursor notification.
     CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor, aLastOwnCursor1);
@@ -1174,11 +1169,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTextEditViewInvalidations)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
 
     // Assert that both views are invalidated when pressing a key while in 
text edit.
     aView1.m_bTilesInvalidated = false;
-    emulateTyping(*pXTextDocument, u"y");
+    emulateTyping(u"y");
 
     CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
 
@@ -1199,7 +1194,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoInvalidations)
     // Insert a character the end of the document.
     SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
     pWrtShell->EndOfSection();
-    emulateTyping(*pXTextDocument, u"c");
+    emulateTyping(u"c");
     // ProcessEventsToIdle resets the view; set it again
     SfxLokHelper::setView(nView1);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
@@ -1228,7 +1223,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoLimiting)
     // Insert a character the end of the document in the second view.
     SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
     pWrtShell2->EndOfSection();
-    emulateTyping(*pXTextDocument, u"c");
+    emulateTyping(u"c");
     SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
     CPPUNIT_ASSERT_EQUAL(u"Aaa bbb.c"_ustr, 
pShellCursor->GetPoint()->GetNode().GetTextNode()->GetText());
 
@@ -1256,12 +1251,12 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReordering)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph.
-    emulateTyping(*pXTextDocument, u"a");
+    emulateTyping(u"a");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph.
-    emulateTyping(*pXTextDocument, u"z");
+    emulateTyping(u"z");
     CPPUNIT_ASSERT_EQUAL(u"a"_ustr, pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(u"z"_ustr, pTextNode2->GetText());
 
@@ -1296,15 +1291,15 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingRedo)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph, twice.
-    emulateTyping(*pXTextDocument, u"f");
+    emulateTyping(u"f");
     // Go to the start of the paragraph, to avoid grouping.
     pWrtShell1->SttEndDoc(/*bStt=*/true);
-    emulateTyping(*pXTextDocument, u"s");
+    emulateTyping(u"s");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph.
-    emulateTyping(*pXTextDocument, u"z");
+    emulateTyping(u"z");
     CPPUNIT_ASSERT_EQUAL(u"sf"_ustr, pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(u"z"_ustr, pTextNode2->GetText());
 
@@ -1384,15 +1379,15 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingMulti)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph.
-    emulateTyping(*pXTextDocument, u"a");
+    emulateTyping(u"a");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph, twice.
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     // Go to the start of the paragraph, to avoid grouping.
     pWrtShell2->SttPara();
-    emulateTyping(*pXTextDocument, u"y");
+    emulateTyping(u"y");
     CPPUNIT_ASSERT_EQUAL(u"a"_ustr, pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(u"yx"_ustr, pTextNode2->GetText());
 
@@ -1428,7 +1423,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoShapeLimiting)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell2->GetDrawView();
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell2->GetWin());
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     pWrtShell2->EndTextEdit();
 
     // Assert that the first view can't and the second view can undo the 
insertion.
@@ -1459,7 +1454,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoDispatch)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    emulateTyping(*pXTextDocument, u"c");
+    emulateTyping(u"c");
 
     // Click before the first word in the second view.
     SfxLokHelper::setView(nView2);
@@ -1496,7 +1491,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairDispatch)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    emulateTyping(*pXTextDocument, u"c");
+    emulateTyping(u"c");
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -1537,7 +1532,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoShells)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     pWrtShell->EndTextEdit();
 
     // Make sure that the undo item remembers who created it.
@@ -1563,7 +1558,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 
awt::Key::BACKSPACE);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE);
     Scheduler::ProcessEventsToIdle();
@@ -1584,7 +1579,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
 
     // Create an editeng text selection in the first view.
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     // 0th para, 0th char -> 0th para, 1st char.
     ESelection aWordSelection(0, 0, 0, 1);
     rEditView.SetSelection(aWordSelection);
@@ -2102,14 +2097,14 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testCommentEndTextEdit)
     // Create a document, type a character and remember the cursor position.
     SwXTextDocument* pXTextDocument = createDoc();
     ViewCallback aView1;
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     tools::Rectangle aBodyCursor = aView1.m_aOwnCursor;
 
     // Create a comment and type a character there as well.
     const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
-    emulateTyping(*pXTextDocument, u"x");
+    emulateTyping(u"x");
     // End comment text edit by clicking in the body text area, and assert that
     // no unexpected cursor callbacks are emitted at origin (top left corner of
     // the document).
@@ -2211,11 +2206,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairResult)
 
     // Insert a character in the second view.
     SfxLokHelper::setView(nView2);
-    emulateTyping(*pXTextDocument, u"b");
+    emulateTyping(u"b");
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    emulateTyping(*pXTextDocument, u"a");
+    emulateTyping(u"a");
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -2241,11 +2236,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedoRepairResult)
 
     // Insert a character in the second view.
-e 
... etc. - the rest is truncated

Reply via email to