sd/inc/Outliner.hxx                                          |    8 -
 sd/source/core/ThemeColorChanger.cxx                         |    2 
 sd/source/core/drawdoc.cxx                                   |    4 
 sd/source/core/drawdoc3.cxx                                  |    2 
 sd/source/ui/dlg/SpellDialogChildWindow.cxx                  |    4 
 sd/source/ui/dlg/unchss.cxx                                  |    8 -
 sd/source/ui/docshell/docshel3.cxx                           |    6 
 sd/source/ui/func/fuarea.cxx                                 |   12 -
 sd/source/ui/func/fubullet.cxx                               |   16 +-
 sd/source/ui/func/fuchar.cxx                                 |   18 +-
 sd/source/ui/func/fucon3d.cxx                                |   14 +-
 sd/source/ui/func/fuconarc.cxx                               |   12 -
 sd/source/ui/func/fuconbez.cxx                               |   10 -
 sd/source/ui/func/fuconcs.cxx                                |   12 -
 sd/source/ui/func/fuconnct.cxx                               |   10 -
 sd/source/ui/func/fuconrec.cxx                               |   18 +-
 sd/source/ui/func/fuconstr.cxx                               |    6 
 sd/source/ui/func/fuconuno.cxx                               |    8 -
 sd/source/ui/func/fucopy.cxx                                 |   10 -
 sd/source/ui/func/fucushow.cxx                               |   16 +-
 sd/source/ui/func/fudraw.cxx                                 |    4 
 sd/source/ui/func/fudspord.cxx                               |    8 -
 sd/source/ui/func/fuediglu.cxx                               |    8 -
 sd/source/ui/func/fuexecuteinteraction.cxx                   |    8 -
 sd/source/ui/func/fuexpand.cxx                               |   42 +++---
 sd/source/ui/func/fuformatpaintbrush.cxx                     |   16 +-
 sd/source/ui/func/fuhhconv.cxx                               |   23 +--
 sd/source/ui/func/fuinsert.cxx                               |   34 ++---
 sd/source/ui/func/fuinsfil.cxx                               |   36 ++---
 sd/source/ui/func/fuline.cxx                                 |   12 -
 sd/source/ui/func/fulinend.cxx                               |   10 -
 sd/source/ui/func/fulink.cxx                                 |   10 -
 sd/source/ui/func/fumeasur.cxx                               |   10 -
 sd/source/ui/func/fumorph.cxx                                |    8 -
 sd/source/ui/func/funavig.cxx                                |   16 +-
 sd/source/ui/func/fuoaprms.cxx                               |   20 +--
 sd/source/ui/func/fuolbull.cxx                               |   14 +-
 sd/source/ui/func/fuoltext.cxx                               |   12 -
 sd/source/ui/func/fupage.cxx                                 |   62 +++++-----
 sd/source/ui/func/fuparagr.cxx                               |   10 -
 sd/source/ui/func/fupoor.cxx                                 |   10 -
 sd/source/ui/func/fuprlout.cxx                               |   26 ++--
 sd/source/ui/func/fuprobjs.cxx                               |   12 -
 sd/source/ui/func/fuscale.cxx                                |   10 -
 sd/source/ui/func/fusearch.cxx                               |   20 +--
 sd/source/ui/func/fusel.cxx                                  |   14 +-
 sd/source/ui/func/fusldlg.cxx                                |   22 +--
 sd/source/ui/func/fusnapln.cxx                               |    8 -
 sd/source/ui/func/fusumry.cxx                                |   38 +++---
 sd/source/ui/func/futempl.cxx                                |   50 ++++----
 sd/source/ui/func/futext.cxx                                 |   12 -
 sd/source/ui/func/futhes.cxx                                 |   14 +-
 sd/source/ui/func/futransf.cxx                               |   10 -
 sd/source/ui/func/futxtatt.cxx                               |   10 -
 sd/source/ui/func/fuvect.cxx                                 |    8 -
 sd/source/ui/func/fuzoom.cxx                                 |    8 -
 sd/source/ui/inc/NotesPanelViewShell.hxx                     |    4 
 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                                  |    4 
 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/unchss.hxx                                  |    2 
 sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx |    2 
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx       |    8 -
 sd/source/ui/view/NotesPanelView.cxx                         |    2 
 sd/source/ui/view/NotesPanelViewShell.cxx                    |   42 +++---
 sd/source/ui/view/Outliner.cxx                               |   58 ++++-----
 sd/source/ui/view/OutlinerIterator.cxx                       |    4 
 sd/source/ui/view/drawview.cxx                               |   10 -
 sd/source/ui/view/drtxtob1.cxx                               |    2 
 sd/source/ui/view/drviews2.cxx                               |   68 +++++------
 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/sdview4.cxx                                |    2 
 121 files changed, 648 insertions(+), 651 deletions(-)

New commits:
commit d573d3c70f356f256d91401f81c7766ff5097b2e
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue May 27 13:52:31 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue May 27 16:01:15 2025 +0200

    FuPoor: pass SdDrawDocument by ref
    
    Change-Id: I75701740a24ad64f7a491937991eacf0c733d37e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185906
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index 8d00cfbbba9c..43ccb81cc196 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -125,7 +125,7 @@ public:
     friend class ::sd::outliner::OutlinerContainer;
 
     /** Create a new sd outliner object.
-        @param pDoc
+        @param rDoc
             The draw document from which to take the content.
         @param nMode
             The valid values <const>OutlinerMode::DontKnow</const>,
@@ -135,7 +135,7 @@ public:
             <const>OutlinerMode::OutlineView</const> are defined in
             editeng/outliner.hxx.
     */
-    SdOutliner(SdDrawDocument* pDoc, OutlinerMode nMode);
+    SdOutliner(SdDrawDocument& rDoc, OutlinerMode nMode);
     virtual ~SdOutliner() override;
     /// Forbid copy construction and copy assignment
     SdOutliner(const Outliner&) = delete;
@@ -193,7 +193,7 @@ public:
     int GetIgnoreCurrentPageChangesLevel() const { return 
mnIgnoreCurrentPageChangesLevel; };
     void IncreIgnoreCurrentPageChangesLevel() { 
mnIgnoreCurrentPageChangesLevel++; };
     void DecreIgnoreCurrentPageChangesLevel() { 
mnIgnoreCurrentPageChangesLevel--; };
-    SdDrawDocument* GetDoc() const { return mpDrawDocument; }
+    SdDrawDocument& GetDoc() const { return mrDrawDocument; }
 
 private:
     class Implementation;
@@ -221,7 +221,7 @@ private:
     /// This window contains the view.
     VclPtr<::sd::Window> mpWindow;
     /// The document on whose objects and pages this class operates.
