sd/inc/sdabstdlg.hxx                                           |    2 
 sd/qa/unit/dialogs-test.cxx                                    |    2 
 sd/source/ui/accessibility/AccessibleSlideSorterView.cxx       |    7 
 sd/source/ui/dlg/headerfooterdlg.cxx                           |    8 
 sd/source/ui/dlg/sddlgfact.cxx                                 |    4 
 sd/source/ui/dlg/sddlgfact.hxx                                 |    2 
 sd/source/ui/docshell/docshel3.cxx                             |    6 
 sd/source/ui/docshell/sdclient.cxx                             |   14 -
 sd/source/ui/func/fuarea.cxx                                   |   14 -
 sd/source/ui/func/fubullet.cxx                                 |   31 +--
 sd/source/ui/func/fuchar.cxx                                   |   14 -
 sd/source/ui/func/fucon3d.cxx                                  |   16 -
 sd/source/ui/func/fuconarc.cxx                                 |   12 -
 sd/source/ui/func/fuconbez.cxx                                 |   16 -
 sd/source/ui/func/fuconcs.cxx                                  |   12 -
 sd/source/ui/func/fuconnct.cxx                                 |    8 
 sd/source/ui/func/fuconrec.cxx                                 |   25 +-
 sd/source/ui/func/fuconstr.cxx                                 |   10 -
 sd/source/ui/func/fuconuno.cxx                                 |   12 -
 sd/source/ui/func/fucopy.cxx                                   |   16 -
 sd/source/ui/func/fucushow.cxx                                 |   14 -
 sd/source/ui/func/fudraw.cxx                                   |   34 +--
 sd/source/ui/func/fudspord.cxx                                 |   10 -
 sd/source/ui/func/fuediglu.cxx                                 |   10 -
 sd/source/ui/func/fuexecuteinteraction.cxx                     |   22 +-
 sd/source/ui/func/fuexpand.cxx                                 |   10 -
 sd/source/ui/func/fuformatpaintbrush.cxx                       |   25 +-
 sd/source/ui/func/fuhhconv.cxx                                 |   29 +--
 sd/source/ui/func/fuinsert.cxx                                 |   54 +++---
 sd/source/ui/func/fuinsfil.cxx                                 |   22 +-
 sd/source/ui/func/fuline.cxx                                   |   14 -
 sd/source/ui/func/fulinend.cxx                                 |    8 
 sd/source/ui/func/fulink.cxx                                   |   13 -
 sd/source/ui/func/fumeasur.cxx                                 |    8 
 sd/source/ui/func/fumorph.cxx                                  |    8 
 sd/source/ui/func/funavig.cxx                                  |   35 +---
 sd/source/ui/func/fuoaprms.cxx                                 |   14 -
 sd/source/ui/func/fuolbull.cxx                                 |   22 +-
 sd/source/ui/func/fuoltext.cxx                                 |   24 +-
 sd/source/ui/func/fupage.cxx                                   |   12 -
 sd/source/ui/func/fuparagr.cxx                                 |   12 -
 sd/source/ui/func/fupoor.cxx                                   |   80 ++++-----
 sd/source/ui/func/fuprlout.cxx                                 |   24 +-
 sd/source/ui/func/fuprobjs.cxx                                 |   12 -
 sd/source/ui/func/fuscale.cxx                                  |   54 ++----
 sd/source/ui/func/fusearch.cxx                                 |   18 +-
 sd/source/ui/func/fusel.cxx                                    |   46 ++---
 sd/source/ui/func/fusldlg.cxx                                  |   10 -
 sd/source/ui/func/fusnapln.cxx                                 |   14 -
 sd/source/ui/func/fusumry.cxx                                  |   10 -
 sd/source/ui/func/futempl.cxx                                  |   26 +--
 sd/source/ui/func/futext.cxx                                   |   42 ++--
 sd/source/ui/func/futhes.cxx                                   |   12 -
 sd/source/ui/func/futransf.cxx                                 |   16 -
 sd/source/ui/func/futxtatt.cxx                                 |    8 
 sd/source/ui/func/fuvect.cxx                                   |    8 
 sd/source/ui/func/fuzoom.cxx                                   |   26 +--
 sd/source/ui/inc/BezierObjectBar.hxx                           |    4 
 sd/source/ui/inc/Client.hxx                                    |    4 
 sd/source/ui/inc/GraphicObjectBar.hxx                          |    2 
 sd/source/ui/inc/MediaObjectBar.hxx                            |    2 
 sd/source/ui/inc/NotesPanelViewShell.hxx                       |    4 
 sd/source/ui/inc/SlideSorter.hxx                               |    4 
 sd/source/ui/inc/TextObjectBar.hxx                             |    8 
 sd/source/ui/inc/fuarea.hxx                                    |    4 
 sd/source/ui/inc/fubullet.hxx                                  |    4 
 sd/source/ui/inc/fuchar.hxx                                    |    4 
 sd/source/ui/inc/fucon3d.hxx                                   |    4 
 sd/source/ui/inc/fuconarc.hxx                                  |    4 
 sd/source/ui/inc/fuconbez.hxx                                  |    4 
 sd/source/ui/inc/fuconcs.hxx                                   |    4 
 sd/source/ui/inc/fuconnct.hxx                                  |    4 
 sd/source/ui/inc/fuconrec.hxx                                  |    4 
 sd/source/ui/inc/fuconstr.hxx                                  |    2 
 sd/source/ui/inc/fuconuno.hxx                                  |    4 
 sd/source/ui/inc/fucopy.hxx                                    |    4 
 sd/source/ui/inc/fucushow.hxx                                  |    4 
 sd/source/ui/inc/fudraw.hxx                                    |    2 
 sd/source/ui/inc/fudspord.hxx                                  |    4 
 sd/source/ui/inc/fuediglu.hxx                                  |    4 
 sd/source/ui/inc/fuexecuteinteraction.hxx                      |    4 
 sd/source/ui/inc/fuexpand.hxx                                  |    4 
 sd/source/ui/inc/fuformatpaintbrush.hxx                        |    4 
 sd/source/ui/inc/fuhhconv.hxx                                  |    4 
 sd/source/ui/inc/fuinsert.hxx                                  |   16 -
 sd/source/ui/inc/fuinsfil.hxx                                  |    4 
 sd/source/ui/inc/fuline.hxx                                    |    4 
 sd/source/ui/inc/fulinend.hxx                                  |    4 
 sd/source/ui/inc/fulink.hxx                                    |    4 
 sd/source/ui/inc/fumeasur.hxx                                  |    4 
 sd/source/ui/inc/fumorph.hxx                                   |    4 
 sd/source/ui/inc/funavig.hxx                                   |    4 
 sd/source/ui/inc/fuoaprms.hxx                                  |    4 
 sd/source/ui/inc/fuolbull.hxx                                  |    4 
 sd/source/ui/inc/fuoltext.hxx                                  |    6 
 sd/source/ui/inc/fupage.hxx                                    |    4 
 sd/source/ui/inc/fuparagr.hxx                                  |    4 
 sd/source/ui/inc/fupoor.hxx                                    |    8 
 sd/source/ui/inc/fuprlout.hxx                                  |    4 
 sd/source/ui/inc/fuprobjs.hxx                                  |    4 
 sd/source/ui/inc/fuscale.hxx                                   |    4 
 sd/source/ui/inc/fusearch.hxx                                  |    4 
 sd/source/ui/inc/fusel.hxx                                     |    4 
 sd/source/ui/inc/fusldlg.hxx                                   |    4 
 sd/source/ui/inc/fusnapln.hxx                                  |    4 
 sd/source/ui/inc/fusumry.hxx                                   |    4 
 sd/source/ui/inc/futempl.hxx                                   |    4 
 sd/source/ui/inc/futext.hxx                                    |    4 
 sd/source/ui/inc/futhes.hxx                                    |    4 
 sd/source/ui/inc/futransf.hxx                                  |    4 
 sd/source/ui/inc/futxtatt.hxx                                  |    4 
 sd/source/ui/inc/fuvect.hxx                                    |    4 
 sd/source/ui/inc/fuzoom.hxx                                    |    4 
 sd/source/ui/inc/headerfooterdlg.hxx                           |    4 
 sd/source/ui/inc/zoomlist.hxx                                  |    4 
 sd/source/ui/slidesorter/controller/SlideSorterController.cxx  |   28 +--
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx           |   25 +-
 sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx |    8 
 sd/source/ui/slidesorter/controller/SlsListener.cxx            |   13 -
 sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx    |   21 +-
 sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx   |   22 +-
 sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx    |   30 +--
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx         |   86 
++++------
 sd/source/ui/slidesorter/model/SlideSorterModel.cxx            |   33 +--
 sd/source/ui/slidesorter/shell/SlideSorter.cxx                 |   14 -
 sd/source/ui/slidesorter/view/SlideSorterView.cxx              |    4 
 sd/source/ui/table/tableobjectbar.cxx                          |   14 -
 sd/source/ui/table/tableobjectbar.hxx                          |    4 
 sd/source/ui/view/GraphicObjectBar.cxx                         |    6 
 sd/source/ui/view/MediaObjectBar.cxx                           |    6 
 sd/source/ui/view/NotesPanelViewShell.cxx                      |   46 ++---
 sd/source/ui/view/drbezob.cxx                                  |   14 -
 sd/source/ui/view/drtxtob.cxx                                  |   39 ++--
 sd/source/ui/view/drtxtob1.cxx                                 |   48 ++---
 sd/source/ui/view/drviews2.cxx                                 |   70 ++++----
 sd/source/ui/view/drviews3.cxx                                 |    2 
 sd/source/ui/view/drviewsa.cxx                                 |   10 -
 sd/source/ui/view/drviewse.cxx                                 |   22 +-
 sd/source/ui/view/outlnvs2.cxx                                 |   24 +-
 sd/source/ui/view/outlnvsh.cxx                                 |    2 
 sd/source/ui/view/sdview.cxx                                   |    2 
 sd/source/ui/view/sdview4.cxx                                  |    2 
 sd/source/ui/view/viewshe2.cxx                                 |    2 
 sd/source/ui/view/viewshel.cxx                                 |   10 -
 sd/source/ui/view/zoomlist.cxx                                 |   10 -
 145 files changed, 920 insertions(+), 980 deletions(-)

New commits:
commit 9e56c2ea7ff7e9816414fe333c6a733bd7f424ad
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed May 14 13:56:54 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed May 14 21:13:32 2025 +0200

    sd: pass ViewShell by ref
    
    Change-Id: Idbc66dedfb64c28bc699b54f9c433cfa535598ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185309
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx
index 924caf904b17..2cb49786b027 100644
--- a/sd/inc/sdabstdlg.hxx
+++ b/sd/inc/sdabstdlg.hxx
@@ -182,7 +182,7 @@ public:
 
     virtual VclPtr<VclAbstractDialog>          
CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) 
= 0;
 