-    SdDrawDocument* mpDrawDocument;
+    SdDrawDocument& mrDrawDocument;
 
     /** this is the language that is used for current text conversion.
         Only valid if meMode is TEXT_CONVERSION.
diff --git a/sd/source/core/ThemeColorChanger.cxx 
b/sd/source/core/ThemeColorChanger.cxx
index d8b7b0239c92..b7634b9fa587 100644
--- a/sd/source/core/ThemeColorChanger.cxx
+++ b/sd/source/core/ThemeColorChanger.cxx
@@ -109,7 +109,7 @@ bool changeStyle(sd::DrawDocShell* pDocShell, SdStyleSheet* 
pStyle,
     if (bChanged)
     {
         pDocShell->GetUndoManager()->AddUndoAction(
-            std::make_unique<StyleSheetUndoAction>(pDocShell->GetDoc(), 
*pStyle, &aItemSet));
+            std::make_unique<StyleSheetUndoAction>(*pDocShell->GetDoc(), 
*pStyle, &aItemSet));
         pStyle->GetItemSet().Put(aItemSet);
         pStyle->Broadcast(SfxHint(SfxHintId::DataChanged));
     }
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index a07d24e4ffcb..7a77e451db22 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -932,7 +932,7 @@ SdOutliner* SdDrawDocument::GetOutliner(bool 
bCreateOutliner)
 {
     if (!mpOutliner && bCreateOutliner)
     {
-        mpOutliner.reset(new SdOutliner( this, OutlinerMode::TextObject ));
+        mpOutliner.reset(new SdOutliner( *this, OutlinerMode::TextObject ));
 
         if (mpDocSh)
             mpOutliner->SetRefDevice(SdModule::get()->GetVirtualRefDevice());
@@ -950,7 +950,7 @@ SdOutliner* SdDrawDocument::GetInternalOutliner(bool 
bCreateOutliner)
 {
     if ( !mpInternalOutliner && bCreateOutliner )
     {
-        mpInternalOutliner.reset( new SdOutliner( this, 
OutlinerMode::TextObject ) );
+        mpInternalOutliner.reset( new SdOutliner( *this, 
OutlinerMode::TextObject ) );
 
         // This outliner is only used to create special text objects. As no
         // information about portions is saved in this outliner, the update 
mode
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 9d3c48404330..7ebb5bd5829d 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -1707,7 +1707,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
 
                         if (bUndo)
                         {
-                            
pUndoMgr->AddUndoAction(std::make_unique<StyleSheetUndoAction>(this,
+                            
pUndoMgr->AddUndoAction(std::make_unique<StyleSheetUndoAction>(*this,
                                                                  *pMySheet, 
&pHisSheet->GetItemSet()));
                         }
                         pMySheet->GetItemSet().Put(pHisSheet->GetItemSet());
diff --git a/sd/source/ui/dlg/SpellDialogChildWindow.cxx 
b/sd/source/ui/dlg/SpellDialogChildWindow.cxx
index c87919346322..93cf10ba02f8 100644
--- a/sd/source/ui/dlg/SpellDialogChildWindow.cxx
+++ b/sd/source/ui/dlg/SpellDialogChildWindow.cxx
@@ -100,7 +100,7 @@ void SpellDialogChildWindow::EndSpellingAndClearOutliner()
 {
     if (!mpSdOutliner)
         return;
-    EndListening(*mpSdOutliner->GetDoc());
+    EndListening(mpSdOutliner->GetDoc());
     mpSdOutliner->EndSpelling();
     if (mbOwnOutliner)
         delete mpSdOutliner;
@@ -146,7 +146,7 @@ void SpellDialogChildWindow::ProvideOutliner()
         // to create one.
         mbOwnOutliner = true;
         SdDrawDocument *pDoc = pViewShell->GetDoc();
-        mpSdOutliner = new SdOutliner(pDoc, OutlinerMode::TextObject);
+        mpSdOutliner = new SdOutliner(*pDoc, OutlinerMode::TextObject);
         StartListening(*pDoc);
     }
     else if( dynamic_cast< const OutlineViewShell *>( pViewShell ) !=  nullptr)
diff --git a/sd/source/ui/dlg/unchss.cxx b/sd/source/ui/dlg/unchss.cxx
index 43ca8a85c66c..5727bb0deaed 100644
--- a/sd/source/ui/dlg/unchss.cxx
+++ b/sd/source/ui/dlg/unchss.cxx
@@ -33,19 +33,19 @@
 #include <stlsheet.hxx>
 #include <strings.hxx>
 
-StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
+StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument& rTheDoc,
                                            SfxStyleSheet& rTheStyleSheet,
                                            const SfxItemSet* pTheNewItemSet)
-    : SdUndoAction(pTheDoc),
+    : SdUndoAction(&rTheDoc),
       mrStyleSheet(rTheStyleSheet)
 {
     // Create ItemSets; Attention, it is possible that the new one is from a,
     // different pool. Therefore we clone it with its items.
     mpNewSet = 
std::make_unique<SfxItemSet>(static_cast<SfxItemPool&>(SdrObject::GetGlobalDrawObjectItemPool()),
 pTheNewItemSet->GetRanges());
-    SdrModel::MigrateItemSet( pTheNewItemSet, mpNewSet.get(), *pTheDoc );
+    SdrModel::MigrateItemSet( pTheNewItemSet, mpNewSet.get(), rTheDoc );
 
     mpOldSet = 
std::make_unique<SfxItemSet>(static_cast<SfxItemPool&>(SdrObject::GetGlobalDrawObjectItemPool()),
 mrStyleSheet.GetItemSet().GetRanges());
-    SdrModel::MigrateItemSet( &mrStyleSheet.GetItemSet(), mpOldSet.get(), 
*pTheDoc );
+    SdrModel::MigrateItemSet( &mrStyleSheet.GetItemSet(), mpOldSet.get(), 
rTheDoc );
 
     OUString aComment(SdResId(STR_UNDO_CHANGE_PRES_OBJECT));
     OUString aName(mrStyleSheet.GetName());
diff --git a/sd/source/ui/docshell/docshel3.cxx 
b/sd/source/ui/docshell/docshel3.cxx
index 61c0031096c2..0dc52d1785cf 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -211,7 +211,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
                         xFuSearch = rtl::Reference<FuSearch>(
                             FuSearch::createPtr(*mpViewShell,
                                                 mpViewShell->GetActiveWindow(),
-                                                pView, mpDoc, rReq));
+                                                pView, *mpDoc, rReq));
 
                         pView->getSearchContext().setSearchFunction(xFuSearch);
                     }
@@ -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/func/fuarea.cxx b/sd/source/ui/func/fuarea.cxx
index d24d155ccbef..1a34d25e7454 100644
--- a/sd/source/ui/func/fuarea.cxx
+++ b/sd/source/ui/func/fuarea.cxx
@@ -31,14 +31,14 @@
 
 namespace sd {
 
-FuArea::FuArea( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* _pView, 
SdDrawDocument* pDoc, SfxRequest& rReq)
-: FuPoor(rViewSh, pWin, _pView, pDoc, rReq)
+FuArea::FuArea( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* _pView, 
SdDrawDocument& rDoc, SfxRequest& rReq)
+: FuPoor(rViewSh, pWin, _pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuArea::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* _pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuArea::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* _pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuArea( rViewSh, pWin, _pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuArea( rViewSh, pWin, _pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -51,13 +51,13 @@ void FuArea::DoExecute( SfxRequest& rReq )
     if (pArgs)
         return;
 
-    SfxItemSet aNewAttr( mpDoc->GetPool() );
+    SfxItemSet aNewAttr( mrDoc.GetPool() );
     mpView->GetAttributes( aNewAttr );
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     bool bHasSlideBackground = mrViewShell.GetDoc()->GetDocumentType() == 
DocumentType::Impress;
     VclPtr<AbstractSvxAreaTabDialog> pDlg(
-        pFact->CreateSvxAreaTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, 
mpDoc, true, bHasSlideBackground));
+        pFact->CreateSvxAreaTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, 
&mrDoc, true, bHasSlideBackground));
 
     pDlg->StartExecuteAsync([pDlg, pView = this->mpView, pViewShell = 
&this->mrViewShell](sal_Int32 nResult){
         if (nResult == RET_OK)
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx
index 67ab7d32ccfb..076062786a21 100644
--- a/sd/source/ui/func/fubullet.cxx
+++ b/sd/source/ui/func/fubullet.cxx
@@ -58,15 +58,15 @@ FuBullet::FuBullet (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* _pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, _pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, _pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuBullet::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuBullet::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuBullet( rViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuBullet( rViewSh, pWin, pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -168,7 +168,7 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
         }
         else
         {
-            SfxItemSet aFontAttr( mpDoc->GetPool() );
+            SfxItemSet aFontAttr( mrDoc.GetPool() );
             mpView->GetAttributes( aFontAttr );
             const SvxFontItem* pFItem = aFontAttr.GetItem( SID_ATTR_CHAR_FONT 
);
             if( pFItem )
@@ -178,10 +178,10 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
 
     if (aChars.isEmpty())
     {
-        SfxAllItemSet aSet( mpDoc->GetPool() );
+        SfxAllItemSet aSet( mrDoc.GetPool() );
         aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
 
-        SfxItemSet aFontAttr( mpDoc->GetPool() );
+        SfxItemSet aFontAttr( mrDoc.GetPool() );
         mpView->GetAttributes( aFontAttr );
         const SvxFontItem* pFontItem = aFontAttr.GetItem( SID_ATTR_CHAR_FONT );
         if( pFontItem )
@@ -243,7 +243,7 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
        empty string). */
     pOV->InsertText( u""_ustr );
 
-    SfxItemSetFixed<EE_CHAR_FONTINFO, EE_CHAR_FONTINFO> aOldSet( 
mpDoc->GetPool() );
+    SfxItemSetFixed<EE_CHAR_FONTINFO, EE_CHAR_FONTINFO> aOldSet( 
mrDoc.GetPool() );
     aOldSet.Put( pOV->GetAttribs() );
 
     EditUndoManager& rUndoMgr = pOL->GetUndoManager();
diff --git a/sd/source/ui/func/fuchar.cxx b/sd/source/ui/func/fuchar.cxx
index cd6f27da52be..c9229f82934d 100644
--- a/sd/source/ui/func/fuchar.cxx
+++ b/sd/source/ui/func/fuchar.cxx
@@ -40,15 +40,15 @@ FuChar::FuChar (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuChar::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuChar::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuChar( rViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuChar( rViewSh, pWin, pView, rDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -59,14 +59,14 @@ void FuChar::DoExecute( SfxRequest& rReq )
 
     if( !pArgs )
     {
-        SfxItemSet aEditAttr( mpDoc->GetPool() );
+        SfxItemSet aEditAttr( mrDoc.GetPool() );
         mpView->GetAttributes( aEditAttr );
 
         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(mrViewShell.GetFrameWeld(), &aNewAttr, 
mpDoc->GetDocSh() ) );
+        ScopedVclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSdTabCharDialog(mrViewShell.GetFrameWeld(), &aNewAttr, 
mrDoc.GetDocSh() ) );
         if (rReq.GetSlot() == SID_CHAR_DLG_EFFECT)
         {
             pDlg->SetCurPageId(u"RID_SVXPAGE_CHAR_EFFECTS"_ustr);
@@ -114,14 +114,14 @@ void FuChar::DoExecute( SfxRequest& rReq )
 
     mrViewShell.GetViewFrame()->GetBindings().Invalidate( SidArray );
 
-    if( mpDoc->GetOnlineSpell() )
+    if( mrDoc.GetOnlineSpell() )
     {
         if( SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE, false ) 
||
             SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CJK, 
false ) ||
             SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CTL, 
false ) )
         {
-            mpDoc->StopOnlineSpelling();
-            mpDoc->StartOnlineSpelling();
+            mrDoc.StopOnlineSpelling();
+            mrDoc.StartOnlineSpelling();
         }
     }
 }
diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx
index 8eea3e8b5213..a2ab31cc1d94 100644
--- a/sd/source/ui/func/fucon3d.cxx
+++ b/sd/source/ui/func/fucon3d.cxx
@@ -54,16 +54,16 @@ FuConstruct3dObject::FuConstruct3dObject (
     ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&     rReq)