-    virtual VclPtr<AbstractHeaderFooterDialog> 
CreateHeaderFooterDialog(sd::ViewShell* pViewShell,
+    virtual VclPtr<AbstractHeaderFooterDialog> 
CreateHeaderFooterDialog(sd::ViewShell& rViewShell,
                                                                         
weld::Window* pParent,
                                                                         
SdDrawDocument* pDoc,
                                                                         
SdPage* pCurrentPage) = 0;
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 0a00c80f88a7..26b88712bb88 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -547,7 +547,7 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
             CPPUNIT_ASSERT(pSdPage);
             pRetval = getSdAbstractDialogFactory()->CreateHeaderFooterDialog(
-                getViewShell(),
+                *getViewShell(),
                 Application::GetDefDialogParent(),
                 pDrawDoc,
                 pSdPage);
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx 
b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
index 6b5a89ea91ff..fe6021702f94 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
@@ -630,8 +630,7 @@ AccessibleSlideSorterObject* 
AccessibleSlideSorterView::Implementation::GetAcces
 void AccessibleSlideSorterView::Implementation::ConnectListeners()
 {
     StartListening (*mrSlideSorter.GetModel().GetDocument());
-    if (mrSlideSorter.GetViewShell() != nullptr)
-        StartListening (*mrSlideSorter.GetViewShell());
+    StartListening (mrSlideSorter.GetViewShell());
     mbListeningToDocument = true;
 
     if (mpWindow != nullptr)
@@ -661,10 +660,10 @@ void 
AccessibleSlideSorterView::Implementation::ReleaseListeners()
 
     if (mbListeningToDocument)
     {
-        if (mrSlideSorter.GetViewShell() != nullptr && 
!IsListening(*mrSlideSorter.GetViewShell()))
+        if (!IsListening(mrSlideSorter.GetViewShell()))
         {   // ??? is it even possible that ConnectListeners is called with no
             // view shell and this one with a view shell?
-            StartListening(*mrSlideSorter.GetViewShell());
+            StartListening(mrSlideSorter.GetViewShell());
         }
         EndListening (*mrSlideSorter.GetModel().GetDocument());
         mbListeningToDocument = false;
diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx 
b/sd/source/ui/dlg/headerfooterdlg.cxx
index 056c56b32e97..95f8249699bc 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -166,11 +166,11 @@ public:
 
 using namespace ::sd;
 
-HeaderFooterDialog::HeaderFooterDialog(ViewShell* pViewShell, weld::Window* 
pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
+HeaderFooterDialog::HeaderFooterDialog(ViewShell& rViewShell, weld::Window* 
pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
     : GenericDialogController(pParent, 
u"modules/simpress/ui/headerfooterdialog.ui"_ustr, u"HeaderFooterDialog"_ustr)
     , mpDoc( pDoc )
     , mpCurrentPage( pCurrentPage )
-    , mpViewShell( pViewShell )
+    , mrViewShell( rViewShell )
     , mxTabCtrl(m_xBuilder->weld_notebook(u"tabcontrol"_ustr))
     , mxPBApplyToAll(m_xBuilder->weld_button(u"apply_all"_ustr))
     , mxPBApply(m_xBuilder->weld_button(u"apply"_ustr))
@@ -251,7 +251,7 @@ short HeaderFooterDialog::run()
 {
     short nRet = GenericDialogController::run();
     if (nRet)
-        mpViewShell->GetDocSh()->SetModified();
+        mrViewShell.GetDocSh()->SetModified();
     return nRet;
 }
 
@@ -344,7 +344,7 @@ void HeaderFooterDialog::apply( bool bToAll, bool 
bForceSlides )
     }
 
     // give the undo group to the undo manager
-    
mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
+    
mrViewShell.GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
 }
 
 void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const 
HeaderFooterSettings& rNewSettings )
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index c7d592438897..fa7e9c05036e 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -425,12 +425,12 @@ VclPtr<VclAbstractDialog> 
SdAbstractDialogFactory_Impl::CreateMasterLayoutDialog
     return 
VclPtr<SdAbstractGenericDialog_Impl<sd::MasterLayoutDialog>>::Create(pParent, 
pDoc, pCurrentPage);
 }
 
-VclPtr<AbstractHeaderFooterDialog> 
SdAbstractDialogFactory_Impl::CreateHeaderFooterDialog(sd::ViewShell* 
pViewShell,
+VclPtr<AbstractHeaderFooterDialog> 
SdAbstractDialogFactory_Impl::CreateHeaderFooterDialog(sd::ViewShell& 
rViewShell,
     weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
 {
     using AbstractHeaderFooterDialog_Impl
         = ScreenshottedDialog_Impl_Async<AbstractHeaderFooterDialog, 
sd::HeaderFooterDialog>;
-    return VclPtr<AbstractHeaderFooterDialog_Impl>::Create(pViewShell, 
pParent, pDoc, pCurrentPage);
+    return VclPtr<AbstractHeaderFooterDialog_Impl>::Create(rViewShell, 
pParent, pDoc, pCurrentPage);
 }
 
 VclPtr<VclAbstractDialog> 
SdAbstractDialogFactory_Impl::CreateSdPhotoAlbumDialog(weld::Window* pParent, 
SdDrawDocument* pDoc)
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 3a2488cb6753..7d52c2e584aa 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -53,7 +53,7 @@ public:
 
     virtual VclPtr<VclAbstractDialog>          
CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) 
override;
 
-    virtual VclPtr<AbstractHeaderFooterDialog> 
CreateHeaderFooterDialog(sd::ViewShell* pViewShell,
+    virtual VclPtr<AbstractHeaderFooterDialog> 
CreateHeaderFooterDialog(sd::ViewShell& rViewShell,
                                                                         
weld::Window* pParent,
                                                                         
SdDrawDocument* pDoc,
                                                                         
SdPage* pCurrentPage) override;
diff --git a/sd/source/ui/docshell/docshel3.cxx 
b/sd/source/ui/docshell/docshel3.cxx
index c3d129678bbb..61c0031096c2 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -209,7 +209,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
                     if (!xFuSearch.is())
                     {
                         xFuSearch = rtl::Reference<FuSearch>(
-                            FuSearch::createPtr(mpViewShell,
+                            FuSearch::createPtr(*mpViewShell,
                                                 mpViewShell->GetActiveWindow(),
                                                 pView, mpDoc, rReq));
 
@@ -270,7 +270,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
         {
             if( mpViewShell )
             {
-                rtl::Reference<FuPoor> aFunc( FuHangulHanjaConversion::Create( 
mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, 
rReq ) );
+                rtl::Reference<FuPoor> aFunc( 
FuHangulHanjaConversion::Create(*mpViewShell, mpViewShell->GetActiveWindow(), 
mpViewShell->GetView(), mpDoc, rReq ) );
                 static_cast< FuHangulHanjaConversion* >( aFunc.get() 
)->StartConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, nullptr, 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true );
             }
         }
@@ -280,7 +280,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
         {
             if( mpViewShell )
             {
-                rtl::Reference<FuPoor> aFunc( FuHangulHanjaConversion::Create( 
mpViewShell, mpViewShell->GetActiveWindow(), mpViewShell->GetView(), mpDoc, 
rReq ) );
+                rtl::Reference<FuPoor> aFunc( 
FuHangulHanjaConversion::Create(*mpViewShell, mpViewShell->GetActiveWindow(), 
mpViewShell->GetView(), mpDoc, rReq ) );
                 static_cast< FuHangulHanjaConversion* >( aFunc.get() 
)->StartChineseConversion();
             }
         }
diff --git a/sd/source/ui/docshell/sdclient.cxx 
b/sd/source/ui/docshell/sdclient.cxx
index c0b7b38edb4a..a066b81e8cbe 100644
--- a/sd/source/ui/docshell/sdclient.cxx
+++ b/sd/source/ui/docshell/sdclient.cxx
@@ -29,9 +29,9 @@ using namespace com::sun::star;
 
 namespace sd {
 
-Client::Client(SdrOle2Obj* pObj, ViewShell* pViewShell, vcl::Window* pWindow) :
-    SfxInPlaceClient(pViewShell->GetViewShell(), pWindow, pObj->GetAspect() ),
-    mpViewShell(pViewShell),
+Client::Client(SdrOle2Obj* pObj, ViewShell& rViewShell, vcl::Window* pWindow) :
+    SfxInPlaceClient(rViewShell.GetViewShell(), pWindow, pObj->GetAspect() ),
+    mrViewShell(rViewShell),
     pSdrOle2Obj(pObj)
 {
     SetObject( pObj->GetObjRef() );
@@ -48,7 +48,7 @@ Client::~Client()
  */
 void Client::RequestNewObjectArea( ::tools::Rectangle& aObjRect )
 {
-    ::sd::View* pView = mpViewShell->GetView();
+    ::sd::View* pView = mrViewShell.GetView();
 
     bool bSizeProtect = false;
     bool bPosProtect = false;
@@ -91,7 +91,7 @@ void Client::RequestNewObjectArea( ::tools::Rectangle& 
aObjRect )
 
 void Client::ObjectAreaChanged()
 {
-    ::sd::View* pView = mpViewShell->GetView();
+    ::sd::View* pView = mrViewShell.GetView();
     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     if (rMarkList.GetMarkCount() != 1)
         return;
@@ -136,10 +136,10 @@ void Client::ViewChanged()
 
     //TODO/LATER: should we try to avoid the recalculation of the visareasize
     //if we know that it didn't change?
-    if (!mpViewShell->GetActiveWindow())
+    if (!mrViewShell.GetActiveWindow())
         return;
 
-    ::sd::View* pView = mpViewShell->GetView();
+    ::sd::View* pView = mrViewShell.GetView();
     if (!pView)
         return;
 
diff --git a/sd/source/ui/func/fuarea.cxx b/sd/source/ui/func/fuarea.cxx
index 8dd7543e3ba0..d24d155ccbef 100644
--- a/sd/source/ui/func/fuarea.cxx
+++ b/sd/source/ui/func/fuarea.cxx
@@ -31,14 +31,14 @@
 
 namespace sd {
 
-FuArea::FuArea( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* _pView, 
SdDrawDocument* pDoc, SfxRequest& rReq)
-: FuPoor(pViewSh, pWin, _pView, pDoc, rReq)
+FuArea::FuArea( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* _pView, 
SdDrawDocument* pDoc, SfxRequest& rReq)
+: FuPoor(rViewSh, pWin, _pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuArea::Create( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* _pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuArea::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* _pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuArea( pViewSh, pWin, _pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuArea( rViewSh, pWin, _pView, pDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -55,11 +55,11 @@ void FuArea::DoExecute( SfxRequest& rReq )
     mpView->GetAttributes( aNewAttr );
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    bool bHasSlideBackground = mpViewShell->GetDoc()->GetDocumentType() == 
DocumentType::Impress;
+    bool bHasSlideBackground = mrViewShell.GetDoc()->GetDocumentType() == 
DocumentType::Impress;
     VclPtr<AbstractSvxAreaTabDialog> pDlg(
-        pFact->CreateSvxAreaTabDialog(mpViewShell->GetFrameWeld(), &aNewAttr, 
mpDoc, true, bHasSlideBackground));
+        pFact->CreateSvxAreaTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, 
mpDoc, true, bHasSlideBackground));
 
-    pDlg->StartExecuteAsync([pDlg, pView = this->mpView, pViewShell = 
this->mpViewShell](sal_Int32 nResult){
+    pDlg->StartExecuteAsync([pDlg, pView = this->mpView, pViewShell = 
&this->mrViewShell](sal_Int32 nResult){
         if (nResult == RET_OK)
         {
             pView->SetAttributes (*(pDlg->GetOutputItemSet ()));
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx
index 299abd1c3641..d3a907bce9aa 100644
--- a/sd/source/ui/func/fubullet.cxx
+++ b/sd/source/ui/func/fubullet.cxx
@@ -55,18 +55,18 @@ const sal_Unicode CHAR_NNBSP        =   u'\x202F'; //NARROW 
NO-BREAK SPACE
 
 
 FuBullet::FuBullet (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* _pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, _pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, _pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuBullet::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuBullet::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuBullet( pViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuBullet( rViewSh, pWin, pView, pDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -104,17 +104,17 @@ void FuBullet::InsertFormattingMark( sal_Unicode cMark )
     ::Outliner*   pOL = nullptr;
 
     // depending on ViewShell set Outliner and OutlinerView
-    if( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  nullptr)
+    if( dynamic_cast< const DrawViewShell *>( &mrViewShell ) !=  nullptr)
     {
         pOV = mpView->GetTextEditOutlinerView();
         if (pOV)
             pOL = mpView->GetTextEditOutliner();
     }
-    else if( dynamic_cast< const OutlineViewShell *>( mpViewShell ) !=  
nullptr)
+    else if( dynamic_cast< const OutlineViewShell *>( &mrViewShell ) !=  
nullptr)
     {
         pOL = &static_cast<OutlineView*>(mpView)->GetOutliner();
         pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
-            mpViewShell->GetActiveWindow());
+            mrViewShell.GetActiveWindow());
     }
 
     // insert string
@@ -131,7 +131,7 @@ void FuBullet::InsertFormattingMark( sal_Unicode cMark )
     // prepare undo
     EditUndoManager& rUndoMgr =  pOL->GetUndoManager();
     rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR),
-                                u""_ustr, 0, 
mpViewShell->GetViewShellBase().GetViewShellId() );
+                                u""_ustr, 0, 
mrViewShell.GetViewShellBase().GetViewShellId() );
 
     // insert given text
     OUString aStr( cMark );
@@ -189,11 +189,8 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
 
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         css::uno::Reference<css::frame::XFrame> xFrame;
-        if (mpViewShell)
-        {
-            if (SfxViewFrame* pFrame = mpViewShell->GetFrame())
-                xFrame = pFrame->GetFrame().GetFrameInterface();
-        }
+        if (SfxViewFrame* pFrame = mrViewShell.GetFrame())
+            xFrame = pFrame->GetFrame().GetFrameInterface();
         VclPtr<SfxAbstractDialog> pDlg( 
pFact->CreateCharMapDialog(mpView->GetViewShell()->GetFrameWeld(), aSet,
             xFrame) );
 
@@ -216,7 +213,7 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
     ::Outliner*   pOL = nullptr;
 
     // determine depending on ViewShell Outliner and OutlinerView
-    if(dynamic_cast< const DrawViewShell *>( mpViewShell ))
+    if(dynamic_cast< const DrawViewShell *>( &mrViewShell ))
     {
         pOV = mpView->GetTextEditOutlinerView();
         if (pOV)
@@ -224,11 +221,11 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
             pOL = mpView->GetTextEditOutliner();
         }
     }
-    else if(dynamic_cast< const OutlineViewShell *>( mpViewShell ))
+    else if(dynamic_cast< const OutlineViewShell *>( &mrViewShell ))
     {
         pOL = &static_cast<OutlineView*>(mpView)->GetOutliner();
         pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
-            mpViewShell->GetActiveWindow());
+            mrViewShell.GetActiveWindow());
     }
 
     // insert special character
@@ -250,7 +247,7 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
     aOldSet.Put( pOV->GetAttribs() );
 
     EditUndoManager& rUndoMgr = pOL->GetUndoManager();
-    ViewShellId nViewShellId = mpViewShell ? 
mpViewShell->GetViewShellBase().GetViewShellId() : ViewShellId(-1);
+    ViewShellId nViewShellId = mrViewShell.GetViewShellBase().GetViewShellId();
     rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR),
                              u""_ustr, 0, nViewShellId );
     pOV->InsertText(aChars, true);
diff --git a/sd/source/ui/func/fuchar.cxx b/sd/source/ui/func/fuchar.cxx
index d5956e02b295..cd6f27da52be 100644
--- a/sd/source/ui/func/fuchar.cxx
+++ b/sd/source/ui/func/fuchar.cxx
@@ -37,18 +37,18 @@ namespace sd {
 
 
 FuChar::FuChar (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuChar::Create( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuChar::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuChar( pViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuChar( rViewSh, pWin, pView, pDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -62,11 +62,11 @@ void FuChar::DoExecute( SfxRequest& rReq )
         SfxItemSet aEditAttr( mpDoc->GetPool() );
         mpView->GetAttributes( aEditAttr );
 
-        SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR, EE_ITEMS_START, 
EE_ITEMS_END> aNewAttr(mpViewShell->GetPool());
+        SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR, EE_ITEMS_START, 
EE_ITEMS_END> aNewAttr(mrViewShell.GetPool());
         aNewAttr.Put( aEditAttr, false );
 
         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-        ScopedVclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSdTabCharDialog(mpViewShell->GetFrameWeld(), &aNewAttr, 
mpDoc->GetDocSh() ) );
+        ScopedVclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSdTabCharDialog(mrViewShell.GetFrameWeld(), &aNewAttr, 
mpDoc->GetDocSh() ) );
         if (rReq.GetSlot() == SID_CHAR_DLG_EFFECT)
         {
             pDlg->SetCurPageId(u"RID_SVXPAGE_CHAR_EFFECTS"_ustr);
@@ -112,7 +112,7 @@ void FuChar::DoExecute( SfxRequest& rReq )
                     SID_ATTR_CHAR_BACK_COLOR,
                     0 };
 
-    mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
+    mrViewShell.GetViewFrame()->GetBindings().Invalidate( SidArray );
 
     if( mpDoc->GetOnlineSpell() )
     {
diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx
index 066c8e45305d..8eea3e8b5213 100644
--- a/sd/source/ui/func/fucon3d.cxx
+++ b/sd/source/ui/func/fucon3d.cxx
@@ -51,19 +51,19 @@ namespace sd {
 
 
 FuConstruct3dObject::FuConstruct3dObject (
-    ViewShell*  pViewSh,
+    ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
     SdDrawDocument* pDoc,
     SfxRequest&     rReq)
-    : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConstruct3dObject::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuConstruct3dObject::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstruct3dObject* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstruct3dObject( pViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstruct3dObject( rViewSh, 
pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
@@ -72,7 +72,7 @@ rtl::Reference<FuPoor> FuConstruct3dObject::Create( 
ViewShell* pViewSh, ::sd::Wi
 void FuConstruct3dObject::DoExecute( SfxRequest& rReq )
 {
     FuConstruct::DoExecute( rReq );
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msDrawingObjectToolBar);
 }
@@ -307,7 +307,7 @@ void 
FuConstruct3dObject::ImpPrepareBasic3DShape(E3dCompoundObject const * p3DOb
 
     pScene->SetTransform(aTransformation * pScene->GetTransform());
 
-    SfxItemSet aAttr (mpViewShell->GetPool());
+    SfxItemSet aAttr (mrViewShell.GetPool());
     pScene->SetMergedItemSetAndBroadcast(aAttr);
 }
 
@@ -322,7 +322,7 @@ bool FuConstruct3dObject::MouseButtonDown(const MouseEvent& 
rMEvt)
         mpWindow->CaptureMouse();
         sal_uInt16 nDrgLog = sal_uInt16 ( 
mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
 
-        weld::WaitObject aWait(mpViewShell->GetFrameWeld());
+        weld::WaitObject aWait(mrViewShell.GetFrameWeld());
 
         rtl::Reference<E3dCompoundObject> p3DObj = ImpCreateBasic3DShape();
         rtl::Reference<E3dScene> pScene = 
mpView->SetCurrent3DObj(p3DObj.get());
@@ -383,7 +383,7 @@ bool FuConstruct3dObject::MouseButtonUp(const MouseEvent& 
rMEvt)
     bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn;
 
     if (!bPermanent)
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 
     return bReturn;
 }
diff --git a/sd/source/ui/func/fuconarc.cxx b/sd/source/ui/func/fuconarc.cxx
index 94718f1ed4c1..459b50463629 100644
--- a/sd/source/ui/func/fuconarc.cxx
+++ b/sd/source/ui/func/fuconarc.cxx
@@ -46,19 +46,19 @@ namespace sd {
 
 
 FuConstructArc::FuConstructArc (
-    ViewShell*  pViewSh,
+    ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
     SdDrawDocument* pDoc,
     SfxRequest&     rReq )
-    : FuConstruct( pViewSh, pWin, pView, pDoc, rReq )
+    : FuConstruct( rViewSh, pWin, pView, pDoc, rReq )
 {
 }
 
-rtl::Reference<FuPoor> FuConstructArc::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent  )
+rtl::Reference<FuPoor> FuConstructArc::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent  )
 {
     FuConstructArc* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( pViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( rViewSh, pWin, 
pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
@@ -68,7 +68,7 @@ void FuConstructArc::DoExecute( SfxRequest& rReq )
 {
     FuConstruct::DoExecute( rReq );
 
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msDrawingObjectToolBar);
 
@@ -154,7 +154,7 @@ bool FuConstructArc::MouseButtonUp( const MouseEvent& rMEvt 
)
     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
 
     if (!bPermanent && bCreated)
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 
     return bReturn;
 }
diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx
index 881f27343d5d..483d61341d2e 100644
--- a/sd/source/ui/func/fuconbez.cxx
+++ b/sd/source/ui/func/fuconbez.cxx
@@ -59,12 +59,12 @@ namespace sd {
     sal_uInt16  mnWidth;         // Default: 0
     OUString    msShapeName;     // Default: ""*/
 FuConstructBezierPolygon::FuConstructBezierPolygon (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuConstruct(pViewSh, pWin, pView, pDoc, rReq),
+    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq),
       nEditMode(SID_BEZIER_MOVE),
       mnTransparence(0),
       mnWidth(0)
@@ -90,10 +90,10 @@ bool isSticky(const SfxRequest& rReq)
 
 }
 
-rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructBezierPolygon* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructBezierPolygon( 
pViewSh, pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructBezierPolygon( 
rViewSh, pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent || isSticky(rReq));
     return xFunc;
@@ -278,7 +278,7 @@ bool FuConstructBezierPolygon::MouseButtonUp(const 
MouseEvent& rMEvt )
 
     if ((!bPermanent && bCreated) || bDeleted)
     {
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
     }
 
     return bReturn;
@@ -353,8 +353,8 @@ void FuConstructBezierPolygon::SelectionHasChanged()
 {
     FuDraw::SelectionHasChanged();
 
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SelectionHasChanged(
-        *mpViewShell,
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SelectionHasChanged(
+        mrViewShell,
         *mpView);
 }
 
@@ -399,7 +399,7 @@ void FuConstructBezierPolygon::SetEditMode(sal_uInt16 nMode)
     nEditMode = nMode;
     ForcePointer();
 
-    SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+    SfxBindings& rBindings = mrViewShell.GetViewFrame()->GetBindings();
     rBindings.Invalidate(SID_BEZIER_MOVE);
     rBindings.Invalidate(SID_BEZIER_INSERT);
 }
diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx
index 3c8b2344148e..9f33127d7b93 100644
--- a/sd/source/ui/func/fuconcs.cxx
+++ b/sd/source/ui/func/fuconcs.cxx
@@ -46,19 +46,19 @@ namespace sd {
 
 
 FuConstructCustomShape::FuConstructCustomShape (
-        ViewShell*          pViewSh,
+        ViewShell&          rViewSh,
         ::sd::Window*       pWin,
         ::sd::View*         pView,
         SdDrawDocument*     pDoc,
         SfxRequest&         rReq ) :
-    FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+    FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConstructCustomShape::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuConstructCustomShape::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructCustomShape* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( pViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( rViewSh, 
pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent( bPermanent );
     return xFunc;
@@ -75,7 +75,7 @@ void FuConstructCustomShape::DoExecute( SfxRequest& rReq )
         aCustomShape = rItm.GetValue();
     }
 
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msDrawingObjectToolBar);
 }
@@ -149,7 +149,7 @@ bool FuConstructCustomShape::MouseButtonUp(const 
MouseEvent& rMEvt)
     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
 
     if (!bPermanent)
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 
     return bReturn;
 }
diff --git a/sd/source/ui/func/fuconnct.cxx b/sd/source/ui/func/fuconnct.cxx
index fc95b4907746..8e3f557b4fae 100644
--- a/sd/source/ui/func/fuconnct.cxx
+++ b/sd/source/ui/func/fuconnct.cxx
@@ -28,18 +28,18 @@ namespace sd {
 
 
 FuConnectionDlg::FuConnectionDlg (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConnectionDlg::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuConnectionDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuConnectionDlg( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuConnectionDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index af031550258f..a636b5aca43b 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -78,12 +78,12 @@ namespace sd {
 
 
 FuConstructRectangle::FuConstructRectangle (
-    ViewShell*  pViewSh,
+    ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
     SdDrawDocument* pDoc,
     SfxRequest&     rReq)
-    : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
     , mnFillTransparence(0)
     , mnLineStyle(SAL_MAX_UINT16)
 {
@@ -108,10 +108,10 @@ bool isSticky(const SfxRequest& rReq)
 
 }
 
-rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructRectangle* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( pViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( rViewSh, 
pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent || isSticky(rReq));
     return xFunc;
@@ -121,7 +121,7 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
 {
     FuConstruct::DoExecute( rReq );
 
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msDrawingObjectToolBar);
 
@@ -341,7 +341,7 @@ bool FuConstructRectangle::MouseButtonUp(const MouseEvent& 
rMEvt)
     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
 
     if (!bPermanent)
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 
     return bReturn;
 }
@@ -507,18 +507,13 @@ void FuConstructRectangle::Deactivate()
     }
 
     // Finished drawing a signature rectangle, now set it up.
-    if (!mpViewShell)
-    {
-        return;
-    }
-
-    SfxViewShell* pViewShell = mpViewShell->GetViewShell();
+    SfxViewShell* pViewShell = mrViewShell.GetViewShell();
     svl::crypto::CertificateOrName aCertificateOrName = 
pViewShell->GetSigningCertificate();
     if (aCertificateOrName.m_aName.isEmpty())
     {
         aCertificateOrName.m_xCertificate = 
svx::SignatureLineHelper::getSignatureCertificate(
-            mpViewShell->GetObjectShell(), mpViewShell->GetViewShell(),
-            mpViewShell->GetFrameWeld());
+            mrViewShell.GetObjectShell(), mrViewShell.GetViewShell(),
+            mrViewShell.GetFrameWeld());
         if (!aCertificateOrName.m_xCertificate.is())
         {
             return;
@@ -528,7 +523,7 @@ void FuConstructRectangle::Deactivate()
     svx::SignatureLineHelper::setShapeCertificate(pViewShell, 
aCertificateOrName);
 
     // Update infobar to offer "finish signing".
-    SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
+    SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
     if (pFrame && pFrame->HasInfoBarWithID(u"readonly"))
     {
         pFrame->RemoveInfoBar(u"readonly");
diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx
index 01f56174980d..7c42b554d550 100644
--- a/sd/source/ui/func/fuconstr.cxx
+++ b/sd/source/ui/func/fuconstr.cxx
@@ -51,12 +51,12 @@ namespace sd {
 
 
 FuConstruct::FuConstruct (
-    ViewShell*      pViewSh,
+    ViewShell&      rViewSh,
     ::sd::Window*           pWin,
     ::sd::View*         pView,
     SdDrawDocument* pDoc,
     SfxRequest&     rReq)
-    : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
+    : FuDraw(rViewSh, pWin, pView, pDoc, rReq),
       bSelectionChanged(false)
 {
 }
@@ -142,7 +142,7 @@ bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
 
     if ( mpView && mpView->IsDragObj() )
     {
-        FrameView* pFrameView = mpViewShell->GetFrameView();
+        FrameView* pFrameView = mrViewShell.GetFrameView();
         bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
 
         if (bDragWithCopy)
@@ -179,7 +179,7 @@ bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
                 mpView->MarkObj(aPnt, nHitLog);
             }
 
-            
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+            
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
         }
         else if (rMEvt.IsLeft() && !rMEvt.IsShift() && !rMEvt.IsMod1() && 
!rMEvt.IsMod2() &&
                  !bSelectionChanged                   &&
@@ -196,7 +196,7 @@ bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
 
             const bool bTiledRendering = 
comphelper::LibreOfficeKit::isActive();
             if (!bTiledRendering && (mpView->GetDragMode() == 
SdrDragMode::Move && mpView->IsRotateAllowed() &&
-                (mpViewShell->GetFrameView()->IsClickChangeRotation() ||
+                (mrViewShell.GetFrameView()->IsClickChangeRotation() ||
                  (pSingleObj && 
pSingleObj->GetObjInventor()==SdrInventor::E3d))))
             {
                 mpView->SetDragMode(SdrDragMode::Rotate);
diff --git a/sd/source/ui/func/fuconuno.cxx b/sd/source/ui/func/fuconuno.cxx
index 6086d62a0ea4..88b0da9a3abd 100644
--- a/sd/source/ui/func/fuconuno.cxx
+++ b/sd/source/ui/func/fuconuno.cxx
@@ -38,21 +38,21 @@ namespace sd {
 
 
 FuConstructUnoControl::FuConstructUnoControl (
-    ViewShell*  pViewSh,
+    ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
     SdDrawDocument* pDoc,
     SfxRequest&     rReq)
-    : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
     , nInventor(SdrInventor::Unknown)
     , nIdentifier(SdrObjKind::NONE)
 {
 }
 
-rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructUnoControl* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( pViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( rViewSh, 
pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
@@ -69,7 +69,7 @@ void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
     if( pIdentifierItem )
         nIdentifier = static_cast<SdrObjKind>(pIdentifierItem->GetValue());
 
-    mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msDrawingObjectToolBar);
 }
@@ -105,7 +105,7 @@ bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& 
rMEvt)
     bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
 
     if (!bPermanent)
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 
     return bReturn;
 }
diff --git a/sd/source/ui/func/fucopy.cxx b/sd/source/ui/func/fucopy.cxx
index 4976683292ec..8009fb36baab 100644
--- a/sd/source/ui/func/fucopy.cxx
+++ b/sd/source/ui/func/fucopy.cxx
@@ -44,18 +44,18 @@ namespace sd {
 
 
 FuCopy::FuCopy (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuCopy::Create( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuCopy::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuCopy( pViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuCopy( rViewSh, pWin, pView, pDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -75,7 +75,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
 
     if( !pArgs )
     {
-        SfxItemSetFixed<ATTR_COPY_START, ATTR_COPY_END> aSet( 
mpViewShell->GetPool() );
+        SfxItemSetFixed<ATTR_COPY_START, ATTR_COPY_END> aSet( 
mrViewShell.GetPool() );
 
         // indicate color attribute
         SfxItemSet aAttr( mpDoc->GetPool() );
@@ -97,7 +97,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
         }
 
         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-        ScopedVclPtr<AbstractCopyDlg> 
pDlg(pFact->CreateCopyDlg(mpViewShell->GetFrameWeld(), aSet, mpView ));
+        ScopedVclPtr<AbstractCopyDlg> 
pDlg(pFact->CreateCopyDlg(mrViewShell.GetFrameWeld(), aSet, mpView ));
 
         sal_uInt16 nResult = pDlg->Execute();
 
@@ -202,7 +202,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
 
         if( ( 1 == i ) && bColor )
         {
-            SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR> aNewSet( 
mpViewShell->GetPool() );
+            SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR> aNewSet( 
mrViewShell.GetPool() );
             aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
             aNewSet.Put( XFillColorItem( OUString(), aStartColor ) );
             mpView->SetAttributes( aNewSet );
@@ -264,7 +264,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
             sal_uInt8 nGreen = aStartColor.GetGreen() + 
static_cast<sal_uInt8>( ( static_cast<::tools::Long>(aEndColor.GetGreen()) - 
static_cast<::tools::Long>(aStartColor.GetGreen()) ) *  
static_cast<::tools::Long>(i) / static_cast<::tools::Long>(nNumber) );
             sal_uInt8 nBlue = aStartColor.GetBlue() + static_cast<sal_uInt8>( 
( static_cast<::tools::Long>(aEndColor.GetBlue()) - 
static_cast<::tools::Long>(aStartColor.GetBlue()) ) * 
static_cast<::tools::Long>(i) / static_cast<::tools::Long>(nNumber) );
             Color aNewColor( nRed, nGreen, nBlue );
-            SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR> aNewSet( 
mpViewShell->GetPool() );
+            SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR> aNewSet( 
mrViewShell.GetPool() );
             aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
             aNewSet.Put( XFillColorItem( OUString(), aNewColor ) );
             mpView->SetAttributes( aNewSet );
diff --git a/sd/source/ui/func/fucushow.cxx b/sd/source/ui/func/fucushow.cxx
index eb3b12211085..5fa58f43b329 100644
--- a/sd/source/ui/func/fucushow.cxx
+++ b/sd/source/ui/func/fucushow.cxx
@@ -33,18 +33,18 @@ namespace sd {
 
 
 FuCustomShowDlg::FuCustomShowDlg (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window*    pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
+    : FuPoor( rViewSh, pWin, pView, pDoc, rReq )
 {
 }
 
-rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuCustomShowDlg( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuCustomShowDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -52,7 +52,7 @@ rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell* 
pViewSh, ::sd::Window
 void FuCustomShowDlg::DoExecute( SfxRequest& )
 {
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-    vcl::Window* pWin = mpViewShell->GetActiveWindow();
+    vcl::Window* pWin = mrViewShell.GetActiveWindow();
     ScopedVclPtr<AbstractSdCustomShowDlg> pDlg( 
pFact->CreateSdCustomShowDlg(pWin ? pWin->GetFrameWeld() : nullptr, *mpDoc) );
     sal_uInt16 nRet = pDlg->Execute();
     mpDoc->SetChanged();
@@ -67,9 +67,9 @@ void FuCustomShowDlg::DoExecute( SfxRequest& )
             rSettings.mbCustomShow = pDlg->IsCustomShow();
         }
 
-        mpViewShell->SetStartShowWithDialog(true);
+        mrViewShell.SetStartShowWithDialog(true);
 
-        mpViewShell->GetViewFrame()->GetDispatcher()->Execute( 
SID_PRESENTATION,
+        mrViewShell.GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION,
                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
     }
     if (nRet == RET_OK)
diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx
index 28e1bf7e96f3..b72ab9399322 100644
--- a/sd/source/ui/func/fudraw.cxx
+++ b/sd/source/ui/func/fudraw.cxx
@@ -62,9 +62,9 @@ namespace sd {
 /**
  * Base-class for all drawmodul-specific functions
  */
-FuDraw::FuDraw(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
+FuDraw::FuDraw(ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
                SdDrawDocument* pDoc, SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
     , aNewPointer(PointerStyle::Arrow)
     , aOldPointer(PointerStyle::Arrow)
     , bMBDown(false)
@@ -85,7 +85,7 @@ FuDraw::~FuDraw()
  */
 void FuDraw::DoModifiers(const MouseEvent& rMEvt, bool bSnapModPressed)
 {
-    FrameView* pFrameView = mpViewShell->GetFrameView();
+    FrameView* pFrameView = mrViewShell.GetFrameView();
     bool bGridSnap = pFrameView->IsGridSnap();
     bGridSnap = (bSnapModPressed != bGridSnap);
 
@@ -149,7 +149,7 @@ bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
 
     if ( rMEvt.IsLeft() )
     {
-        FrameView* pFrameView = mpViewShell->GetFrameView();
+        FrameView* pFrameView = mrViewShell.GetFrameView();
 
         bool bOrtho = false;
 
@@ -213,7 +213,7 @@ bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
 
 bool FuDraw::MouseMove(const MouseEvent& rMEvt)
 {
-    FrameView* pFrameView = mpViewShell->GetFrameView();
+    FrameView* pFrameView = mrViewShell.GetFrameView();
     Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
 
     bool bOrtho = false;
@@ -288,7 +288,7 @@ bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
 
     if (mpView)
     {
-        FrameView* pFrameView = mpViewShell->GetFrameView();
+        FrameView* pFrameView = mrViewShell.GetFrameView();
         mpView->SetOrtho( pFrameView->IsOrtho() );
         mpView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
         mpView->SetSnapEnabled(true);
@@ -342,7 +342,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
                 else
                 {
                     // wait-mousepointer while deleting object
-                    weld::WaitObject aWait(mpViewShell->GetFrameWeld());
+                    weld::WaitObject aWait(mrViewShell.GetFrameWeld());
                     // delete object
                     mpView->DeleteMarked();
                 }
@@ -362,7 +362,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
                 // and thus is allowed to call SelectionHasChanged().
 
                 // Switch to FuSelect.
-                mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
+                mrViewShell.GetViewFrame()->GetDispatcher()->Execute(
                     SID_OBJECT_SELECT,
                     SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
 
@@ -486,10 +486,10 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt)
             mpWindow->SetPointer(PointerStyle::Fill);
         }
         else if (!pHdl &&
-                 
mpViewShell->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
+                 
mrViewShell.GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
         {
             // pipette mode
-            SfxChildWindow* pWnd = 
mpViewShell->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
+            SfxChildWindow* pWnd = 
mrViewShell.GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
             SvxBmpMask* pMask = pWnd ? 
static_cast<SvxBmpMask*>(pWnd->GetWindow()) : nullptr;
             if (pMask && pMask->IsEyedropping())
             {
@@ -645,7 +645,7 @@ void FuDraw::DoubleClick(const MouseEvent& rMEvt)
             {
                 // activate OLE-object
                 SfxInt16Item aItem(SID_OBJECT, 0);
-                mpViewShell->GetViewFrame()->
+                mrViewShell.GetViewFrame()->
                     GetDispatcher()->ExecuteList(SID_OBJECT,
                                                  SfxCallMode::ASYNCHRON | 
SfxCallMode::RECORD,
                                                  { &aItem });
@@ -653,17 +653,17 @@ void FuDraw::DoubleClick(const MouseEvent& rMEvt)
             else if (nInv == SdrInventor::Default && nSdrObjKind == 
SdrObjKind::Graphic
                      && pObj->IsEmptyPresObj() && !mpDocSh->IsReadOnly())
             {
-                mpViewShell->GetViewFrame()->
+                mrViewShell.GetViewFrame()->
                     GetDispatcher()->Execute( SID_INSERT_GRAPHIC,
                                               SfxCallMode::ASYNCHRON | 
SfxCallMode::RECORD );
             }
             else if ( ( DynCastSdrTextObj( pObj ) != nullptr || dynamic_cast< 
const SdrObjGroup *>( pObj ) !=  nullptr ) &&
                       !SdModule::get()->GetWaterCan() &&
-                      mpViewShell->GetFrameView()->IsDoubleClickTextEdit() &&
+                      mrViewShell.GetFrameView()->IsDoubleClickTextEdit() &&
                       !mpDocSh->IsReadOnly())
             {
                 SfxUInt16Item aItem(SID_TEXTEDIT, 2);
-                mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+                mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                         SID_TEXTEDIT,
                         SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
                         { &aItem });
@@ -677,7 +677,7 @@ void FuDraw::DoubleClick(const MouseEvent& rMEvt)
         }
     }
     else
-        
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
+        
mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
 }
 
 bool FuDraw::RequestHelp(const HelpEvent& rHEvt)
@@ -787,7 +787,7 @@ bool FuDraw::cancel()
         mpView->SdrEndTextEdit();
         bReturn = true;
 
-        SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+        SfxBindings& rBindings = mrViewShell.GetViewFrame()->GetBindings();
         rBindings.Invalidate( SID_DEC_INDENT );
         rBindings.Invalidate( SID_INC_INDENT );
         rBindings.Invalidate( SID_PARASPACE_INCREASE );
@@ -808,7 +808,7 @@ bool FuDraw::cancel()
         }
 
         // Switch to FuSelect.
-        mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
+        mrViewShell.GetViewFrame()->GetDispatcher()->Execute(
             SID_OBJECT_SELECT,
             SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
 
diff --git a/sd/source/ui/func/fudspord.cxx b/sd/source/ui/func/fudspord.cxx
index f129c523ccb4..ab95ed832113 100644
--- a/sd/source/ui/func/fudspord.cxx
+++ b/sd/source/ui/func/fudspord.cxx
@@ -30,8 +30,8 @@
 namespace sd {
 
 
-FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
-: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+FuDisplayOrder::FuDisplayOrder( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
+: FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 , maPtr(PointerStyle::Arrow)
 , mpRefObj(nullptr)
 {
@@ -46,9 +46,9 @@ void FuDisplayOrder::implClearOverlay()
     mpOverlay.reset();
 }
 
-rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( rViewSh, pWin, pView, 
pDoc, rReq ) );
     return xFunc;
 }
 
@@ -110,7 +110,7 @@ bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt)
         }
     }
 
-    mpViewShell->Cancel();
+    mrViewShell.Cancel();
 
     return true;
 }
diff --git a/sd/source/ui/func/fuediglu.cxx b/sd/source/ui/func/fuediglu.cxx
index 442c0fbb7e61..8e4b97306b2e 100644
--- a/sd/source/ui/func/fuediglu.cxx
+++ b/sd/source/ui/func/fuediglu.cxx
@@ -34,12 +34,12 @@ namespace sd {
 
 
 FuEditGluePoints::FuEditGluePoints (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuDraw(pViewSh, pWin, pView, pDoc, rReq)
+    : FuDraw(rViewSh, pWin, pView, pDoc, rReq)
      //Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point,
      //and SHIFT+ENTER key to decide the position and draw the new insert point
      ,bBeginInsertPoint(false),
@@ -47,10 +47,10 @@ FuEditGluePoints::FuEditGluePoints (
 {
 }
 
-rtl::Reference<FuPoor> FuEditGluePoints::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
+rtl::Reference<FuPoor> FuEditGluePoints::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuEditGluePoints* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuEditGluePoints( pViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuEditGluePoints( rViewSh, pWin, 
pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent( bPermanent );
     return xFunc;
@@ -60,7 +60,7 @@ void FuEditGluePoints::DoExecute( SfxRequest& rReq )
 {
     FuDraw::DoExecute( rReq );
     mpView->SetInsGluePointMode(false);
-    mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBar(
+    mrViewShell.GetViewShellBase().GetToolBarManager()->AddToolBar(
         ToolBarManager::ToolBarGroup::Function,
         ToolBarManager::msGluePointsToolBar);
 }
diff --git a/sd/source/ui/func/fuexecuteinteraction.cxx 
b/sd/source/ui/func/fuexecuteinteraction.cxx
index 1ab2fbc6733b..26ce457ba482 100644
--- a/sd/source/ui/func/fuexecuteinteraction.cxx
+++ b/sd/source/ui/func/fuexecuteinteraction.cxx
@@ -49,18 +49,18 @@ using namespace css;
 
 namespace sd
 {
-FuExecuteInteraction::FuExecuteInteraction(ViewShell* pViewSh, ::sd::Window* 
pWin,
+FuExecuteInteraction::FuExecuteInteraction(ViewShell& rViewSh, ::sd::Window* 
pWin,
                                            ::sd::View* pView, SdDrawDocument* 
pDoc,
                                            SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuExecuteInteraction::Create(ViewShell* pViewSh, 
::sd::Window* pWin,
+rtl::Reference<FuPoor> FuExecuteInteraction::Create(ViewShell& rViewSh, 
::sd::Window* pWin,
                                                     ::sd::View* pView, 
SdDrawDocument* pDoc,
                                                     SfxRequest& rReq)
 {
-    rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(pViewSh, pWin, 
pView, pDoc, rReq));
+    rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(rViewSh, pWin, 
pView, pDoc, rReq));
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -90,7 +90,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
         {
             // Jump to Bookmark (Page or Object)
             SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark());
-            mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+            mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                 SID_NAVIGATOR_OBJECT, SfxCallMode::SLOT | SfxCallMode::RECORD, 
{ &aItem });
         }
         break;
@@ -103,7 +103,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
             {
                 SfxStringItem aReferer(SID_REFERER, 
mpDocSh->GetMedium()->GetName());
                 SfxStringItem aStrItem(SID_FILE_NAME, sBookmark);
-                SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
+                SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
                 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
                 SfxBoolItem aBrowseItem(SID_BROWSE, true);
                 pFrame->GetDispatcher()->ExecuteList(
@@ -117,7 +117,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
         {
             // Jump to the previous page
             SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS);
-            mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+            mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { 
&aItem });
         }
         break;
@@ -126,7 +126,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
         {
             // Jump to the next page
             SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT);
-            mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+            mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { 
&aItem });
         }
         break;
@@ -135,7 +135,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
         {
             // Jump to the first page
             SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST);
-            mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+            mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { 
&aItem });
         }
         break;
@@ -144,7 +144,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
         {
             // Jump to the last page
             SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST);
-            mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+            mrViewShell.GetViewFrame()->GetDispatcher()->ExecuteList(
                 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { 
&aItem });
         }
         break;
@@ -171,7 +171,7 @@ void FuExecuteInteraction::DoExecute(SfxRequest&)
             // Assign verb
             mpView->UnmarkAll();
             mpView->MarkObj(pObj, mpView->GetSdrPageView());
-            DrawViewShell* pDrViewSh = 
static_cast<DrawViewShell*>(mpViewShell);
+            DrawViewShell* pDrViewSh = 
static_cast<DrawViewShell*>(&mrViewShell);
             pDrViewSh->DoVerb(static_cast<sal_Int16>(pInfo->mnVerb));
         }
         break;
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index bd12519a66bb..74625c53eff3 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -48,18 +48,18 @@ namespace sd {
 
 
 FuExpandPage::FuExpandPage (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuExpandPage::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuExpandPage::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuExpandPage( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuExpandPage( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -248,7 +248,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
             mpView->EndUndo();
     }
 
-    mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, 
SfxCallMode::SYNCHRON | SfxCallMode::RECORD);
+    mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, 
SfxCallMode::SYNCHRON | SfxCallMode::RECORD);
 }
 
 } // end of namespace sd
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx 
b/sd/source/ui/func/fuformatpaintbrush.cxx
index f41b4278c28f..19eafbdae1cc 100644
--- a/sd/source/ui/func/fuformatpaintbrush.cxx
+++ b/sd/source/ui/func/fuformatpaintbrush.cxx
@@ -58,17 +58,17 @@ bool ShouldPasteParaFormatPerSelection(const OutlinerView* 
pOLV)
 namespace sd {
 
 
-FuFormatPaintBrush::FuFormatPaintBrush( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
-: FuText(pViewSh, pWin, pView, pDoc, rReq)
+FuFormatPaintBrush::FuFormatPaintBrush( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+: FuText(rViewSh, pWin, pView, pDoc, rReq)
     , mnDepth(-1)
     , mbPermanent( false )
     , mbOldIsQuickTextEditMode(true)
 {
 }
 
-rtl::Reference<FuPoor> FuFormatPaintBrush::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuFormatPaintBrush::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuFormatPaintBrush( pViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuFormatPaintBrush( rViewSh, pWin, 
pView, pDoc, rReq ) );
     xFunc->DoExecute( rReq );
     return xFunc;
 }
@@ -89,9 +89,9 @@ void FuFormatPaintBrush::DoExecute( SfxRequest& rReq )
 
 void FuFormatPaintBrush::implcancel()
 {
-    if( mpViewShell && mpViewShell->GetViewFrame() )
+    if( mrViewShell.GetViewFrame() )
     {
-        SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
+        SfxViewFrame* pViewFrame = mrViewShell.GetViewFrame();
         pViewFrame->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
         pViewFrame->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
     }
@@ -110,7 +110,7 @@ bool FuFormatPaintBrush::MouseButtonDown(const MouseEvent& 
rMEvt)
         SdrViewEvent aVEvt;
         SdrHitKind eHit = mpView->PickAnything(rMEvt, 
SdrMouseEventKind::BUTTONDOWN, aVEvt);
 
-        if( (eHit == SdrHitKind::TextEdit) || (eHit == SdrHitKind::TextEditObj 
&& ( mpViewShell->GetFrameView()->IsQuickEdit() || 
dynamic_cast<sdr::table::SdrTableObj*>(aVEvt.mpObj) != nullptr ) ))
+        if( (eHit == SdrHitKind::TextEdit) || (eHit == SdrHitKind::TextEditObj 
&& ( mrViewShell.GetFrameView()->IsQuickEdit() || 
dynamic_cast<sdr::table::SdrTableObj*>(aVEvt.mpObj) != nullptr ) ))
         {
             SdrPageView* pPV=nullptr;
             sal_uInt16 nHitLog = sal_uInt16 ( 
mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
@@ -204,8 +204,7 @@ bool FuFormatPaintBrush::MouseButtonUp(const MouseEvent& 
rMEvt)
             pOLV->MouseButtonUp(rMEvt);
 
         Paste( bNoCharacterFormats, bNoParagraphFormats );
-        if(mpViewShell)
-            
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+        
mrViewShell.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
 
         if( mbPermanent )
             return true;
@@ -227,10 +226,10 @@ bool FuFormatPaintBrush::KeyInput(const KeyEvent& rKEvt)
 
 void FuFormatPaintBrush::Activate()
 {
-    mbOldIsQuickTextEditMode = mpViewShell->GetFrameView()->IsQuickEdit();
+    mbOldIsQuickTextEditMode = mrViewShell.GetFrameView()->IsQuickEdit();
     if( !mbOldIsQuickTextEditMode  )
     {
-        mpViewShell->GetFrameView()->SetQuickEdit(true);
+        mrViewShell.GetFrameView()->SetQuickEdit(true);
         mpView->SetQuickTextEditMode(true);
     }
 }
@@ -239,7 +238,7 @@ void FuFormatPaintBrush::Deactivate()
 {
     if( !mbOldIsQuickTextEditMode  )
     {
-        mpViewShell->GetFrameView()->SetQuickEdit(false);
+        mrViewShell.GetFrameView()->SetQuickEdit(false);
         mpView->SetQuickTextEditMode(false);
     }
 }
@@ -269,7 +268,7 @@ void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, 
bool bNoParagraphForma
     // except in a few cases (?)
     if( pObj )
     {
-        OUString sLabel( 
mpViewShell->GetViewShellBase().RetrieveLabelFromCommand(u".uno:FormatPaintbrush"_ustr
 ) );
+        OUString sLabel( 
mrViewShell.GetViewShellBase().RetrieveLabelFromCommand(u".uno:FormatPaintbrush"_ustr
 ) );
         mpDoc->BegUndo( sLabel );
         if (dynamic_cast< sdr::table::SdrTableObj* >( pObj ) == nullptr)
             mpDoc->AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( 
*pObj, false, true ) );
diff --git a/sd/source/ui/func/fuhhconv.cxx b/sd/source/ui/func/fuhhconv.cxx
index be40d46eea63..df7b95e316c1 100644
--- a/sd/source/ui/func/fuhhconv.cxx
+++ b/sd/source/ui/func/fuhhconv.cxx
@@ -52,21 +52,21 @@ namespace sd {
 
 
 FuHangulHanjaConversion::FuHangulHanjaConversion (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDocument,
     SfxRequest& rReq )
-       : FuPoor(pViewSh, pWin, pView, pDocument, rReq),
+       : FuPoor(rViewSh, pWin, pView, pDocument, rReq),
     pSdOutliner(nullptr),
     bOwnOutliner(false)
 {
-    if ( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  nullptr )
+    if ( dynamic_cast< const DrawViewShell *>( &mrViewShell ) !=  nullptr )
     {
         bOwnOutliner = true;
         pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
     }
-    else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) !=  
nullptr )
+    else if ( dynamic_cast< const OutlineViewShell *>( &mrViewShell ) !=  
nullptr )
     {
         bOwnOutliner = false;
         pSdOutliner = mpDoc->GetOutliner();
@@ -85,9 +85,9 @@ FuHangulHanjaConversion::~FuHangulHanjaConversion()
         delete pSdOutliner;
 }
 
-rtl::Reference<FuPoor> FuHangulHanjaConversion::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuHangulHanjaConversion::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuHangulHanjaConversion( pViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuHangulHanjaConversion( rViewSh, pWin, 
pView, pDoc, rReq ) );
     return xFunc;
 }
 
@@ -101,12 +101,11 @@ void FuHangulHanjaConversion::StartConversion( 
LanguageType nSourceLanguage, Lan
     mpView->BegUndo(SdResId(STR_UNDO_HANGULHANJACONVERSION));
 
     ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( 
SfxViewShell::Current() );
-    if (pBase != nullptr)
-        mpViewShell = pBase->GetMainViewShell().get();
+    ViewShell* pViewShell = pBase ? pBase->GetMainViewShell().get() : nullptr;
 
-    if( mpViewShell )
+    if( pViewShell )
     {
-        if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( mpViewShell 
) !=  nullptr && !bOwnOutliner )
+        if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) 
!=  nullptr && !bOwnOutliner )
         {
             pSdOutliner->EndConversion();
 
@@ -114,7 +113,7 @@ void FuHangulHanjaConversion::StartConversion( LanguageType 
nSourceLanguage, Lan
             pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
             pSdOutliner->BeginConversion();
         }
-        else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( 
mpViewShell ) !=  nullptr && bOwnOutliner )
+        else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( 
pViewShell ) !=  nullptr && bOwnOutliner )
         {
             pSdOutliner->EndConversion();
             delete pSdOutliner;
@@ -130,11 +129,11 @@ void FuHangulHanjaConversion::StartConversion( 
LanguageType nSourceLanguage, Lan
 
     // Due to changing between edit mode, notes mode, and handout mode the
     // view has most likely changed.  Get the new one.
-    mpViewShell = pBase ? pBase->GetMainViewShell().get() : nullptr;
-    if (mpViewShell != nullptr)
+    pViewShell = pBase ? pBase->GetMainViewShell().get() : nullptr;
+    if (pViewShell != nullptr)
     {
-        mpView = mpViewShell->GetView();
-        mpWindow = mpViewShell->GetActiveWindow();
+        mpView = pViewShell->GetView();
+        mpWindow = pViewShell->GetActiveWindow();
     }
     else
     {
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index a6e3a1cc04dd..44470c09b4d4 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -91,21 +91,21 @@ namespace sd {
 
 
 FuInsertGraphic::FuInsertGraphic (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq,
     bool replaceExistingImage)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq),
       mbReplaceExistingImage(replaceExistingImage)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView,
+rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView,
                                                 SdDrawDocument* pDoc, 
SfxRequest& rReq, bool replaceExistingImage )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( pViewSh, pWin, pView, 
pDoc, rReq, replaceExistingImage ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( rViewSh, pWin, pView, 
pDoc, rReq, replaceExistingImage ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -166,7 +166,7 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
                 aTransform.rotate( aRotation );
             }
         }
-        if( dynamic_cast< DrawViewShell *>( mpViewShell ) )
+        if( dynamic_cast< DrawViewShell *>( &mrViewShell ) )
         {
             sal_Int8    nAction = DND_ACTION_COPY;
             SdrObject* pPickObj = nullptr;
@@ -207,18 +207,18 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
 }
 
 FuInsertClipboard::FuInsertClipboard (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertClipboard::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertClipboard::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertClipboard( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertClipboard( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -229,7 +229,7 @@ void FuInsertClipboard::DoExecute( SfxRequest&  )
     SotClipboardFormatId                        nFormatId;
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    ScopedVclPtr<SfxAbstractPasteDialog> 
pDlg(pFact->CreatePasteDialog(mpViewShell->GetFrameWeld()));
+    ScopedVclPtr<SfxAbstractPasteDialog> 
pDlg(pFact->CreatePasteDialog(mrViewShell.GetFrameWeld()));
     pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, OUString() );
     pDlg->Insert( SotClipboardFormatId::LINK_SOURCE, OUString() );
     pDlg->Insert( SotClipboardFormatId::DRAWING, OUString() );
@@ -256,7 +256,7 @@ void FuInsertClipboard::DoExecute( SfxRequest&  )
                             mpWindow->PixelToLogic( ::tools::Rectangle( 
Point(), mpWindow->GetOutputSizePixel() ).Center() ),
                             nAction, false, nFormatId ))
     {
-        pDrViewSh = dynamic_cast<DrawViewShell*>(mpViewShell);
+        pDrViewSh = dynamic_cast<DrawViewShell*>(&mrViewShell);
     }
 
     if (!pDrViewSh)
@@ -276,18 +276,18 @@ void FuInsertClipboard::DoExecute( SfxRequest&  )
 }
 
 FuInsertOLE::FuInsertOLE (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertOLE( pViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertOLE( rViewSh, pWin, pView, pDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -312,7 +312,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
         else if (nSlotId == SID_INSERT_MATH)
             aName = SvGlobalName(SO3_SM_CLASSID);
 
-        uno::Reference < embed::XEmbeddedObject > xObj = 
mpViewShell->GetViewFrame()->GetObjectShell()->
+        uno::Reference < embed::XEmbeddedObject > xObj = 
mrViewShell.GetViewFrame()->GetObjectShell()->
                 GetEmbeddedObjectContainer().CreateEmbeddedObject( 
aName.GetByteSequence(), aObjName );
         if ( xObj.is() )
         {
@@ -425,7 +425,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                 aVisualSize.Width = aTmp.Width();
                 aVisualSize.Height = aTmp.Height();
                 xObj->setVisualAreaSize( nAspect, aVisualSize );
-                mpViewShell->ActivateObject(pOleObj.get(), 
embed::EmbedVerbs::MS_OLEVERB_SHOW);
+                mrViewShell.ActivateObject(pOleObj.get(), 
embed::EmbedVerbs::MS_OLEVERB_SHOW);
 
                 if (nSlotId == SID_INSERT_DIAGRAM)
                 {
@@ -458,7 +458,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
         if ( nSlotId == SID_INSERT_OBJECT && pNameItem )
         {
             const SvGlobalName& aClassName = pNameItem->GetValue();
-            xObj =  mpViewShell->GetViewFrame()->GetObjectShell()->
+            xObj =  mrViewShell.GetViewFrame()->GetObjectShell()->
                     GetEmbeddedObjectContainer().CreateEmbeddedObject( 
aClassName.GetByteSequence(), aName );
         }
         else
@@ -492,7 +492,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                 {
                     SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
                     ScopedVclPtr<SfxAbstractInsertObjectDialog> pDlg(
-                            pFact->CreateInsertObjectDialog( 
mpViewShell->GetFrameWeld(), 
SdModule::get()->GetSlotPool()->GetSlot(nSlotId)->GetCommand(),
+                            pFact->CreateInsertObjectDialog( 
mrViewShell.GetFrameWeld(), 
SdModule::get()->GetSlotPool()->GetSlot(nSlotId)->GetCommand(),
                             xStorage, &aServerLst ));
                     pDlg->Execute();
                     bCreateNew = pDlg->IsCreateNew();
@@ -503,7 +503,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                         nAspect = embed::Aspects::MSOLE_ICON;
 
                     if ( xObj.is() )
-                        
mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject(
 xObj, aName );
+                        
mrViewShell.GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject(
 xObj, aName );
 
                     break;
                 }
@@ -649,12 +649,12 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                                 xObj->setVisualAreaSize( nAspect, aSz );
                             }
 
-                            mpViewShell->ActivateObject(pObj.get(), 
embed::EmbedVerbs::MS_OLEVERB_SHOW);
+                            mrViewShell.ActivateObject(pObj.get(), 
embed::EmbedVerbs::MS_OLEVERB_SHOW);
                         }
 
                         Size aVisSizePixel = mpWindow->GetOutputSizePixel();
                         ::tools::Rectangle aVisAreaWin = 
mpWindow->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
-                        mpViewShell->VisAreaChanged(aVisAreaWin);
+                        mrViewShell.VisAreaChanged(aVisAreaWin);
                         mpDocSh->SetVisArea(aVisAreaWin);
                     }
                 }
@@ -669,18 +669,18 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
 }
 
 FuInsertAVMedia::FuInsertAVMedia(
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertAVMedia::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertAVMedia::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertAVMedia( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertAVMedia( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -725,7 +725,7 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
         if( mpWindow )
             mpWindow->EnterWait();
 
-        SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
+        SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
         if (!pFrame)
             return;
 
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index 9eb004066084..4d492cb412e6 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -104,18 +104,18 @@ namespace sd {
 
 
 FuInsertFile::FuInsertFile (
-    ViewShell*    pViewSh,
+    ViewShell&    rViewSh,
     ::sd::Window*      pWin,
     ::sd::View*        pView,
     SdDrawDocument* pDoc,
     SfxRequest&    rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertFile::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertFile::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertFile( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertFile( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -251,7 +251,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
 
     SfxGetpApp()->GetFilterMatcher().GuessFilter(*xMedium, pFilter);
 
-    bool                bDrawMode = dynamic_cast< const DrawViewShell *>( 
mpViewShell ) != nullptr;
+    bool                bDrawMode = dynamic_cast< const DrawViewShell *>( 
&mrViewShell ) != nullptr;
     bool                bInserted = false;
 
     if( pFilter )
@@ -316,7 +316,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
 
     mpDocSh->SetWaitCursor( false );
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-    weld::Window* pParent = mpViewShell ? mpViewShell->GetFrameWeld() : 
nullptr;
+    weld::Window* pParent = mrViewShell.GetFrameWeld();
     ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(pParent, mpDoc, pMedium, aFile) );
 
     sal_uInt16 nRet = pDlg->Execute();
@@ -330,7 +330,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
         std::vector<OUString> aBookmarkList = pDlg->GetList( 1 ); // pages
         bool bLink = pDlg->IsLink();
         SdPage* pPage = nullptr;
-        ::sd::View* pView = mpViewShell ? mpViewShell->GetView() : nullptr;
+        ::sd::View* pView = mrViewShell.GetView();
 
         if (pView)
         {
@@ -397,7 +397,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
 void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
 {
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(mpViewShell->GetFrameWeld(), mpDoc, nullptr, 
aFile) );
+    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(mrViewShell.GetFrameWeld(), mpDoc, nullptr, 
aFile) );
 
     mpDocSh->SetWaitCursor( false );
 
@@ -426,7 +426,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
     // set reference device
     aOutliner.SetRefDevice(SdModule::get()->GetVirtualRefDevice());
 
-    SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
+    SdPage* pPage = static_cast<DrawViewShell*>(&mrViewShell)->GetActualPage();
     aLayoutName = pPage->GetLayoutName();
     sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR);
     if( nIndex != -1 )
@@ -449,7 +449,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
     else
     {
         // is it a master page?
-        if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == 
EditMode::MasterPage &&
+        if (static_cast<DrawViewShell*>(&mrViewShell)->GetEditMode() == 
EditMode::MasterPage &&
             !pPage->IsMasterPage())
         {
             pPage = static_cast<SdPage*>(&(pPage->TRG_GetMasterPage()));
@@ -612,7 +612,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
 
         nNewPages = 0;
 
-        ViewShellId nViewShellId = mpViewShell ? 
mpViewShell->GetViewShellBase().GetViewShellId() : ViewShellId(-1);
+        ViewShellId nViewShellId = 
mrViewShell.GetViewShellBase().GetViewShellId();
         rDocliner.GetUndoManager().EnterListAction(
                                     SdResId(STR_UNDO_INSERT_FILE), OUString(), 
0, nViewShellId );
 
diff --git a/sd/source/ui/func/fuline.cxx b/sd/source/ui/func/fuline.cxx
index 0e8eb78f39e4..1dcfe0058e4f 100644
--- a/sd/source/ui/func/fuline.cxx
+++ b/sd/source/ui/func/fuline.cxx
@@ -32,18 +32,18 @@ namespace sd {
 
 
 FuLine::FuLine (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLine::Create( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLine::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLine( pViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuLine( rViewSh, pWin, pView, pDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -66,7 +66,7 @@ void FuLine::DoExecute( SfxRequest& rReq )
 
     bool bHasMarked = rMarkList.GetMarkCount() != 0;
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    VclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSvxLineTabDialog(mpViewShell->GetFrameWeld(), &aNewAttr, mpDoc, 
pObj, bHasMarked) );
+    VclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSvxLineTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, mpDoc, 
pObj, bHasMarked) );
 
     pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult){
         if (nResult == RET_OK)
@@ -86,11 +86,11 @@ void FuLine::DoExecute( SfxRequest& rReq )
                 SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
                 0 };
 
-            mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
+            mrViewShell.GetViewFrame()->GetBindings().Invalidate( SidArray );
         }
 
         // deferred until the dialog ends
-        mpViewShell->Cancel();
+        mrViewShell.Cancel();
 
         pDlg->disposeOnce();
     });
diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx
index 629c18935023..4f995004ba92 100644
--- a/sd/source/ui/func/fulinend.cxx
+++ b/sd/source/ui/func/fulinend.cxx
@@ -36,15 +36,15 @@
 namespace sd {
 
 
-FuLineEnd::FuLineEnd(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
+FuLineEnd::FuLineEnd(ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
                     SdDrawDocument* pDoc, SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLineEnd::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLineEnd::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLineEnd( pViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuLineEnd( rViewSh, pWin, pView, pDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/fulink.cxx b/sd/source/ui/func/fulink.cxx
index 4ad4d2feaaf5..89095f15f3ad 100644
--- a/sd/source/ui/func/fulink.cxx
+++ b/sd/source/ui/func/fulink.cxx
@@ -38,18 +38,18 @@ namespace sd {
 
 
 FuLink::FuLink (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq )
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLink::Create( ViewShell* pViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLink::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLink( pViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuLink( rViewSh, pWin, pView, pDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -68,10 +68,9 @@ void FuLink::DoExecute( SfxRequest& )
     sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager();
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    VclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(mpViewShell->GetFrameWeld(), pLinkManager));
-    auto pViewShell = mpViewShell;
+    VclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(mrViewShell.GetFrameWeld(), pLinkManager));
     pDlg->StartExecuteAsync(
-        [pDlg, pViewShell] (sal_Int32 /*nResult*/)->void
+        [pDlg, pViewShell = &mrViewShell] (sal_Int32 /*nResult*/)->void
         {
             pViewShell->GetViewFrame()->GetBindings().Invalidate( 
SID_MANAGE_LINKS );
             pDlg->disposeOnce();
diff --git a/sd/source/ui/func/fumeasur.cxx b/sd/source/ui/func/fumeasur.cxx
index 27afd0f7a120..5c8df27450d6 100644
--- a/sd/source/ui/func/fumeasur.cxx
+++ b/sd/source/ui/func/fumeasur.cxx
@@ -28,18 +28,18 @@ namespace sd {
 
 
 FuMeasureDlg::FuMeasureDlg (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuMeasureDlg::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuMeasureDlg::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuMeasureDlg( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuMeasureDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index 5c8081a6855e..d5179f6d61de 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -49,24 +49,24 @@ using namespace com::sun::star;
 namespace sd {
 
 FuMorph::FuMorph (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq )
-    :   FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    :   FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
 rtl::Reference<FuPoor> FuMorph::Create(
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq
 )
 {
-    rtl::Reference<FuPoor> xFunc( new FuMorph( pViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuMorph( rViewSh, pWin, pView, pDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/funavig.cxx b/sd/source/ui/func/funavig.cxx
index ca7565c8ba49..4b9303ec0d72 100644
--- a/sd/source/ui/func/funavig.cxx
+++ b/sd/source/ui/func/funavig.cxx
@@ -38,38 +38,37 @@ namespace sd {
 
 
 FuNavigation::FuNavigation (
-    ViewShell* pViewSh,
+    ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
     SdDrawDocument* pDoc,
     SfxRequest& rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuNavigation::Create( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuNavigation::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuNavigation( pViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuNavigation( rViewSh, pWin, pView, 
pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
 
 void FuNavigation::DoExecute( SfxRequest& rReq )
 {
-    assert(mpViewShell);
-    bool bSlideShow = SlideShow::IsRunning( mpViewShell->GetViewShellBase() )
-        && !SlideShow::IsInteractiveSlideshow( 
&mpViewShell->GetViewShellBase() ); // IASS
+    bool bSlideShow = SlideShow::IsRunning( mrViewShell.GetViewShellBase() )
+        && !SlideShow::IsInteractiveSlideshow( &mrViewShell.GetViewShellBase() 
); // IASS
 
     switch ( rReq.GetSlot() )
     {
         case SID_GO_TO_FIRST_PAGE:
         {
             if (!mpView->IsTextEdit()
-                && dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  
nullptr
+                && dynamic_cast< const DrawViewShell *>( &mrViewShell ) !=  
nullptr
                 && !bSlideShow)
             {
                // jump to first page
-               static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
+               static_cast<DrawViewShell*>(&mrViewShell)->SwitchPage(0);
             }
         }
         break;
@@ -77,7 +76,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
         case SID_GO_TO_PREVIOUS_PAGE:
         {
             if( !bSlideShow)
-                if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ) )
+                if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
&mrViewShell ) )
                 {
                     // With no modifier pressed we move to the previous
                     // slide.
@@ -93,11 +92,11 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
                         // deactivation the old page and activating the new
                         // one.
                         TabControl& rPageTabControl =
-                            static_cast<DrawViewShell*>(mpViewShell)
+                            static_cast<DrawViewShell*>(&mrViewShell)
                             ->GetPageTabControl();
                         if (rPageTabControl.IsReallyShown())
                             rPageTabControl.SendDeactivatePageEvent ();
-                        
static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
+                        
static_cast<DrawViewShell*>(&mrViewShell)->SwitchPage(nSdPage - 1);
                         if (rPageTabControl.IsReallyShown())
                             rPageTabControl.SendActivatePageEvent ();
                     }
@@ -108,7 +107,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
         case SID_GO_TO_NEXT_PAGE:
         {
             if( !bSlideShow)
-                if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
+                if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
&mrViewShell ))
                 {
                     // With no modifier pressed we move to the next slide.
                     mpView->SdrEndTextEdit();
@@ -123,10 +122,10 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
                         // deactivation the old page and activating the new
                         // one.
                         TabControl& rPageTabControl =
-                            
static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
+                            
static_cast<DrawViewShell*>(&mrViewShell)->GetPageTabControl();
                         if (rPageTabControl.IsReallyShown())
                             rPageTabControl.SendDeactivatePageEvent ();
-                        
static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
+                        
static_cast<DrawViewShell*>(&mrViewShell)->SwitchPage(nSdPage + 1);
                         if (rPageTabControl.IsReallyShown())
                             rPageTabControl.SendActivatePageEvent ();
                     }
@@ -137,7 +136,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
         case SID_GO_TO_LAST_PAGE:
         {
             if (!mpView->IsTextEdit() && !bSlideShow)
-                if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
+                if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
&mrViewShell ))
                 {
                     // jump to last page
                     SdPage* pPage = pDrawViewShell->GetActualPage();
@@ -150,7 +149,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
         case SID_GO_TO_PAGE:
         {
             if( !bSlideShow)
-                if(auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
+                if(auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
&mrViewShell ))
                 {
                     OUString sTitle = SdResId(STR_GOTO_PAGE_DLG_TITLE);
                     OUString sLabel = SdResId(STR_PAGE_NAME) + ":";
@@ -170,7 +169,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
         break;
     }
     // Refresh toolbar icons
-    SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+    SfxBindings& rBindings = mrViewShell.GetViewFrame()->GetBindings();
     rBindings.Invalidate(SID_GO_TO_FIRST_PAGE);
     rBindings.Invalidate(SID_GO_TO_PREVIOUS_PAGE);
     rBindings.Invalidate(SID_GO_TO_NEXT_PAGE);
diff --git a/sd/source/ui/func/fuoaprms.cxx b/sd/source/ui/func/fuoaprms.cxx
index d6f356d257f3..62d601106848 100644
--- a/sd/source/ui/func/fuoaprms.cxx
+++ b/sd/source/ui/func/fuoaprms.cxx
@@ -56,18 +56,18 @@ namespace sd {
 #define ATTR_SET        2       ///< Attribute unique
 
 FuObjectAnimationParameters::FuObjectAnimationParameters (
-    ViewShell*   pViewSh,
+    ViewShell&   rViewSh,
     ::sd::Window*        pWin,
     ::sd::View*      pView,
     SdDrawDocument* pDoc,
     SfxRequest&  rReq)
-    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell* 
pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, 
SfxRequest& rReq )
+rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell& 
rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, 
SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( pViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( rViewSh, 
pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -446,7 +446,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& 
rReq )
         rReq.Ignore(); // the 'old' request is not relevant any more
 
         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-        VclPtr<SfxAbstractDialog> pDlg( 
pFact->CreatSdActionDialog(mpViewShell->GetFrameWeld(), *aSet, mpView) );
+        VclPtr<SfxAbstractDialog> pDlg( 
pFact->CreatSdActionDialog(mrViewShell.GetFrameWeld(), *aSet, mpView) );
         rtl::Reference<FuObjectAnimationParameters> xThis( this ); // avoid 
destruction within async processing
         pDlg->StartExecuteAsync([pDlg, xThis, xRequest=std::move(xRequest), 
aSet=std::move(aSet)](sal_Int32 nResult){
             if (nResult == RET_OK) {
@@ -459,7 +459,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& 
rReq )
 
 void FuObjectAnimationParameters::Finish( const std::shared_ptr<SfxRequest>& 
xRequest, const VclPtr<SfxAbstractDialog>& pDlg )
 {
-    SfxUndoManager* pUndoMgr = 
mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager();
+    SfxUndoManager* pUndoMgr = 
mrViewShell.GetViewFrame()->GetObjectShell()->GetUndoManager();
 
     const SdrMarkList& rMarkList  = mpView->GetMarkedObjectList();
     const size_t nCount = rMarkList.GetMarkCount();
@@ -664,7 +664,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
 
     // with 'following curves', we have an additional UndoAction
     // therefore cling? here
-    pUndoMgr->EnterListAction(aComment, aComment, 0, 
mpViewShell->GetViewShellBase().GetViewShellId());
+    pUndoMgr->EnterListAction(aComment, aComment, 0, 
mrViewShell.GetViewShellBase().GetViewShellId());
 
     // create undo group
     std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc));
diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx
index f9b8f3965c36..d2ea81280c2a 100644
--- a/sd/source/ui/func/fuolbull.cxx
+++ b/sd/source/ui/func/fuolbull.cxx
@@ -41,16 +41,16 @@
 using namespace svx::sidebar;
 namespace sd {
 
-FuBulletAndPosition::FuBulletAndPosition(ViewShell* pViewShell, ::sd::Window* 
pWindow,
+FuBulletAndPosition::FuBulletAndPosition(ViewShell& rViewShell, ::sd::Window* 
pWindow,
                                  ::sd::View* pView, SdDrawDocument* pDoc,
                                  SfxRequest& rReq)
-       : FuPoor(pViewShell, pWindow, pView, pDoc, rReq)
+       : FuPoor(rViewShell, pWindow, pView, pDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuBulletAndPosition::Create( ViewShell* pViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuBulletAndPosition::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuBulletAndPosition( pViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuBulletAndPosition( rViewSh, pWin, 
pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -79,14 +79,14 @@ void FuBulletAndPosition::DoExecute( SfxRequest& rReq )
     SfxItemSet aEditAttr( mpDoc->GetPool() );
     mpView->GetAttributes( aEditAttr );
 
-    SfxItemSetFixed<EE_PARA_NUMBULLET, EE_PARA_BULLET> aNewAttr( 
mpViewShell->GetPool() );
+    SfxItemSetFixed<EE_PARA_NUMBULLET, EE_PARA_BULLET> aNewAttr( 
mrViewShell.GetPool() );
     aNewAttr.Put( aEditAttr, false );
 
     auto pView = mpView;
 
     // create and execute dialog
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-    ScopedVclPtr<AbstractSvxBulletAndPositionDlg> 
pDlg(pFact->CreateSvxBulletAndPositionDlg(mpViewShell->GetFrameWeld(), 
&aNewAttr, mpView));
+    ScopedVclPtr<AbstractSvxBulletAndPositionDlg> 
pDlg(pFact->CreateSvxBulletAndPositionDlg(mrViewShell.GetFrameWeld(), 
&aNewAttr, mpView));
     sal_uInt16 nResult = pDlg->Execute();
 
     if( nResult == RET_OK )
@@ -97,7 +97,7 @@ void FuBulletAndPosition::DoExecute( SfxRequest& rReq )
 
         if (OutlineView* pOutlineView = dynamic_cast<OutlineView*>(pView))
         {
-            pOLV = 
pOutlineView->GetViewByWindow(mpViewShell->GetActiveWindow());
+            pOLV = 
pOutlineView->GetViewByWindow(mrViewShell.GetActiveWindow());
             aGuard.reset(new OutlineViewModelChangeGuard(*pOutlineView));
         }
 
@@ -132,14 +132,14 @@ void 
FuBulletAndPosition::SetCurrentBulletsNumbering(SfxRequest& rReq)
         return;
     }
 
-    SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aNewAttr( 
mpViewShell->GetPool() );
+    SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aNewAttr( 
mrViewShell.GetPool() );
     {
         SfxItemSet aEditAttr( mpDoc->GetPool() );
         mpView->GetAttributes( aEditAttr );
         aNewAttr.Put( aEditAttr, false );
     }
 
-    const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* 
>(mpViewShell);
+    const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* 
>(&mrViewShell);
     //Init bullet level in "Customize" tab page in bullet dialog in master 
page view
-e 
... etc. - the rest is truncated

Reply via email to