-    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConstruct3dObject::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstruct3dObject* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstruct3dObject( rViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstruct3dObject( rViewSh, 
pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
@@ -334,7 +334,7 @@ bool FuConstruct3dObject::MouseButtonDown(const MouseEvent& 
rMEvt)
 
         if (pObj)
         {
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             SetStyleSheet(aAttr, pObj);
 
             // extract LineStyle
@@ -408,7 +408,7 @@ rtl::Reference<SdrObject> 
FuConstruct3dObject::CreateDefaultObject(const sal_uIn
     double fW(aVolume.getWidth());
     double fH(aVolume.getHeight());
     ::tools::Rectangle a3DRect(0, 0, static_cast<::tools::Long>(fW), 
static_cast<::tools::Long>(fH));
-    rtl::Reference< E3dScene > pScene(new E3dScene(*mpDoc));
+    rtl::Reference< E3dScene > pScene(new E3dScene(mrDoc));
 
     // copied code from E3dView::InitScene
     double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0));
@@ -424,7 +424,7 @@ rtl::Reference<SdrObject> 
FuConstruct3dObject::CreateDefaultObject(const sal_uIn
     pScene->InsertObject(p3DObj.get());
     pScene->NbcSetSnapRect(a3DRect);
     ImpPrepareBasic3DShape(p3DObj.get(), pScene.get());
-    SfxItemSet aAttr(mpDoc->GetPool());
+    SfxItemSet aAttr(mrDoc.GetPool());
     SetStyleSheet(aAttr, p3DObj.get());
     aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE));
     p3DObj->SetMergedItemSet(aAttr);
diff --git a/sd/source/ui/func/fuconarc.cxx b/sd/source/ui/func/fuconarc.cxx
index 459b50463629..a5cec1cbbb05 100644
--- a/sd/source/ui/func/fuconarc.cxx
+++ b/sd/source/ui/func/fuconarc.cxx
@@ -49,16 +49,16 @@ FuConstructArc::FuConstructArc (
     ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&     rReq )
-    : FuConstruct( rViewSh, pWin, pView, pDoc, rReq )
+    : FuConstruct( rViewSh, pWin, pView, rDoc, rReq )
 {
 }
 
-rtl::Reference<FuPoor> FuConstructArc::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent  )
 {
     FuConstructArc* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( rViewSh, pWin, 
pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
@@ -117,7 +117,7 @@ bool FuConstructArc::MouseButtonDown( const MouseEvent& 
rMEvt )
 
         if (pObj)
         {
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             SetStyleSheet(aAttr, pObj);
 
             pObj->SetMergedItemSet(aAttr);
@@ -229,7 +229,7 @@ rtl::Reference<SdrObject> 
FuConstructArc::CreateDefaultObject(const sal_uInt16 n
 
             pObj->SetLogicRect(aRect);
 
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
             aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
 
diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx
index 483d61341d2e..9e8e9763b233 100644
--- a/sd/source/ui/func/fuconbez.cxx
+++ b/sd/source/ui/func/fuconbez.cxx
@@ -62,9 +62,9 @@ FuConstructBezierPolygon::FuConstructBezierPolygon (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq),
+    : FuConstruct(rViewSh, pWin, pView, rDoc, rReq),
       nEditMode(SID_BEZIER_MOVE),
       mnTransparence(0),
       mnWidth(0)
@@ -90,10 +90,10 @@ bool isSticky(const SfxRequest& rReq)
 
 }
 
-rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructBezierPolygon* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructBezierPolygon( 
rViewSh, pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructBezierPolygon( 
rViewSh, pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent || isSticky(rReq));
     return xFunc;
@@ -178,7 +178,7 @@ bool FuConstructBezierPolygon::MouseButtonDown(const 
MouseEvent& rMEvt)
 
         if (pObj)
         {
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             SetStyleSheet(aAttr, pObj);
             SetAttributes(aAttr, pObj);
             pObj->SetMergedItemSet(aAttr);
diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx
index 9f33127d7b93..4e0204ad7f48 100644
--- a/sd/source/ui/func/fuconcs.cxx
+++ b/sd/source/ui/func/fuconcs.cxx
@@ -49,16 +49,16 @@ FuConstructCustomShape::FuConstructCustomShape (
         ViewShell&          rViewSh,
         ::sd::Window*       pWin,
         ::sd::View*         pView,
-        SdDrawDocument*     pDoc,
+        SdDrawDocument&     rDoc,
         SfxRequest&         rReq ) :
-    FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
+    FuConstruct(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConstructCustomShape::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructCustomShape* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( rViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( rViewSh, 
pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent( bPermanent );
     return xFunc;
@@ -104,7 +104,7 @@ bool FuConstructCustomShape::MouseButtonDown(const 
MouseEvent& rMEvt)
                 bForceFillStyle = false;
                 bForceNoFillStyle = true;
             }
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
             pObj->SetMergedItemSet(aAttr);
         }
@@ -240,7 +240,7 @@ rtl::Reference<SdrObject> 
FuConstructCustomShape::CreateDefaultObject(const sal_
             ImpForceQuadratic( aRect );
         pObj->SetLogicRect( aRect );
         SetAttributes( pObj.get() );
-        SfxItemSet aAttr(mpDoc->GetPool());
+        SfxItemSet aAttr(mrDoc.GetPool());
         SetStyleSheet(aAttr, pObj.get());
         pObj->SetMergedItemSet(aAttr);
     }
diff --git a/sd/source/ui/func/fuconnct.cxx b/sd/source/ui/func/fuconnct.cxx
index 8e3f557b4fae..824e4a71d5e8 100644
--- a/sd/source/ui/func/fuconnct.cxx
+++ b/sd/source/ui/func/fuconnct.cxx
@@ -31,22 +31,22 @@ FuConnectionDlg::FuConnectionDlg (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuConnectionDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuConnectionDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuConnectionDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuConnectionDlg( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
 
 void FuConnectionDlg::DoExecute( SfxRequest& rReq )
 {
-    SfxItemSet aNewAttr( mpDoc->GetPool() );
+    SfxItemSet aNewAttr( mrDoc.GetPool() );
     mpView->GetAttributes( aNewAttr );
 
     const SfxItemSet* pArgs = rReq.GetArgs();
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index a636b5aca43b..d3db4fcce388 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -81,9 +81,9 @@ FuConstructRectangle::FuConstructRectangle (
     ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&     rReq)
-    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, rDoc, rReq)
     , mnFillTransparence(0)
     , mnLineStyle(SAL_MAX_UINT16)
 {
@@ -108,10 +108,10 @@ bool isSticky(const SfxRequest& rReq)
 
 }
 
-rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructRectangle* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( rViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( rViewSh, 
pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent || isSticky(rReq));
     return xFunc;
@@ -267,7 +267,7 @@ bool FuConstructRectangle::MouseButtonDown(const 
MouseEvent& rMEvt)
 
         if (pObj)
         {
-            SfxItemSet aAttr(mpDoc->GetPool());
+            SfxItemSet aAttr(mrDoc.GetPool());
             SetStyleSheet(aAttr, pObj);
             SetAttributes(aAttr, pObj);
             SetLineEnds(aAttr, *pObj);
@@ -295,7 +295,7 @@ bool FuConstructRectangle::MouseButtonUp(const MouseEvent& 
rMEvt)
         {
             if(SID_DRAW_MEASURELINE == nSlotId)
             {
-                SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
+                SdrLayerAdmin& rAdmin = mrDoc.GetLayerAdmin();
                 pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
             }
 
@@ -631,7 +631,7 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, 
SdrObject* pObj)
             pObj->SetStyleSheet(pSheet, false);
         }
 
-        SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
+        SdrLayerAdmin& rAdmin = mrDoc.GetLayerAdmin();
         pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
     }
     else if (nSlotId == SID_DRAW_RECT)
@@ -723,7 +723,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, 
SdrObject const & rObj
         aSquare.append(aNewSquare);
     }
 
-    SfxItemSet aSet( mpDoc->GetPool() );
+    SfxItemSet aSet( mrDoc.GetPool() );
     mpView->GetAttributes( aSet );
 
     // #i3908# Here, the default Line Start/End width for arrow construction is
@@ -1061,7 +1061,7 @@ rtl::Reference<SdrObject> 
FuConstructRectangle::CreateDefaultObject(const sal_uI
             }
         }
 
-        SfxItemSet aAttr(mpDoc->GetPool());
+        SfxItemSet aAttr(mrDoc.GetPool());
         SetStyleSheet(aAttr, pObj.get());
         SetAttributes(aAttr, pObj.get());
         SetLineEnds(aAttr, *pObj);
diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx
index 7c42b554d550..612282884073 100644
--- a/sd/source/ui/func/fuconstr.cxx
+++ b/sd/source/ui/func/fuconstr.cxx
@@ -54,9 +54,9 @@ FuConstruct::FuConstruct (
     ViewShell&      rViewSh,
     ::sd::Window*           pWin,
     ::sd::View*         pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&     rReq)
-    : FuDraw(rViewSh, pWin, pView, pDoc, rReq),
+    : FuDraw(rViewSh, pWin, pView, rDoc, rReq),
       bSelectionChanged(false)
 {
 }
@@ -330,7 +330,7 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, 
SdrObject* pObj,
 {
     SdPage* pPage = static_cast<SdPage*>(mpView->GetSdrPageView()->GetPage());
     if ( pPage->IsMasterPage() && pPage->GetPageKind() == PageKind::Standard &&
-         mpDoc->GetDocumentType() == DocumentType::Impress )
+         mrDoc.GetDocumentType() == DocumentType::Impress )
     {
         /**********************************************
         * Objects was created on the slide master page
diff --git a/sd/source/ui/func/fuconuno.cxx b/sd/source/ui/func/fuconuno.cxx
index 88b0da9a3abd..01826758c31b 100644
--- a/sd/source/ui/func/fuconuno.cxx
+++ b/sd/source/ui/func/fuconuno.cxx
@@ -41,18 +41,18 @@ FuConstructUnoControl::FuConstructUnoControl (
     ViewShell&  rViewSh,
     ::sd::Window*       pWin,
     ::sd::View*         pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&     rReq)
-    : FuConstruct(rViewSh, pWin, pView, pDoc, rReq)
+    : FuConstruct(rViewSh, pWin, pView, rDoc, rReq)
     , nInventor(SdrInventor::Unknown)
     , nIdentifier(SdrObjKind::NONE)
 {
 }
 
-rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuConstructUnoControl* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( rViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( rViewSh, 
pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent(bPermanent);
     return xFunc;
diff --git a/sd/source/ui/func/fucopy.cxx b/sd/source/ui/func/fucopy.cxx
index 8009fb36baab..c948ac776277 100644
--- a/sd/source/ui/func/fucopy.cxx
+++ b/sd/source/ui/func/fucopy.cxx
@@ -47,15 +47,15 @@ FuCopy::FuCopy (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuCopy::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuCopy::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuCopy( rViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuCopy( rViewSh, pWin, pView, rDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -78,7 +78,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
         SfxItemSetFixed<ATTR_COPY_START, ATTR_COPY_END> aSet( 
mrViewShell.GetPool() );
 
         // indicate color attribute
-        SfxItemSet aAttr( mpDoc->GetPool() );
+        SfxItemSet aAttr( mrDoc.GetPool() );
         mpView->GetAttributes( aAttr );
 
         if( const XFillStyleItem* pFillStyleItem = aAttr.GetItemIfSet( 
XATTR_FILLSTYLE ) )
diff --git a/sd/source/ui/func/fucushow.cxx b/sd/source/ui/func/fucushow.cxx
index 5fa58f43b329..67357ab61641 100644
--- a/sd/source/ui/func/fucushow.cxx
+++ b/sd/source/ui/func/fucushow.cxx
@@ -36,15 +36,15 @@ FuCustomShowDlg::FuCustomShowDlg (
     ViewShell& rViewSh,
     ::sd::Window*    pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor( rViewSh, pWin, pView, pDoc, rReq )
+    : FuPoor( rViewSh, pWin, pView, rDoc, rReq )
 {
 }
 
-rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuCustomShowDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuCustomShowDlg( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -53,10 +53,10 @@ void FuCustomShowDlg::DoExecute( SfxRequest& )
 {
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     vcl::Window* pWin = mrViewShell.GetActiveWindow();
-    ScopedVclPtr<AbstractSdCustomShowDlg> pDlg( 
pFact->CreateSdCustomShowDlg(pWin ? pWin->GetFrameWeld() : nullptr, *mpDoc) );
+    ScopedVclPtr<AbstractSdCustomShowDlg> pDlg( 
pFact->CreateSdCustomShowDlg(pWin ? pWin->GetFrameWeld() : nullptr, mrDoc) );
     sal_uInt16 nRet = pDlg->Execute();
-    mpDoc->SetChanged();
-    sd::PresentationSettings& rSettings = mpDoc->getPresentationSettings();
+    mrDoc.SetChanged();
+    sd::PresentationSettings& rSettings = mrDoc.getPresentationSettings();
 
     if( nRet == RET_YES )
     {
@@ -74,7 +74,7 @@ void FuCustomShowDlg::DoExecute( SfxRequest& )
     }
     if (nRet == RET_OK)
     {
-        if (mpDoc->GetCustomShowList())
+        if (mrDoc.GetCustomShowList())
         {
             if (!pDlg->IsCustomShow())
             {
diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx
index b72ab9399322..bb1811ab037f 100644
--- a/sd/source/ui/func/fudraw.cxx
+++ b/sd/source/ui/func/fudraw.cxx
@@ -63,8 +63,8 @@ namespace sd {
  * Base-class for all drawmodul-specific functions
  */
 FuDraw::FuDraw(ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
-               SdDrawDocument* pDoc, SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+               SdDrawDocument& rDoc, SfxRequest& rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
     , aNewPointer(PointerStyle::Arrow)
     , aOldPointer(PointerStyle::Arrow)
     , bMBDown(false)
diff --git a/sd/source/ui/func/fudspord.cxx b/sd/source/ui/func/fudspord.cxx
index ab95ed832113..9ebb649ca88c 100644
--- a/sd/source/ui/func/fudspord.cxx
+++ b/sd/source/ui/func/fudspord.cxx
@@ -30,8 +30,8 @@
 namespace sd {
 
 
-FuDisplayOrder::FuDisplayOrder( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
-: FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+FuDisplayOrder::FuDisplayOrder( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq)
+: FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 , maPtr(PointerStyle::Arrow)
 , mpRefObj(nullptr)
 {
@@ -46,9 +46,9 @@ void FuDisplayOrder::implClearOverlay()
     mpOverlay.reset();
 }
 
-rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuDisplayOrder::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuDisplayOrder( rViewSh, pWin, pView, 
rDoc, rReq ) );
     return xFunc;
 }
 
diff --git a/sd/source/ui/func/fuediglu.cxx b/sd/source/ui/func/fuediglu.cxx
index 8e4b97306b2e..00e70908c292 100644
--- a/sd/source/ui/func/fuediglu.cxx
+++ b/sd/source/ui/func/fuediglu.cxx
@@ -37,9 +37,9 @@ FuEditGluePoints::FuEditGluePoints (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuDraw(rViewSh, pWin, pView, pDoc, rReq)
+    : FuDraw(rViewSh, pWin, pView, rDoc, 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& rViewSh, 
::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& rDoc, SfxRequest& rReq, 
bool bPermanent )
 {
     FuEditGluePoints* pFunc;
-    rtl::Reference<FuPoor> xFunc( pFunc = new FuEditGluePoints( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( pFunc = new FuEditGluePoints( rViewSh, pWin, 
pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     pFunc->SetPermanent( bPermanent );
     return xFunc;
diff --git a/sd/source/ui/func/fuexecuteinteraction.cxx 
b/sd/source/ui/func/fuexecuteinteraction.cxx
index 26ce457ba482..00a620e92ac7 100644
--- a/sd/source/ui/func/fuexecuteinteraction.cxx
+++ b/sd/source/ui/func/fuexecuteinteraction.cxx
@@ -50,17 +50,17 @@ using namespace css;
 namespace sd
 {
 FuExecuteInteraction::FuExecuteInteraction(ViewShell& rViewSh, ::sd::Window* 
pWin,
-                                           ::sd::View* pView, SdDrawDocument* 
pDoc,
+                                           ::sd::View* pView, SdDrawDocument& 
rDoc,
                                            SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
 rtl::Reference<FuPoor> FuExecuteInteraction::Create(ViewShell& rViewSh, 
::sd::Window* pWin,
-                                                    ::sd::View* pView, 
SdDrawDocument* pDoc,
+                                                    ::sd::View* pView, 
SdDrawDocument& rDoc,
                                                     SfxRequest& rReq)
 {
-    rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(rViewSh, pWin, 
pView, pDoc, rReq));
+    rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(rViewSh, pWin, 
pView, rDoc, rReq));
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index 74625c53eff3..2fbf8d96c385 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -51,15 +51,15 @@ FuExpandPage::FuExpandPage (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuExpandPage::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuExpandPage::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuExpandPage( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuExpandPage( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -72,13 +72,13 @@ void FuExpandPage::DoExecute( SfxRequest& )
     // find selected page (only standard pages)
     SdPage* pActualPage = nullptr;
     sal_uInt16 i = 0;
-    sal_uInt16 nCount = mpDoc->GetSdPageCount(PageKind::Standard);
+    sal_uInt16 nCount = mrDoc.GetSdPageCount(PageKind::Standard);
 
     while (!pActualPage && i < nCount)
     {
-        if (mpDoc->GetSdPage(i, PageKind::Standard)->IsSelected())
+        if (mrDoc.GetSdPage(i, PageKind::Standard)->IsSelected())
         {
-            pActualPage = mpDoc->GetSdPage(i, PageKind::Standard);
+            pActualPage = mrDoc.GetSdPage(i, PageKind::Standard);
         }
 
         i++;
@@ -87,19 +87,19 @@ void FuExpandPage::DoExecute( SfxRequest& )
     if (!pActualPage)
         return;
 
-    SdOutliner aOutliner( mpDoc, OutlinerMode::OutlineObject );
+    SdOutliner aOutliner( mrDoc, OutlinerMode::OutlineObject );
     aOutliner.SetUpdateLayout(false);
     aOutliner.EnableUndo(false);
 
     if (mpDocSh)
         aOutliner.SetRefDevice(SdModule::get()->GetVirtualRefDevice());
 
-    aOutliner.SetDefTab( mpDoc->GetDefaultTabulator() );
-    
aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
+    aOutliner.SetDefTab( mrDoc.GetDefaultTabulator() );
+    
aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mrDoc.GetStyleSheetPool()));
 
     SdrLayerIDSet aVisibleLayers = 
pActualPage->TRG_GetMasterPageVisibleLayers();
     sal_uInt16 nActualPageNum = pActualPage->GetPageNum();
-    SdPage* pActualNotesPage = 
static_cast<SdPage*>(mpDoc->GetPage(nActualPageNum + 1));
+    SdPage* pActualNotesPage = 
static_cast<SdPage*>(mrDoc.GetPage(nActualPageNum + 1));
     SdrTextObj* pActualOutline = 
static_cast<SdrTextObj*>(pActualPage->GetPresObj(PresObjKind::Outline));
 
     if (pActualOutline)
@@ -114,7 +114,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
         aOutliner.SetText(*pParaObj);
 
         // remove hard paragraph- and character attributes
-        SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> 
aEmptyEEAttr(mpDoc->GetPool());
+        SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> 
aEmptyEEAttr(mrDoc.GetPool());
         sal_Int32 nParaCount1 = aOutliner.GetParagraphCount();
 
         for (sal_Int32 nPara = 0; nPara < nParaCount1; nPara++)
@@ -133,7 +133,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
             if ( nDepth == 0 )
             {
                 // page with title & structuring!
-                rtl::Reference<SdPage> pPage = mpDoc->AllocSdPage(false);
+                rtl::Reference<SdPage> pPage = mrDoc.AllocSdPage(false);
                 pPage->SetSize(pActualPage->GetSize() );
                 pPage->SetBorder(pActualPage->GetLeftBorder(),
                                  pActualPage->GetUpperBorder(),
@@ -142,11 +142,11 @@ void FuExpandPage::DoExecute( SfxRequest& )
                 pPage->SetName(OUString());
 
                 // insert page after current page
-                mpDoc->InsertPage(pPage.get(), nActualPageNum + nPos);
+                mrDoc.InsertPage(pPage.get(), nActualPageNum + nPos);
                 nPos++;
 
                 if( bUndo )
-                    
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
+                    
mpView->AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pPage));
 
                 // use MasterPage of the current page
                 pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
@@ -155,7 +155,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
                 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
 
                 // notes-page
-                rtl::Reference<SdPage> pNotesPage = mpDoc->AllocSdPage(false);
+                rtl::Reference<SdPage> pNotesPage = mrDoc.AllocSdPage(false);
                 pNotesPage->SetSize(pActualNotesPage->GetSize());
                 pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
                                       pActualNotesPage->GetUpperBorder(),
@@ -165,11 +165,11 @@ void FuExpandPage::DoExecute( SfxRequest& )
                 pNotesPage->SetName(OUString());
 
                 // insert page after current page
-                mpDoc->InsertPage(pNotesPage.get(), nActualPageNum + nPos);
+                mrDoc.InsertPage(pNotesPage.get(), nActualPageNum + nPos);
                 nPos++;
 
                 if( bUndo )
-                    
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
+                    
mpView->AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
 
                 // use MasterPage of the current page
                 
pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
@@ -188,7 +188,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
 
                 if( pOutlinerParaObject->GetDepth(0) != -1 )
                 {
-                    std::unique_ptr<SdrOutliner> pTempOutl = 
SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc);
+                    std::unique_ptr<SdrOutliner> pTempOutl = 
SdrMakeOutliner(OutlinerMode::TitleObject, mrDoc);
 
                     pTempOutl->SetText( *pOutlinerParaObject );
 
@@ -215,7 +215,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
                     // create structuring text objects
                     std::optional<OutlinerParaObject> pOPO = 
aOutliner.CreateParaObject(++nParaPos, nChildCount);
 
-                    std::unique_ptr<SdrOutliner> pTempOutl = 
SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
+                    std::unique_ptr<SdrOutliner> pTempOutl = 
SdrMakeOutliner(OutlinerMode::OutlineObject, mrDoc);
                     pTempOutl->SetText( *pOPO );
 
                     sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount();
@@ -234,7 +234,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
                     pOutlineObj->SetEmptyPresObj(false);
 
                     // remove hard attributes (Flag to sal_True)
-                    SfxItemSet aAttr(mpDoc->GetPool());
+                    SfxItemSet aAttr(mrDoc.GetPool());
                     aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
                     aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
                     pOutlineObj->SetMergedItemSet(aAttr);
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx 
b/sd/source/ui/func/fuformatpaintbrush.cxx
index 19eafbdae1cc..747e38a2a00c 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& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
-: FuText(rViewSh, pWin, pView, pDoc, rReq)
+FuFormatPaintBrush::FuFormatPaintBrush( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
+: FuText(rViewSh, pWin, pView, rDoc, rReq)
     , mnDepth(-1)
     , mbPermanent( false )
     , mbOldIsQuickTextEditMode(true)
 {
 }
 
-rtl::Reference<FuPoor> FuFormatPaintBrush::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuFormatPaintBrush::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuFormatPaintBrush( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuFormatPaintBrush( rViewSh, pWin, 
pView, rDoc, rReq ) );
     xFunc->DoExecute( rReq );
     return xFunc;
 }
@@ -259,7 +259,7 @@ void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, 
bool bNoParagraphForma
         return;
 
     SdrObject* pObj( nullptr );
-    bool bUndo = mpDoc->IsUndoEnabled();
+    bool bUndo = mrDoc.IsUndoEnabled();
 
     if( bUndo && !mpView->GetTextEditOutlinerView() )
         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
@@ -269,16 +269,16 @@ void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, 
bool bNoParagraphForma
     if( pObj )
     {
         OUString sLabel( 
mrViewShell.GetViewShellBase().RetrieveLabelFromCommand(u".uno:FormatPaintbrush"_ustr
 ) );
-        mpDoc->BegUndo( sLabel );
+        mrDoc.BegUndo( sLabel );
         if (dynamic_cast< sdr::table::SdrTableObj* >( pObj ) == nullptr)
-            mpDoc->AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( 
*pObj, false, true ) );
+            mrDoc.AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoAttrObject( 
*pObj, false, true ) );
     }
 
     mpView->ApplyFormatPaintBrush( *mxItemSet, mnDepth, bNoCharacterFormats, 
bNoParagraphFormats );
 
     if( pObj )
     {
-        mpDoc->EndUndo();
+        mrDoc.EndUndo();
     }
 }
 
diff --git a/sd/source/ui/func/fuhhconv.cxx b/sd/source/ui/func/fuhhconv.cxx
index df7b95e316c1..f6de081cfffe 100644
--- a/sd/source/ui/func/fuhhconv.cxx
+++ b/sd/source/ui/func/fuhhconv.cxx
@@ -55,21 +55,21 @@ FuHangulHanjaConversion::FuHangulHanjaConversion (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDocument,
+    SdDrawDocument& rDocument,
     SfxRequest& rReq )
-       : FuPoor(rViewSh, pWin, pView, pDocument, rReq),
+       : FuPoor(rViewSh, pWin, pView, rDocument, rReq),
     pSdOutliner(nullptr),
     bOwnOutliner(false)
 {
     if ( dynamic_cast< const DrawViewShell *>( &mrViewShell ) !=  nullptr )
     {
         bOwnOutliner = true;
-        pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
+        pSdOutliner = new SdOutliner( mrDoc, OutlinerMode::TextObject );
     }
     else if ( dynamic_cast< const OutlineViewShell *>( &mrViewShell ) !=  
nullptr )
     {
         bOwnOutliner = false;
-        pSdOutliner = mpDoc->GetOutliner();
+        pSdOutliner = mrDoc.GetOutliner();
     }
 
     if (pSdOutliner)
@@ -85,9 +85,9 @@ FuHangulHanjaConversion::~FuHangulHanjaConversion()
         delete pSdOutliner;
 }
 
-rtl::Reference<FuPoor> FuHangulHanjaConversion::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuHangulHanjaConversion::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuHangulHanjaConversion( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuHangulHanjaConversion( rViewSh, pWin, 
pView, rDoc, rReq ) );
     return xFunc;
 }
 
@@ -110,7 +110,7 @@ void FuHangulHanjaConversion::StartConversion( LanguageType 
nSourceLanguage, Lan
             pSdOutliner->EndConversion();
 
             bOwnOutliner = true;
-            pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
+            pSdOutliner = new SdOutliner( mrDoc, OutlinerMode::TextObject );
             pSdOutliner->BeginConversion();
         }
         else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( 
pViewShell ) !=  nullptr && bOwnOutliner )
@@ -119,7 +119,7 @@ void FuHangulHanjaConversion::StartConversion( LanguageType 
nSourceLanguage, Lan
             delete pSdOutliner;
 
             bOwnOutliner = false;
-            pSdOutliner = mpDoc->GetOutliner();
+            pSdOutliner = mrDoc.GetOutliner();
             pSdOutliner->BeginConversion();
         }
 
@@ -147,10 +147,7 @@ void FuHangulHanjaConversion::StartConversion( 
LanguageType nSourceLanguage, Lan
 
 void FuHangulHanjaConversion::ConvertStyles( LanguageType nTargetLanguage, 
const vcl::Font *pTargetFont )
 {
-    if( !mpDoc )
-        return;
-
-    SfxStyleSheetBasePool* pStyleSheetPool = mpDoc->GetStyleSheetPool();
+    SfxStyleSheetBasePool* pStyleSheetPool = mrDoc.GetStyleSheetPool();
     if( !pStyleSheetPool )
         return;
 
@@ -180,7 +177,7 @@ void FuHangulHanjaConversion::ConvertStyles( LanguageType 
nTargetLanguage, const
         pStyle = pStyleSheetPool->Next();
     }
 
-    mpDoc->SetLanguage( nTargetLanguage, EE_CHAR_LANGUAGE_CJK );
+    mrDoc.SetLanguage( nTargetLanguage, EE_CHAR_LANGUAGE_CJK );
 }
 
 void FuHangulHanjaConversion::StartChineseConversion()
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 44470c09b4d4..041a4465172a 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -94,18 +94,18 @@ FuInsertGraphic::FuInsertGraphic (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq,
     bool replaceExistingImage)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq),
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq),
       mbReplaceExistingImage(replaceExistingImage)
 {
 }
 
 rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView,
-                                                SdDrawDocument* pDoc, 
SfxRequest& rReq, bool replaceExistingImage )
+                                                SdDrawDocument& rDoc, 
SfxRequest& rReq, bool replaceExistingImage )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( rViewSh, pWin, pView, 
pDoc, rReq, replaceExistingImage ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( rViewSh, pWin, pView, 
rDoc, rReq, replaceExistingImage ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -210,15 +210,15 @@ FuInsertClipboard::FuInsertClipboard (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertClipboard::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertClipboard::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertClipboard( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertClipboard( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -279,15 +279,15 @@ FuInsertOLE::FuInsertOLE (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertOLE( rViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertOLE( rViewSh, pWin, pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -477,7 +477,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                         break;
                     }
                     aServerLst.FillInsertObjects();
-                    if (mpDoc->GetDocumentType() == DocumentType::Draw)
+                    if (mrDoc.GetDocumentType() == DocumentType::Draw)
                     {
                         aServerLst.Remove( 
GraphicDocShell::Factory().GetClassId() );
                     }
@@ -672,15 +672,15 @@ FuInsertAVMedia::FuInsertAVMedia(
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertAVMedia::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertAVMedia::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertAVMedia( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertAVMedia( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index e9fc1eee39b0..7e8bd84aaf04 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -107,15 +107,15 @@ FuInsertFile::FuInsertFile (
     ViewShell&    rViewSh,
     ::sd::Window*      pWin,
     ::sd::View*        pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&    rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuInsertFile::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuInsertFile::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuInsertFile( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuInsertFile( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -142,7 +142,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
 
         aFileDialog.SetTitle( SdResId(STR_DLG_INSERT_PAGES_FROM_FILE) );
 
-        if( mpDoc->GetDocumentType() == DocumentType::Impress )
+        if( mrDoc.GetDocumentType() == DocumentType::Impress )
         {
             aOwnCont = "simpress";
             aOtherCont = "sdraw";
@@ -165,7 +165,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
                 lcl_AddFilter( aFilterVector, pFilter );
 
                 // get template filter
-                if( mpDoc->GetDocumentType() == DocumentType::Impress )
+                if( mrDoc.GetDocumentType() == DocumentType::Impress )
                     pFilter = DrawDocShell::Factory().GetTemplateFilter();
                 else
                     pFilter = GraphicDocShell::Factory().GetTemplateFilter();
@@ -317,7 +317,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
     mpDocSh->SetWaitCursor( false );
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     weld::Window* pParent = mrViewShell.GetFrameWeld();
-    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(pParent, mpDoc, pMedium, aFile) );
+    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(pParent, &mrDoc, pMedium, aFile) );
 
     sal_uInt16 nRet = pDlg->Execute();
 
@@ -373,7 +373,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
             bNameOK = mpView->GetExchangeList( aExchangeList, aBookmarkList, 0 
);
 
             if( bNameOK )
-                bOK = mpDoc->InsertFileAsPage( aBookmarkList, &aExchangeList,
+                bOK = mrDoc.InsertFileAsPage( aBookmarkList, &aExchangeList,
                                     bLink, nPos, nullptr );
 
             aBookmarkList.clear();
@@ -384,11 +384,11 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
         bNameOK = mpView->GetExchangeList( aExchangeList, aObjectBookmarkList, 
1 );
 
         if( bNameOK )
-            bOK = mpDoc->InsertBookmarkAsObject( aObjectBookmarkList, 
aExchangeList,
+            bOK = mrDoc.InsertBookmarkAsObject( aObjectBookmarkList, 
aExchangeList,
                                 nullptr, nullptr, false );
 
         if( pDlg->IsRemoveUnnecessaryMasterPages() )
-            mpDoc->RemoveUnnecessaryMasterPages();
+            mrDoc.RemoveUnnecessaryMasterPages();
     }
 
     return bOK;
@@ -397,7 +397,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
 void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
 {
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
-    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(mrViewShell.GetFrameWeld(), mpDoc, nullptr, 
aFile) );
+    ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( 
pFact->CreateSdInsertPagesObjsDlg(mrViewShell.GetFrameWeld(), &mrDoc, nullptr, 
aFile) );
 
     mpDocSh->SetWaitCursor( false );
 
@@ -421,7 +421,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
        - the draw outliner of the drawing engine has to draw something in
          between
        - the global outliner could be used in SdPage::CreatePresObj */
-    SdOutliner aOutliner( mpDoc, OutlinerMode::TextObject );
+    SdOutliner aOutliner( mrDoc, OutlinerMode::TextObject );
 
     // set reference device
     aOutliner.SetRefDevice(SdModule::get()->GetVirtualRefDevice());
@@ -498,7 +498,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
             /* can be bigger as the maximal allowed size:
                limit object size if necessary */
             Size aSize(aOutliner.CalcTextSize());
-            Size aMaxSize = mpDoc->GetMaxObjSize();
+            Size aMaxSize = mrDoc.GetMaxObjSize();
             aSize.setHeight( std::min(aSize.Height(), aMaxSize.Height()) );
             aSize.setWidth( std::min(aSize.Width(), aMaxSize.Width()) );
             aSize = mpWindow->LogicToPixel(aSize);
@@ -519,7 +519,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
 
             if( bUndo )
             {
-                
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
+                
mpView->AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
                 mpView->EndUndo();
             }
         }
@@ -559,7 +559,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
             nPage++;
         pPara = rDocliner.GetParagraph( nPos - 1 );
     }
-    SdPage* pPage = mpDoc->GetSdPage(nPage, PageKind::Standard);
+    SdPage* pPage = mrDoc.GetSdPage(nPage, PageKind::Standard);
     aLayoutName = pPage->GetLayoutName();
     sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR);
     if( nIndex != -1 )
@@ -571,8 +571,8 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
        - the draw outliner of the drawing engine has to draw something in
          between
        - the global outliner could be used in SdPage::CreatePresObj */
-    ::Outliner aOutliner( &mpDoc->GetItemPool(), OutlinerMode::OutlineObject );
-    
aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
+    ::Outliner aOutliner( &mrDoc.GetItemPool(), OutlinerMode::OutlineObject );
+    
aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mrDoc.GetStyleSheetPool()));
 
     // set reference device
     aOutliner.SetRefDevice(SdModule::get()->GetVirtualRefDevice());
@@ -632,7 +632,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
                 OUString aStyleSheetName( pStyleSheet->GetName() );
                 aStyleSheetName = aStyleSheetName.subView( 0, 
aStyleSheetName.getLength()-1 ) +
                     OUString::number( nDepth <= 0 ? 1 : nDepth+1 );
-                SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool();
+                SfxStyleSheetBasePool* pStylePool = mrDoc.GetStyleSheetPool();
                 SfxStyleSheet* pOutlStyle = static_cast<SfxStyleSheet*>( 
pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
                 rDocliner.SetStyleSheet( nTargetPos, pOutlStyle );
             }
diff --git a/sd/source/ui/func/fuline.cxx b/sd/source/ui/func/fuline.cxx
index 1dcfe0058e4f..868fc97163d2 100644
--- a/sd/source/ui/func/fuline.cxx
+++ b/sd/source/ui/func/fuline.cxx
@@ -35,15 +35,15 @@ FuLine::FuLine (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLine::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLine::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLine( rViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuLine( rViewSh, pWin, pView, rDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -61,12 +61,12 @@ void FuLine::DoExecute( SfxRequest& rReq )
     if( rMarkList.GetMarkCount() == 1 )
         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
 
-    SfxItemSet aNewAttr( mpDoc->GetPool() );
+    SfxItemSet aNewAttr( mrDoc.GetPool() );
     mpView->GetAttributes( aNewAttr );
 
     bool bHasMarked = rMarkList.GetMarkCount() != 0;
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    VclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSvxLineTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, mpDoc, 
pObj, bHasMarked) );
+    VclPtr<SfxAbstractTabDialog> pDlg( 
pFact->CreateSvxLineTabDialog(mrViewShell.GetFrameWeld(), &aNewAttr, &mrDoc, 
pObj, bHasMarked) );
 
     pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult){
         if (nResult == RET_OK)
diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx
index 4f995004ba92..e7ad70bdaa3f 100644
--- a/sd/source/ui/func/fulinend.cxx
+++ b/sd/source/ui/func/fulinend.cxx
@@ -37,14 +37,14 @@ namespace sd {
 
 
 FuLineEnd::FuLineEnd(ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
-                    SdDrawDocument* pDoc, SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+                    SdDrawDocument& rDoc, SfxRequest& rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLineEnd::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLineEnd::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLineEnd( rViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuLineEnd( rViewSh, pWin, pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -91,7 +91,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
     // Delete the created poly-object
     pConvPolyObj.clear();
 
-    XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
+    XLineEndListRef pLineEndList = mrDoc.GetLineEndList();
 
     OUString aNewName( SdResId( STR_LINEEND ) );
     OUString aDesc( SdResId( STR_DESC_LINEEND ) );
diff --git a/sd/source/ui/func/fulink.cxx b/sd/source/ui/func/fulink.cxx
index 89095f15f3ad..9f299fa0668a 100644
--- a/sd/source/ui/func/fulink.cxx
+++ b/sd/source/ui/func/fulink.cxx
@@ -41,15 +41,15 @@ FuLink::FuLink (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq )
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuLink::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuLink::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuLink( rViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuLink( rViewSh, pWin, pView, rDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -65,7 +65,7 @@ void FuLink::DoExecute( SfxRequest& )
         return;
     }
 
-    sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager();
+    sfx2::LinkManager* pLinkManager = mrDoc.GetLinkManager();
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     VclPtr<SfxAbstractLinksDialog> 
pDlg(pFact->CreateLinksDialog(mrViewShell.GetFrameWeld(), pLinkManager));
diff --git a/sd/source/ui/func/fumeasur.cxx b/sd/source/ui/func/fumeasur.cxx
index 5c8df27450d6..6d3c02cec3e2 100644
--- a/sd/source/ui/func/fumeasur.cxx
+++ b/sd/source/ui/func/fumeasur.cxx
@@ -31,22 +31,22 @@ FuMeasureDlg::FuMeasureDlg (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuMeasureDlg::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuMeasureDlg::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuMeasureDlg( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuMeasureDlg( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
 
 void FuMeasureDlg::DoExecute( SfxRequest& rReq )
 {
-    SfxItemSet aNewAttr( mpDoc->GetPool() );
+    SfxItemSet aNewAttr( mrDoc.GetPool() );
     mpView->GetAttributes( aNewAttr );
 
     const SfxItemSet* pArgs = rReq.GetArgs();
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index d5179f6d61de..6af6d1cc8a79 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -52,9 +52,9 @@ FuMorph::FuMorph (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq )
-    :   FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    :   FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
@@ -62,11 +62,11 @@ rtl::Reference<FuPoor> FuMorph::Create(
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq
 )
 {
-    rtl::Reference<FuPoor> xFunc( new FuMorph( rViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuMorph( rViewSh, pWin, pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
diff --git a/sd/source/ui/func/funavig.cxx b/sd/source/ui/func/funavig.cxx
index 4b9303ec0d72..ccb2e74660e4 100644
--- a/sd/source/ui/func/funavig.cxx
+++ b/sd/source/ui/func/funavig.cxx
@@ -41,15 +41,15 @@ FuNavigation::FuNavigation (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuNavigation::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuNavigation::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuNavigation( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuNavigation( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -116,7 +116,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
                     SdPage* pPage = pDrawViewShell->GetActualPage();
                     sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
 
-                    if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) 
- 1)
+                    if (nSdPage < mrDoc.GetSdPageCount(pPage->GetPageKind()) - 
1)
                     {
                         // Switch the page and send events regarding
                         // deactivation the old page and activating the new
@@ -140,7 +140,7 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
                 {
                     // jump to last page
                     SdPage* pPage = pDrawViewShell->GetActualPage();
-                    pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
+                    pDrawViewShell->SwitchPage(mrDoc.GetSdPageCount(
                             pPage->GetPageKind()) - 1);
                 }
         }
@@ -154,14 +154,14 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
                     OUString sTitle = SdResId(STR_GOTO_PAGE_DLG_TITLE);
                     OUString sLabel = SdResId(STR_PAGE_NAME) + ":";
 
-                    if (mpDoc->GetDocumentType() == DocumentType::Impress)
+                    if (mrDoc.GetDocumentType() == DocumentType::Impress)
                     {
                         sTitle = SdResId(STR_GOTO_SLIDE_DLG_TITLE);
                         sLabel = SdResId(STR_SLIDE_NAME) + ":";
                     }
                     svx::GotoPageDlg aDlg(pDrawViewShell->GetFrameWeld(), 
sTitle, sLabel,
                          pDrawViewShell->GetCurPagePos() + 1,
-                         mpDoc->GetSdPageCount(PageKind::Standard));
+                         mrDoc.GetSdPageCount(PageKind::Standard));
                     if (aDlg.run() == RET_OK)
                         pDrawViewShell->SwitchPage(aDlg.GetPageSelection() - 
1);
                 }
diff --git a/sd/source/ui/func/fuoaprms.cxx b/sd/source/ui/func/fuoaprms.cxx
index 62d601106848..a177c9318a42 100644
--- a/sd/source/ui/func/fuoaprms.cxx
+++ b/sd/source/ui/func/fuoaprms.cxx
@@ -59,15 +59,15 @@ FuObjectAnimationParameters::FuObjectAnimationParameters (
     ViewShell&   rViewSh,
     ::sd::Window*        pWin,
     ::sd::View*      pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest&  rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell& 
rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, 
SfxRequest& rReq )
+rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell& 
rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, 
SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( rViewSh, 
pWin, pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( rViewSh, 
pWin, pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -335,7 +335,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& 
rReq )
     if(!pArgs)
     {
         // fill ItemSet for dialog
-        std::shared_ptr<SfxItemSet> aSet = 
std::make_shared<SfxItemSetFixed<ATTR_ANIMATION_START, 
ATTR_ACTION_END>>(mpDoc->GetPool());
+        std::shared_ptr<SfxItemSet> aSet = 
std::make_shared<SfxItemSetFixed<ATTR_ANIMATION_START, 
ATTR_ACTION_END>>(mrDoc.GetPool());
 
         // fill the set
         if (nAnimationSet == ATTR_SET)
@@ -667,7 +667,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
     pUndoMgr->EnterListAction(aComment, aComment, 0, 
mrViewShell.GetViewShellBase().GetViewShellId());
 
     // create undo group
-    std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc));
+    std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(&mrDoc));
     pUndoGroup->SetComment(aComment);
 
     // for the path effect, remember some stuff
@@ -716,7 +716,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
             Size aDistance(aNewCenter.X() - aCurCenter.X(), aNewCenter.Y() - 
aCurCenter.Y());
             pRunningObj->Move(aDistance);
 
-            
pUndoMgr->AddUndoAction(mpDoc->GetSdrUndoFactory().CreateUndoMoveObject( 
*pRunningObj, aDistance));
+            
pUndoMgr->AddUndoAction(mrDoc.GetSdrUndoFactory().CreateUndoMoveObject( 
*pRunningObj, aDistance));
         }
     }
 
@@ -737,7 +737,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
         if (eEffect == presentation::AnimationEffect_PATH && pObject == pPath)
         {
             SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
-                                            (mpDoc, pObject, bCreated);
+                                            (&mrDoc, pObject, bCreated);
             pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
             pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
             pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
@@ -763,7 +763,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
 
             // create undo action with old and new sizes
             SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
-                                            (mpDoc, pObject, bCreated);
+                                            (&mrDoc, pObject, bCreated);
             pAction->SetActive(pInfo->mbActive, bActive);
             pAction->SetEffect(pInfo->meEffect, eEffect);
             pAction->SetTextEffect(pInfo->meTextEffect, eTextEffect);
@@ -841,7 +841,7 @@ void FuObjectAnimationParameters::Finish( const 
std::shared_ptr<SfxRequest>& xRe
     pUndoMgr->LeaveListAction();
 
     // Model changed
-    mpDoc->SetChanged();
+    mrDoc.SetChanged();
     // not seen, therefore we do not need to invalidate at the bindings
 }
 
diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx
index d2ea81280c2a..d9db92f27fe3 100644
--- a/sd/source/ui/func/fuolbull.cxx
+++ b/sd/source/ui/func/fuolbull.cxx
@@ -42,15 +42,15 @@ using namespace svx::sidebar;
 namespace sd {
 
 FuBulletAndPosition::FuBulletAndPosition(ViewShell& rViewShell, ::sd::Window* 
pWindow,
-                                 ::sd::View* pView, SdDrawDocument* pDoc,
+                                 ::sd::View* pView, SdDrawDocument& rDoc,
                                  SfxRequest& rReq)
-       : FuPoor(rViewShell, pWindow, pView, pDoc, rReq)
+       : FuPoor(rViewShell, pWindow, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuBulletAndPosition::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuBulletAndPosition::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuBulletAndPosition( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuBulletAndPosition( rViewSh, pWin, 
pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -76,7 +76,7 @@ void FuBulletAndPosition::DoExecute( SfxRequest& rReq )
     }
 
     // fill ItemSet for Dialog
-    SfxItemSet aEditAttr( mpDoc->GetPool() );
+    SfxItemSet aEditAttr( mrDoc.GetPool() );
     mpView->GetAttributes( aEditAttr );
 
     SfxItemSetFixed<EE_PARA_NUMBULLET, EE_PARA_BULLET> aNewAttr( 
mrViewShell.GetPool() );
@@ -113,7 +113,7 @@ void FuBulletAndPosition::DoExecute( SfxRequest& rReq )
 
 void FuBulletAndPosition::SetCurrentBulletsNumbering(SfxRequest& rReq)
 {
-    if (!mpDoc || !mpView)
+    if (!mpView)
         return;
 
     const sal_uInt16 nSId = rReq.GetSlot();
@@ -134,7 +134,7 @@ void 
FuBulletAndPosition::SetCurrentBulletsNumbering(SfxRequest& rReq)
 
     SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aNewAttr( 
mrViewShell.GetPool() );
     {
-        SfxItemSet aEditAttr( mpDoc->GetPool() );
+        SfxItemSet aEditAttr( mrDoc.GetPool() );
         mpView->GetAttributes( aEditAttr );
         aNewAttr.Put( aEditAttr, false );
     }
diff --git a/sd/source/ui/func/fuoltext.cxx b/sd/source/ui/func/fuoltext.cxx
index 5298571f1555..216a86d7c631 100644
--- a/sd/source/ui/func/fuoltext.cxx
+++ b/sd/source/ui/func/fuoltext.cxx
@@ -107,23 +107,23 @@ bool FuOutlineText::KeyInput(const KeyEvent& rKEvt)
     return false;
 }
 
-rtl::Reference<FuPoor> FuOutlineText::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::SimpleOutlinerView* pView, SdDrawDocument* pDoc, 
SfxRequest& rReq )
+rtl::Reference<FuPoor> FuOutlineText::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::SimpleOutlinerView* pView, SdDrawDocument& rDoc, 
SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuOutlineText( rViewSh, pWin, pView, 
pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuOutlineText( rViewSh, pWin, pView, 
rDoc, rReq ) );
     xFunc->DoExecute( rReq );
     return xFunc;
 }
 
 FuOutlineText::FuOutlineText(ViewShell& rViewShell, ::sd::Window* pWindow,
-                             ::sd::SimpleOutlinerView* pView, SdDrawDocument* 
pDoc,
+                             ::sd::SimpleOutlinerView* pView, SdDrawDocument& 
rDoc,
                              SfxRequest& rReq)
-       : FuSimpleOutlinerText(rViewShell, pWindow, pView, pDoc, rReq)
+       : FuSimpleOutlinerText(rViewShell, pWindow, pView, rDoc, rReq)
 {}
 
 FuSimpleOutlinerText::FuSimpleOutlinerText(ViewShell& rViewShell, 
::sd::Window* pWindow,
-                             ::sd::SimpleOutlinerView* pView, SdDrawDocument* 
pDoc,
+                             ::sd::SimpleOutlinerView* pView, SdDrawDocument& 
rDoc,
                              SfxRequest& rReq)
-       : FuPoor(rViewShell, pWindow, pView, pDoc, rReq),
+       : FuPoor(rViewShell, pWindow, pView, rDoc, rReq),
          mpSimpleOutlinerView (pView)
 {
 }
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index ee97cd1694fa..59827af6147f 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -100,8 +100,8 @@ static void mergeItemSetsImpl( SfxItemSet& rTarget, const 
SfxItemSet& rSource )
 }
 
 FuPage::FuPage( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
-                 SdDrawDocument* pDoc, SfxRequest& rReq )
-:   FuPoor(rViewSh, pWin, pView, pDoc, rReq),
+                 SdDrawDocument& rDoc, SfxRequest& rReq )
+:   FuPoor(rViewSh, pWin, pView, rDoc, rReq),
     mbPageBckgrdDeleted( false ),
     mbMasterPage( false ),
     mbDisplayBackgroundTabPage( true ),
@@ -110,9 +110,9 @@ FuPage::FuPage( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView,
 {
 }
 
-rtl::Reference<FuPoor> FuPage::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuPage::Create( ViewShell& rViewSh, ::sd::Window* pWin, 
::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuPage( rViewSh, pWin, pView, pDoc, rReq 
) );
+    rtl::Reference<FuPoor> xFunc( new FuPage( rViewSh, pWin, pView, rDoc, rReq 
) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -203,10 +203,10 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
         XATTR_FILL_FIRST, XATTR_FILL_LAST, EE_PARA_WRITINGDIR, 
EE_PARA_WRITINGDIR,
         SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_SHADOW,
         SID_ATTR_BORDER_SHADOW, SID_ATTR_PAGE, SID_ATTR_PAGE_SHARED, 
SID_ATTR_CHAR_GRABBAG,
-        SID_ATTR_CHAR_GRABBAG, SID_ATTR_PAGE_COLOR, 
SID_ATTR_PAGE_FILLSTYLE>(mpDoc->GetPool()));
+        SID_ATTR_CHAR_GRABBAG, SID_ATTR_PAGE_COLOR, 
SID_ATTR_PAGE_FILLSTYLE>(mrDoc.GetPool()));
     // Keep it sorted
-    
aNewAttr->MergeRange(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
-                         
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
+    
aNewAttr->MergeRange(mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
+                         
mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
 
     // Retrieve additional data for dialog
 
@@ -216,7 +216,7 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
     aNewAttr->Put( aBoxItem );
 
     aNewAttr->Put( SvxFrameDirectionItem(
-        mpDoc->GetDefaultWritingMode() == css::text::WritingMode_RL_TB ? 
SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB,
+        mrDoc.GetDefaultWritingMode() == css::text::WritingMode_RL_TB ? 
SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB,
         EE_PARA_WRITINGDIR ) );
 
     // Retrieve page-data for dialog
@@ -225,7 +225,7 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
     aPageItem.SetDescName( mpPage->GetName() );
     aPageItem.SetPageUsage( SvxPageUsage::All );
     aPageItem.SetLandscape( mpPage->GetOrientation() == Orientation::Landscape 
);
-    aPageItem.SetNumType( mpDoc->GetPageNumType() );
+    aPageItem.SetNumType( mrDoc.GetPageNumType() );
     aNewAttr->Put( aPageItem );
 
     // size
@@ -244,14 +244,14 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
     SvxLRSpaceItem aLRSpaceItem(SvxIndentValue::twips(mpPage->GetLeftBorder()),
                                 
SvxIndentValue::twips(mpPage->GetRightBorder()),
                                 SvxIndentValue::zero(),
-                                
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE));
+                                
mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE));
     aNewAttr->Put( aLRSpaceItem );
 
-    SvxULSpaceItem aULSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetUpperBorder()), 
static_cast<sal_uInt16>(mpPage->GetLowerBorder()), 
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
+    SvxULSpaceItem aULSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetUpperBorder()), 
static_cast<sal_uInt16>(mpPage->GetLowerBorder()), 
mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
     aNewAttr->Put( aULSpaceItem );
 
     // Application
-    bool bScale = mpDoc->GetDocumentType() != DocumentType::Draw;
+    bool bScale = mrDoc.GetDocumentType() != DocumentType::Draw;
     aNewAttr->Put( SfxBoolItem( SID_ATTR_PAGE_EXT1, bScale ) );
 
     bool bFullSize = mpPage->IsMasterPage() ?
@@ -327,14 +327,14 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
 
         if (nError == ERRCODE_NONE)
         {
-            SfxItemSet tempSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, 
XATTR_FILL_LAST> );
+            SfxItemSet tempSet( mrDoc.GetPool(), svl::Items<XATTR_FILL_FIRST, 
XATTR_FILL_LAST> );
 
             tempSet.Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
 
             // MigrateItemSet makes sure the XFillBitmapItem will have a 
unique name
-            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLBITMAP, 
XATTR_FILLBITMAP>(mpDoc->GetPool()));
+            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLBITMAP, 
XATTR_FILLBITMAP>(mrDoc.GetPool()));
             aMigrateSet.Put(XFillBitmapItem(u"background"_ustr, 
std::move(aGraphic)));
-            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc );
+            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, mrDoc );
 
             tempSet.Put( XFillBmpStretchItem( true ));
             tempSet.Put( XFillBmpTileItem( false ));
@@ -405,24 +405,24 @@ void FuPage::ApplyItemSet(SdStyleSheet& styleSheet, const 
std::shared_ptr<SfxIte
         if (pTempGradItem && pTempGradItem->GetName().isEmpty())
         {
             // MigrateItemSet guarantees unique gradient names
-            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLGRADIENT, 
XATTR_FILLGRADIENT>(mpDoc->GetPool()));
+            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLGRADIENT, 
XATTR_FILLGRADIENT>(mrDoc.GetPool()));
             aMigrateSet.Put( XFillGradientItem(u"gradient"_ustr, 
pTempGradItem->GetGradientValue()) );
-            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc);
+            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, mrDoc);
         }
 
         const XFillHatchItem* pTempHatchItem = 
tempSet.GetItem<XFillHatchItem>(XATTR_FILLHATCH);
         if (pTempHatchItem && pTempHatchItem->GetName().isEmpty())
         {
             // MigrateItemSet guarantees unique hatch names
-            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLHATCH, 
XATTR_FILLHATCH>(mpDoc->GetPool()));
+            SfxItemSet 
aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLHATCH, 
XATTR_FILLHATCH>(mrDoc.GetPool()));
             aMigrateSet.Put( XFillHatchItem(u"hatch"_ustr, 
pTempHatchItem->GetHatchValue()) );
-            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc);
+            SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, mrDoc);
         }
 
         if( !mbMasterPage && bChanges && mbPageBckgrdDeleted )
         {
             mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction(
-                *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) 
);
+                mrDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) );
 
             if(!mpPage->IsMasterPage())
             {
@@ -445,7 +445,7 @@ void FuPage::ApplyItemSet(SdStyleSheet& styleSheet, const 
std::shared_ptr<SfxIte
         if( mbMasterPage )
         {
             
mpDocSh->GetUndoManager()->AddUndoAction(std::make_unique<StyleSheetUndoAction>(
-                mpDoc, *static_cast<SfxStyleSheet*>(&styleSheet), &tempSet));
+                mrDoc, *static_cast<SfxStyleSheet*>(&styleSheet), &tempSet));
             styleSheet.GetItemSet().Put( tempSet );
             sdr::properties::CleanupFillProperties( styleSheet.GetItemSet() );
             styleSheet.Broadcast(SfxHint(SfxHintId::DataChanged));
@@ -464,10 +464,10 @@ void FuPage::ApplyItemSet(SdStyleSheet& styleSheet, const 
std::shared_ptr<SfxIte
         if( const SvxFrameDirectionItem* pItem = tempSet.GetItemIfSet( 
EE_PARA_WRITINGDIR, false ) )
         {
             SvxFrameDirection nVal = pItem->GetValue();
-            mpDoc->SetDefaultWritingMode( nVal == 
SvxFrameDirection::Horizontal_RL_TB ? css::text::WritingMode_RL_TB : 
css::text::WritingMode_LR_TB );
+            mrDoc.SetDefaultWritingMode( nVal == 
SvxFrameDirection::Horizontal_RL_TB ? css::text::WritingMode_RL_TB : 
css::text::WritingMode_LR_TB );
         }
 
-        mpDoc->SetChanged();
+        mrDoc.SetChanged();
 
         // BackgroundFill of Masterpage: no hard attributes allowed
         SdrPage& rUsedMasterPage = mpPage->IsMasterPage() ? *mpPage : 
mpPage->TRG_GetMasterPage();
@@ -501,7 +501,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
 
     if( pArgs->GetItemState(SID_ATTR_PAGE, true, &pPoolItem) == 
SfxItemState::SET )
     {
-        mpDoc->SetPageNumType(static_cast<const 
SvxPageItem*>(pPoolItem)->GetNumType());
+        mrDoc.SetPageNumType(static_cast<const 
SvxPageItem*>(pPoolItem)->GetNumType());
 
         eOrientation = static_cast<const 
SvxPageItem*>(pPoolItem)->IsLandscape() ?
             Orientation::Landscape : Orientation::Portrait;
@@ -520,7 +520,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
             bSetPageSizeAndBorder = true;
     }
 
-    if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
+    if( 
pArgs->GetItemState(mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
                             true, &pPoolItem) == SfxItemState::SET )
     {
         nLeft = static_cast<const SvxLRSpaceItem*>(pPoolItem)->ResolveLeft({});
@@ -531,7 +531,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
 
     }
 
-    if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE),
+    if( 
pArgs->GetItemState(mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE),
                             true, &pPoolItem) == SfxItemState::SET )
     {
         nUpper = static_cast<const SvxULSpaceItem*>(pPoolItem)->GetUpper();
@@ -541,7 +541,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
             bSetPageSizeAndBorder = true;
     }
 
-    if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_EXT1), 
true, &pPoolItem) == SfxItemState::SET )
+    if( 
pArgs->GetItemState(mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_EXT1), 
true, &pPoolItem) == SfxItemState::SET )
     {
         bScaleAll = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
     }
@@ -562,7 +562,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     }
 
     // Paper Bin
-    if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_PAPERBIN),
 true, &pPoolItem) == SfxItemState::SET )
+    if( 
pArgs->GetItemState(mrDoc.GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_PAPERBIN),
 true, &pPoolItem) == SfxItemState::SET )
     {
         nPaperBin = static_cast<const SvxPaperBinItem*>(pPoolItem)->GetValue();
 
@@ -597,7 +597,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
         {
             // Only this page
             mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction(
-                *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) 
);
+                mrDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) );
             SfxItemSet aSet( *pArgs );
             sdr::properties::CleanupFillProperties(aSet);
             mpPage->getSdrPageProperties().ClearItem();
@@ -613,9 +613,9 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     }
 
     // Objects can not be bigger than ViewSize
-    Size aPageSize = mpDoc->GetSdPage(0, ePageKind)->GetSize();
+    Size aPageSize = mrDoc.GetSdPage(0, ePageKind)->GetSize();
     Size aViewSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
-    mpDoc->SetMaxObjSize(aViewSize);
+    mrDoc.SetMaxObjSize(aViewSize);
 
     // if necessary, we tell Preview the new context
     mpDrawViewShell->UpdatePreview( mpDrawViewShell->GetActualPage() );
diff --git a/sd/source/ui/func/fuparagr.cxx b/sd/source/ui/func/fuparagr.cxx
index 1168dac53885..063895ea69a3 100644
--- a/sd/source/ui/func/fuparagr.cxx
+++ b/sd/source/ui/func/fuparagr.cxx
@@ -42,15 +42,15 @@ FuParagraph::FuParagraph (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuParagraph::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuParagraph::Create( ViewShell& rViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuParagraph( rViewSh, pWin, pView, pDoc, 
rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuParagraph( rViewSh, pWin, pView, rDoc, 
rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -64,7 +64,7 @@ void FuParagraph::DoExecute( SfxRequest& rReq )
 
     if( !pArgs )
     {
-        SfxItemSet aEditAttr( mpDoc->GetPool() );
+        SfxItemSet aEditAttr( mrDoc.GetPool() );
         mpView->GetAttributes( aEditAttr );
         SfxItemPool *pPool =  aEditAttr.GetPool();
         SfxItemSet aNewAttr(SfxItemSet::makeFixedSfxItemSet<
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index dca7a05313d1..7029bd9afc67 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -57,13 +57,13 @@ FuPoor::FuPoor (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDrDoc,
+    SdDrawDocument& rDrDoc,
     SfxRequest& rReq)
     : mpView(pView),
       mrViewShell(rViewSh),
       mpWindow(pWin),
-      mpDocSh( pDrDoc->GetDocSh() ),
-      mpDoc(pDrDoc),
+      mpDocSh( rDrDoc.GetDocSh() ),
+      mrDoc(rDrDoc),
       nSlotId( rReq.GetSlot() ),
       aScrollTimer("sd FuPoor aScrollTimer"),
       aDragTimer("sd FuPoor aDragTimer"),
@@ -395,7 +395,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
                 {
                     // jump to last page
                     SdPage* pPage = pDrawViewShell->GetActualPage();
-                    pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
+                    pDrawViewShell->SwitchPage(mrDoc.GetSdPageCount(
                             pPage->GetPageKind()) - 1);
                     bReturn = true;
                 }
@@ -469,7 +469,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
                     SdPage* pPage = 
static_cast<DrawViewShell*>(&mrViewShell)->GetActualPage();
                     sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
 
-                    if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) 
- 1)
+                    if (nSdPage < mrDoc.GetSdPageCount(pPage->GetPageKind()) - 
1)
                     {
                         // Switch the page and send events regarding
                         // deactivation the old page and activating the new
diff --git a/sd/source/ui/func/fuprlout.cxx b/sd/source/ui/func/fuprlout.cxx
index d5bb82c8f279..85bae0504cc5 100644
--- a/sd/source/ui/func/fuprlout.cxx
+++ b/sd/source/ui/func/fuprlout.cxx
@@ -49,15 +49,15 @@ FuPresentationLayout::FuPresentationLayout (
     ViewShell& rViewSh,
     ::sd::Window* pWin,
     ::sd::View* pView,
-    SdDrawDocument* pDoc,
+    SdDrawDocument& rDoc,
     SfxRequest& rReq)
-    : FuPoor(rViewSh, pWin, pView, pDoc, rReq)
+    : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
 {
 }
 
-rtl::Reference<FuPoor> FuPresentationLayout::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+rtl::Reference<FuPoor> FuPresentationLayout::Create( ViewShell& rViewSh, 
::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
 {
-    rtl::Reference<FuPoor> xFunc( new FuPresentationLayout( rViewSh, pWin, 
pView, pDoc, rReq ) );
+    rtl::Reference<FuPoor> xFunc( new FuPresentationLayout( rViewSh, pWin, 
pView, rDoc, rReq ) );
     xFunc->DoExecute(rReq);
     return xFunc;
 }
@@ -101,7 +101,7 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
                 {
                     if (pPage->IsSelected() || pPage->GetPageKind() != 
PageKind::Standard)
                         continue;
-                    mpDoc->SetSelected(pPage, true);
+                    mrDoc.SetSelected(pPage, true);
                     aUnselect.push_back(pPage);
                 }
             }
@@ -111,9 +111,9 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
     std::vector<SdPage*> aSelectedPages;
     std::vector<sal_uInt16> aSelectedPageNums;
     // determine the active pages
-    for (sal_uInt16 nPage = 0; nPage < 
mpDoc->GetSdPageCount(PageKind::Standard); nPage++)
+    for (sal_uInt16 nPage = 0; nPage < 
mrDoc.GetSdPageCount(PageKind::Standard); nPage++)
     {
-        SdPage* pPage = mpDoc->GetSdPage(nPage, PageKind::Standard);
+        SdPage* pPage = mrDoc.GetSdPage(nPage, PageKind::Standard);
         if (pPage->IsSelected())
         {
             aSelectedPages.push_back(pPage);
@@ -128,7 +128,7 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
     bool   bLoad = false;           // appear the new master pages?
     OUString aFile;
 
-    SfxItemSetFixed<ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END> 
aSet(mpDoc->GetPool() );
+    SfxItemSetFixed<ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END> 
aSet(mrDoc.GetPool() );
 
     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad));
     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, bMasterPage ) );
@@ -202,7 +202,7 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
     {
         sal_Int32 nIdx{ 0 };
         OUString aFileName = aFile.getToken(0, DOCUMENT_TOKEN, nIdx);
-        SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName );
+        SdDrawDocument* pTempDoc = mrDoc.OpenBookmarkDoc( aFileName );
 
         // #69581: If I chose the standard-template I got no filename and so I 
get no
         //         SdDrawDocument-Pointer. But the method SetMasterPage is 
able to handle
@@ -211,14 +211,14 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
         if( pTempDoc )
             aLayoutName = aFile.getToken(0, DOCUMENT_TOKEN, nIdx);
         for (auto nSelectedPage : aSelectedPageNums)
-            mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, 
bMasterPage, bCheckMasters);
-        mpDoc->CloseBookmarkDoc();
-e 
... etc. - the rest is truncated

Reply via email to