[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 5 10:40:25 UTC 2020


 sw/inc/dbfld.hxx                                        |    6 
 sw/inc/docufld.hxx                                      |   42 +--
 sw/qa/core/uwriter.cxx                                  |    2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   88 +++----
 sw/source/core/doc/DocumentFieldsManager.cxx            |   26 +-
 sw/source/core/doc/DocumentStylePoolManager.cxx         |  188 ++++++++--------
 sw/source/core/doc/docfld.cxx                           |    2 
 sw/source/core/fields/dbfld.cxx                         |   12 -
 sw/source/core/fields/docufld.cxx                       |   87 +++----
 sw/source/core/fields/macrofld.cxx                      |    8 
 sw/source/core/fields/scrptfld.cxx                      |    6 
 sw/source/core/txtnode/atrfld.cxx                       |    5 
 12 files changed, 235 insertions(+), 237 deletions(-)

New commits:
commit 4ada921dbb6a431b632cfccd06178dad68860ab6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Oct 4 17:52:07 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 5 12:39:45 2020 +0200

    Evaluate family never passed a null SwDoc*
    
    ditto:
    SwTemplNameFieldType ctor
    lcl_RestoreRedlines never passed a null SwDoc*
    lcl_InsAttr
    SwFileNameFieldType ctor
    SwRefPageGetFieldType ctor
    SwJumpEditFieldType ctor
    SwPostItFieldType ctor
    SwScriptFieldType ctor
    SwMacroFieldType ctor
    
    Change-Id: I61fa1b0e5fba16f9d1be1880dde6c487dca88374
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103927
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx
index 1c0d0db2c30f..5d95036246a3 100644
--- a/sw/inc/dbfld.hxx
+++ b/sw/inc/dbfld.hxx
@@ -167,7 +167,7 @@ public:
     virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
     virtual std::unique_ptr<SwField> Copy() const override;
 
-    void                    Evaluate(SwDoc const *);
+    void                    Evaluate(const SwDoc&);
     inline void             SetCondValid(bool bCond);
     inline bool             IsCondValid() const;
 
@@ -209,7 +209,7 @@ public:
 
     inline bool             IsCondValid() const;
     inline void             SetCondValid(bool bCond);
-    void                    Evaluate(SwDoc const *);
+    void                    Evaluate(const SwDoc&);
 
     // Condition
     virtual OUString        GetPar1() const override;
@@ -271,7 +271,7 @@ public:
 
     virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
     virtual std::unique_ptr<SwField> Copy() const override;
-    void            Evaluate(SwDoc const *);
+    void            Evaluate(const SwDoc&);
 
     inline long     GetSetNumber() const;
     inline void     SetSetNumber(long nNum);
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index bc7ef9219093..62363f01bbd1 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -198,9 +198,9 @@ public:
 
 class SAL_DLLPUBLIC_RTTI SwFileNameFieldType final : public SwFieldType
 {
-    SwDoc *m_pDoc;
+    SwDoc& m_rDoc;
 public:
-    SwFileNameFieldType(SwDoc*);
+    SwFileNameFieldType(SwDoc&);
 
     OUString                Expand(sal_uLong) const;
     virtual std::unique_ptr<SwFieldType> Copy() const override;
@@ -224,9 +224,9 @@ public:
 
 class SAL_DLLPUBLIC_RTTI SwTemplNameFieldType final : public SwFieldType
 {
-    SwDoc *m_pDoc;
+    SwDoc& m_rDoc;
 public:
-    SwTemplNameFieldType(SwDoc*);
+    SwTemplNameFieldType(SwDoc&);
 
     OUString                Expand(sal_uLong) const;
     virtual std::unique_ptr<SwFieldType> Copy() const override;
@@ -246,11 +246,11 @@ public:
 // Document statistics
 class SAL_DLLPUBLIC_RTTI SwDocStatFieldType final : public SwFieldType
 {
-    SwDoc*          m_pDoc;
+    SwDoc&          m_rDoc;
     SvxNumType      m_nNumberingType;
 
 public:
-    SwDocStatFieldType(SwDoc*);
+    SwDocStatFieldType(SwDoc&);
     OUString                Expand(sal_uInt16 nSubType, SvxNumType nFormat) const;
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 
@@ -320,11 +320,11 @@ public:
 
     virtual OUString    GetFieldName() const override;
 
-    void                Evaluate(SwDoc*);
+    void                Evaluate(SwDoc& rDoc);
 
     void         SetValue(bool bHidden)  { m_bIsHidden = bHidden; }
     static OUString     GetColumnName(const OUString& rName);
-    static OUString     GetDBName(const OUString& rName, SwDoc *pDoc);
+    static OUString     GetDBName(const OUString& rName, SwDoc& rDoc);
 
     /// Condition
     virtual void        SetPar1(const OUString& rStr) override;
@@ -377,10 +377,10 @@ public:
 
 class SAL_DLLPUBLIC_RTTI SwMacroFieldType final : public SwFieldType
 {
-    SwDoc* m_pDoc;
+    SwDoc& m_rDoc;
 
 public:
-    SwMacroFieldType(SwDoc*);
+    SwMacroFieldType(SwDoc&);
 
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 };
@@ -426,15 +426,15 @@ public:
 class SAL_DLLPUBLIC_RTTI SwPostItFieldType final : public SwFieldType
 {
 private:
-    SwDoc* mpDoc;
+    SwDoc& mrDoc;
 public:
-    SwPostItFieldType(SwDoc* pDoc);
+    SwPostItFieldType(SwDoc& rDoc);
 
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 
-    SwDoc* GetDoc() const
+    SwDoc& GetDoc() const
     {
-        return mpDoc;
+        return mrDoc;
     };
 };
 
@@ -604,7 +604,7 @@ public:
 // Relative page numbers - query field.
 class SwRefPageGetFieldType final : public SwFieldType
 {
-    SwDoc*          m_pDoc;
+    SwDoc&          m_rDoc;
     sal_Int16       m_nNumberingType;
 
     void UpdateField(SwTextField const * pTextField,
@@ -613,10 +613,10 @@ class SwRefPageGetFieldType final : public SwFieldType
     /// overwritten to update all RefPageGet fields
     virtual void Modify( const SfxPoolItem*, const SfxPoolItem * ) override;
 public:
-    SwRefPageGetFieldType( SwDoc* pDoc );
+    SwRefPageGetFieldType( SwDoc& rDoc );
     virtual std::unique_ptr<SwFieldType> Copy() const override;
     bool MakeSetList(SetGetExpFields& rTmpLst, SwRootFrame const* pLayout);
-    SwDoc*  GetDoc() const                  { return m_pDoc; }
+    SwDoc&  GetDoc() const                  { return m_rDoc; }
 };
 
 // Query relative page numbering.
@@ -641,11 +641,11 @@ public:
 // Field to jump to and edit.
 class SwJumpEditFieldType final : public SwFieldType
 {
-    SwDoc* m_pDoc;
+    SwDoc& m_rDoc;
     sw::WriterMultiListener m_aDep;
 
 public:
-    SwJumpEditFieldType( SwDoc* pDoc );
+    SwJumpEditFieldType( SwDoc& rDoc );
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 
     SwCharFormat* GetCharFormat();
@@ -678,9 +678,9 @@ public:
 
 class SwScriptFieldType final : public SwFieldType
 {
-    SwDoc* m_pDoc;
+    SwDoc& m_rDoc;
 public:
-    SwScriptFieldType( SwDoc* pDoc );
+    SwScriptFieldType( SwDoc& rDoc );
 
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 };
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 0d49a0744f33..4975d4dde2c5 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -220,7 +220,7 @@ void SwDocTest::testFileNameFields()
 
     const INetURLObject &rUrlObj = m_xDocShRef->GetMedium()->GetURLObject();
 
-    SwFileNameFieldType aNameField(m_pDoc);
+    SwFileNameFieldType aNameField(*m_pDoc);
 
     {
         OUString sResult(aNameField.Expand(FF_NAME));
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index fe748212d497..ea9fd3f0c07d 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -834,18 +834,18 @@ namespace
         rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
     }
 
-    void lcl_RestoreRedlines(SwDoc* pDoc, const SwPosition& rPos, SaveRedlines_t& rArr)
+    void lcl_RestoreRedlines(SwDoc& rDoc, const SwPosition& rPos, SaveRedlines_t& rArr)
     {
-        RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
-        pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( ( eOld & ~RedlineFlags::Ignore) | RedlineFlags::On );
+        RedlineFlags eOld = rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
+        rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( ( eOld & ~RedlineFlags::Ignore) | RedlineFlags::On );
 
         for(SaveRedline & rSvRedLine : rArr)
         {
             rSvRedLine.SetPos( rPos );
-            pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
+            rDoc.getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
         }
 
-        pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
+        rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
     }
 
     void lcl_SaveRedlines(const SwNodeRange& rRg, SaveRedlines_t& rArr)
@@ -931,22 +931,22 @@ namespace
         rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
     }
 
-    void lcl_RestoreRedlines(SwDoc *const pDoc, sal_uInt32 const nInsPos, SaveRedlines_t& rArr)
+    void lcl_RestoreRedlines(SwDoc& rDoc, sal_uInt32 const nInsPos, SaveRedlines_t& rArr)
     {
-        RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
-        pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( ( eOld & ~RedlineFlags::Ignore) | RedlineFlags::On );
+        RedlineFlags eOld = rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
+        rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( ( eOld & ~RedlineFlags::Ignore) | RedlineFlags::On );
 
         for(SaveRedline & rSvRedLine : rArr)
         {
             rSvRedLine.SetPos( nInsPos );
-            pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
+            rDoc.getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
             if (rSvRedLine.pRedl->GetType() == RedlineType::Delete)
             {
-                UpdateFramesForAddDeleteRedline(*pDoc, *rSvRedLine.pRedl);
+                UpdateFramesForAddDeleteRedline(rDoc, *rSvRedLine.pRedl);
             }
         }
 
-        pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
+        rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
     }
 
     bool lcl_SaveFootnote( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd,
@@ -1215,7 +1215,7 @@ namespace //local functions originally from docfmt.cxx
     // Is used in SwDoc::Insert(..., SwFormatHint &rHt)
 
     bool lcl_InsAttr(
-        SwDoc *const pDoc,
+        SwDoc& rDoc,
         const SwPaM &rRg,
         const SfxItemSet& rChgSet,
         const SetAttrMode nFlags,
@@ -1269,7 +1269,7 @@ namespace //local functions originally from docfmt.cxx
         if ( !bCharAttr && !bOtherAttr )
         {
             SfxItemSet* pTmpCharItemSet = new SfxItemSet(
-                pDoc->GetAttrPool(),
+                rDoc.GetAttrPool(),
                 svl::Items<
                     RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
                     RES_TXTATR_AUTOFMT, RES_TXTATR_CHARFMT,
@@ -1277,7 +1277,7 @@ namespace //local functions originally from docfmt.cxx
                         RES_TXTATR_UNKNOWN_CONTAINER>{});
 
             SfxItemSet* pTmpOtherItemSet = new SfxItemSet(
-                pDoc->GetAttrPool(),
+                rDoc.GetAttrPool(),
                 svl::Items<
                     RES_PARATR_BEGIN, RES_GRFATR_END - 1,
                     RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1,
@@ -1351,7 +1351,7 @@ namespace //local functions originally from docfmt.cxx
 
                 SwNumFormat aNumFormat = pNumRule->Get(static_cast<sal_uInt16>(nLevel));
                 SwCharFormat * pCharFormat =
-                    pDoc->FindCharFormatByName(aNumFormat.GetCharFormatName());
+                    rDoc.FindCharFormatByName(aNumFormat.GetCharFormatName());
 
                 if (pCharFormat)
                 {
@@ -1371,7 +1371,7 @@ namespace //local functions originally from docfmt.cxx
             // Attributes without an end do not have a range
             if ( !bCharAttr && !bOtherAttr )
             {
-                SfxItemSet aTextSet( pDoc->GetAttrPool(),
+                SfxItemSet aTextSet( rDoc.GetAttrPool(),
                             svl::Items<RES_TXTATR_NOEND_BEGIN, RES_TXTATR_NOEND_END-1>{} );
                 aTextSet.Put( rChgSet );
                 if( aTextSet.Count() )
@@ -1380,8 +1380,8 @@ namespace //local functions originally from docfmt.cxx
                     bRet = history.InsertItems(
                         aTextSet, rSt.GetIndex(), rSt.GetIndex(), nFlags, /*ppNewTextAttr*/nullptr ) || bRet;
 
-                    if (bRet && (pDoc->getIDocumentRedlineAccess().IsRedlineOn() || (!pDoc->getIDocumentRedlineAccess().IsIgnoreRedline()
-                                    && !pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty())))
+                    if (bRet && (rDoc.getIDocumentRedlineAccess().IsRedlineOn() || (!rDoc.getIDocumentRedlineAccess().IsIgnoreRedline()
+                                    && !rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())))
                     {
                         SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
                                     pStt->nNode, pStt->nContent.GetIndex() );
@@ -1389,10 +1389,10 @@ namespace //local functions originally from docfmt.cxx
                         if( pUndo )
                             pUndo->SaveRedlineData( aPam, true );
 
-                        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
-                            pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Insert, aPam ), true);
+                        if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
+                            rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Insert, aPam ), true);
                         else
-                            pDoc->getIDocumentRedlineAccess().SplitRedline( aPam );
+                            rDoc.getIDocumentRedlineAccess().SplitRedline( aPam );
                     }
                 }
             }
@@ -1403,7 +1403,7 @@ namespace //local functions originally from docfmt.cxx
                 // CharFormat and URL attributes are treated separately!
                 // TEST_TEMP ToDo: AutoFormat!
                 SfxItemSet aTextSet(
-                    pDoc->GetAttrPool(),
+                    rDoc.GetAttrPool(),
                     svl::Items<
                         RES_TXTATR_REFMARK, RES_TXTATR_METAFIELD,
                         RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
@@ -1420,8 +1420,8 @@ namespace //local functions originally from docfmt.cxx
                     bRet = history.InsertItems( aTextSet, nInsCnt, nEnd, nFlags, ppNewTextAttr )
                            || bRet;
 
-                    if (bRet && (pDoc->getIDocumentRedlineAccess().IsRedlineOn() || (!pDoc->getIDocumentRedlineAccess().IsIgnoreRedline()
-                                    && !pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty())))
+                    if (bRet && (rDoc.getIDocumentRedlineAccess().IsRedlineOn() || (!rDoc.getIDocumentRedlineAccess().IsIgnoreRedline()
+                                    && !rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())))
                     {
                         // Was text content inserted? (RefMark/TOXMarks without an end)
                         bool bTextIns = nInsCnt != rSt.GetIndex();
@@ -1431,13 +1431,13 @@ namespace //local functions originally from docfmt.cxx
                         if( pUndo )
                             pUndo->SaveRedlineData( aPam, bTextIns );
 
-                        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
-                            pDoc->getIDocumentRedlineAccess().AppendRedline(
+                        if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
+                            rDoc.getIDocumentRedlineAccess().AppendRedline(
                                 new SwRangeRedline(
                                     bTextIns ? RedlineType::Insert : RedlineType::Format, aPam ),
                                     true);
                         else if( bTextIns )
-                            pDoc->getIDocumentRedlineAccess().SplitRedline( aPam );
+                            rDoc.getIDocumentRedlineAccess().SplitRedline( aPam );
                     }
                 }
             }
@@ -1533,20 +1533,20 @@ namespace //local functions originally from docfmt.cxx
                 sal_uInt16 nPoolId=0;
                 if( SfxItemState::SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE,
                                     false, reinterpret_cast<const SfxPoolItem**>(&pRule) ) &&
-                    !pDoc->FindNumRulePtr( pRule->GetValue() ) &&
+                    !rDoc.FindNumRulePtr( pRule->GetValue() ) &&
                     USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(),
                                     SwGetPoolIdFromName::NumRule )) )
-                    pDoc->getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId );
+                    rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId );
             }
         }
 
-        SfxItemSet firstSet(pDoc->GetAttrPool(),
+        SfxItemSet firstSet(rDoc.GetAttrPool(),
                 svl::Items<RES_PAGEDESC, RES_BREAK>{});
         if (pOtherSet && pOtherSet->Count())
         {   // actually only RES_BREAK is possible here...
             firstSet.Put(*pOtherSet);
         }
-        SfxItemSet propsSet(pDoc->GetAttrPool(),
+        SfxItemSet propsSet(rDoc.GetAttrPool(),
             svl::Items<RES_PARATR_BEGIN, RES_PAGEDESC,
                        RES_BREAK+1, RES_FRMATR_END,
                        XATTR_FILL_FIRST, XATTR_FILL_LAST+1>{});
@@ -1622,13 +1622,13 @@ namespace //local functions originally from docfmt.cxx
                 bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags, /*ppNewTextAttr*/nullptr )
                     || bRet;
 
-                if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
+                if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
                 {
                     SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
 
                     if( pUndo )
                         pUndo->SaveRedlineData( aPam, false );
-                    pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Format, aPam ), true);
+                    rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Format, aPam ), true);
                 }
             }
             if( pOtherSet && pOtherSet->Count() )
@@ -1638,7 +1638,7 @@ namespace //local functions originally from docfmt.cxx
                 // modify/correct entries inside of the given SfxItemSet
                 SfxItemSet aTempLocalCopy(*pOtherSet);
 
-                pDoc->CheckForUniqueItemForLineFillNameOrIndex(aTempLocalCopy);
+                rDoc.CheckForUniqueItemForLineFillNameOrIndex(aTempLocalCopy);
                 bRet = lcl_ApplyOtherSet(*pNode, pHistory, aTempLocalCopy, firstSet, propsSet, pLayout) || bRet;
             }
 
@@ -1646,18 +1646,18 @@ namespace //local functions originally from docfmt.cxx
             return bRet;
         }
 
-        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() && pCharSet && pCharSet->Count() )
+        if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() && pCharSet && pCharSet->Count() )
         {
             if( pUndo )
                 pUndo->SaveRedlineData( rRg, false );
-            pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Format, rRg ), true);
+            rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Format, rRg ), true);
         }
 
         /* now if range */
         sal_uLong nNodes = 0;
 
-        SwNodeIndex aSt( pDoc->GetNodes() );
-        SwNodeIndex aEnd( pDoc->GetNodes() );
+        SwNodeIndex aSt( rDoc.GetNodes() );
+        SwNodeIndex aEnd( rDoc.GetNodes() );
         SwIndex aCntEnd( pEnd->nContent );
 
         if( pNode )
@@ -1761,7 +1761,7 @@ namespace //local functions originally from docfmt.cxx
         {
             ::sw::DocumentContentOperationsManager::ParaRstFormat aPara(
                     pStt, pEnd, pHistory, pCharSet, pLayout);
-            pDoc->GetNodes().ForEach( aSt, aEnd, ::sw::DocumentContentOperationsManager::lcl_RstTextAttr, &aPara );
+            rDoc.GetNodes().ForEach( aSt, aEnd, ::sw::DocumentContentOperationsManager::lcl_RstTextAttr, &aPara );
         }
 
         bool bCreateSwpHints = pCharSet && (
@@ -1836,7 +1836,7 @@ namespace //local functions originally from docfmt.cxx
             sal_uLong nEnd = aEndPos.nNode.GetIndex();
             for(; nStart <= nEnd; ++nStart)
             {
-                SwNode* pNd = pDoc->GetNodes()[ nStart ];
+                SwNode* pNd = rDoc.GetNodes()[ nStart ];
                 if (!pNd || !pNd->IsTextNode())
                     continue;
                 SwTextNode *pCurrentNd = pNd->GetTextNode();
@@ -2413,7 +2413,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
     // restore redlines (if DOC_MOVEREDLINES is used)
     if( !aSaveRedl.empty() )
     {
-        lcl_RestoreRedlines( &m_rDoc, *aSavePam.Start(), aSaveRedl );
+        lcl_RestoreRedlines( m_rDoc, *aSavePam.Start(), aSaveRedl );
     }
 
     if( bUpdateFootnote )
@@ -2559,7 +2559,7 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
     }
 
     if( !aSaveRedl.empty() )
-        lcl_RestoreRedlines( &m_rDoc, aIdx.GetIndex(), aSaveRedl );
+        lcl_RestoreRedlines( m_rDoc, aIdx.GetIndex(), aSaveRedl );
 
     if( pUndo )
     {
@@ -3393,7 +3393,7 @@ bool DocumentContentOperationsManager::InsertPoolItem(
 
     SfxItemSet aSet( m_rDoc.GetAttrPool(), {{rHt.Which(), rHt.Which()}} );
     aSet.Put( rHt );
-    const bool bRet = lcl_InsAttr(&m_rDoc, rRg, aSet, nFlags, pUndoAttr.get(), pLayout, bExpandCharToPara, ppNewTextAttr);
+    const bool bRet = lcl_InsAttr(m_rDoc, rRg, aSet, nFlags, pUndoAttr.get(), pLayout, bExpandCharToPara, ppNewTextAttr);
 
     if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
     {
@@ -3418,7 +3418,7 @@ void DocumentContentOperationsManager::InsertItemSet ( const SwPaM &rRg, const S
         pUndoAttr.reset(new SwUndoAttr( rRg, rSet, nFlags ));
     }
 
-    bool bRet = lcl_InsAttr(&m_rDoc, rRg, rSet, nFlags, pUndoAttr.get(), pLayout, /*bExpandCharToPara*/false, /*ppNewTextAttr*/nullptr );
+    bool bRet = lcl_InsAttr(m_rDoc, rRg, rSet, nFlags, pUndoAttr.get(), pLayout, /*bExpandCharToPara*/false, /*ppNewTextAttr*/nullptr );
 
     if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
     {
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index db76efdfcd45..72ed8ae8ef4a 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1068,7 +1068,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
             {
                 pHField->SetValue( bValue );
                 // evaluate field
-                pHField->Evaluate(&m_rDoc);
+                pHField->Evaluate(m_rDoc);
             }
         }
         break;
@@ -1084,7 +1084,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
         case SwFieldIds::DbSetNumber:
 #if HAVE_FEATURE_DBCONNECTIVITY
         {
-            const_cast<SwDBSetNumberField*>(static_cast<const SwDBSetNumberField*>(pField))->Evaluate(&m_rDoc);
+            const_cast<SwDBSetNumberField*>(static_cast<const SwDBSetNumberField*>(pField))->Evaluate(m_rDoc);
             aCalc.VarChange( sDBNumNm, static_cast<const SwDBSetNumberField*>(pField)->GetSetNumber());
             pField->ExpandField(m_rDoc.IsClipBoard(), nullptr);
         }
@@ -1764,28 +1764,28 @@ void DocumentFieldsManager::InitFieldTypes()       // is being called by the CTO
     mpFieldTypes->emplace_back( new SwChapterFieldType );
     mpFieldTypes->emplace_back( new SwPageNumberFieldType );
     mpFieldTypes->emplace_back( new SwAuthorFieldType );
-    mpFieldTypes->emplace_back( new SwFileNameFieldType(&m_rDoc) );
+    mpFieldTypes->emplace_back( new SwFileNameFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwDBNameFieldType(&m_rDoc) );
     mpFieldTypes->emplace_back( new SwGetExpFieldType(&m_rDoc) );
     mpFieldTypes->emplace_back( new SwGetRefFieldType( &m_rDoc ) );
     mpFieldTypes->emplace_back( new SwHiddenTextFieldType );
-    mpFieldTypes->emplace_back( new SwPostItFieldType(&m_rDoc) );
-    mpFieldTypes->emplace_back( new SwDocStatFieldType(&m_rDoc) );
+    mpFieldTypes->emplace_back( new SwPostItFieldType(m_rDoc) );
+    mpFieldTypes->emplace_back( new SwDocStatFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwDocInfoFieldType(&m_rDoc) );
     mpFieldTypes->emplace_back( new SwInputFieldType( &m_rDoc ) );
     mpFieldTypes->emplace_back( new SwTableFieldType( &m_rDoc ) );
-    mpFieldTypes->emplace_back( new SwMacroFieldType(&m_rDoc) );
+    mpFieldTypes->emplace_back( new SwMacroFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwHiddenParaFieldType );
     mpFieldTypes->emplace_back( new SwDBNextSetFieldType );
     mpFieldTypes->emplace_back( new SwDBNumSetFieldType );
     mpFieldTypes->emplace_back( new SwDBSetNumberFieldType );
-    mpFieldTypes->emplace_back( new SwTemplNameFieldType(&m_rDoc) );
-    mpFieldTypes->emplace_back( new SwTemplNameFieldType(&m_rDoc) );
+    mpFieldTypes->emplace_back( new SwTemplNameFieldType(m_rDoc) );
+    mpFieldTypes->emplace_back( new SwTemplNameFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwExtUserFieldType );
     mpFieldTypes->emplace_back( new SwRefPageSetFieldType );
-    mpFieldTypes->emplace_back( new SwRefPageGetFieldType( &m_rDoc ) );
-    mpFieldTypes->emplace_back( new SwJumpEditFieldType( &m_rDoc ) );
-    mpFieldTypes->emplace_back( new SwScriptFieldType( &m_rDoc ) );
+    mpFieldTypes->emplace_back( new SwRefPageGetFieldType(m_rDoc) );
+    mpFieldTypes->emplace_back( new SwJumpEditFieldType(m_rDoc) );
+    mpFieldTypes->emplace_back( new SwScriptFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwCombinedCharFieldType );
     mpFieldTypes->emplace_back( new SwDropDownFieldType );
 
@@ -1833,9 +1833,9 @@ void DocumentFieldsManager::UpdateDBNumFields( SwDBNameInfField& rDBField, SwCal
     {
         // Edit a certain database
         if( SwFieldIds::DbNextSet == nFieldType )
-            static_cast<SwDBNextSetField&>(rDBField).Evaluate(&m_rDoc);
+            static_cast<SwDBNextSetField&>(rDBField).Evaluate(m_rDoc);
         else
-            static_cast<SwDBNumSetField&>(rDBField).Evaluate(&m_rDoc);
+            static_cast<SwDBNumSetField&>(rDBField).Evaluate(m_rDoc);
 
         SwDBData aTmpDBData( rDBField.GetDBData(&m_rDoc) );
 
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index f93e02151758..0244670d288e 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -170,13 +170,13 @@ namespace
         }
     }
 
-    void lcl_SetHeadline( SwDoc* pDoc, SwTextFormatColl* pColl,
+    void lcl_SetHeadline( SwDoc& rDoc, SwTextFormatColl* pColl,
                             SfxItemSet& rSet,
                             sal_uInt16 nOutLvlBits, sal_uInt8 nLevel, bool bItalic )
     {
         SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
         SvxFontHeightItem aHItem(240, 100, RES_CHRATR_FONTSIZE);
-        const bool bHTMLMode = pDoc->GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE);
+        const bool bHTMLMode = rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE);
         if( bHTMLMode )
             aHItem.SetHeight( aHeadlineSizes[ MAXLEVEL + nLevel ] );
         else
@@ -200,7 +200,7 @@ namespace
             pColl->AssignToListLevelOfOutlineStyle(nLevel);
             if( !bHTMLMode )
             {
-                SwNumRule * pOutlineRule = pDoc->GetOutlineNumRule();
+                SwNumRule * pOutlineRule = rDoc.GetOutlineNumRule();
                 const SwNumFormat& rNFormat = pOutlineRule->Get( nLevel );
 
                 if ( rNFormat.GetPositionAndSpaceMode() ==
@@ -220,10 +220,10 @@ namespace
                 pColl->SetFormatAttr(aItem);
             }
         }
-        pColl->SetNextTextFormatColl( *pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT ));
+        pColl->SetNextTextFormatColl( *rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT ));
     }
 
-    void lcl_SetRegister( SwDoc* pDoc, SfxItemSet& rSet, sal_uInt16 nFact,
+    void lcl_SetRegister( SwDoc& rDoc, SfxItemSet& rSet, sal_uInt16 nFact,
                             bool bHeader, bool bTab )
     {
         SvxLRSpaceItem aLR( RES_LR_SPACE );
@@ -238,7 +238,7 @@ namespace
         }
         if( bTab )
         {
-            long nRightMargin = lcl_GetRightMargin( *pDoc );
+            long nRightMargin = lcl_GetRightMargin( rDoc );
             SvxTabStopItem aTStops( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
             aTStops.Insert( SvxTabStop( nRightMargin - nLeft,
                                         SvxTabAdjust::Right,
@@ -247,7 +247,7 @@ namespace
         }
     }
 
-    void lcl_SetNumBul( SwDoc* pDoc, SwTextFormatColl* pColl,
+    void lcl_SetNumBul( SwDoc& rDoc, SwTextFormatColl* pColl,
                             SfxItemSet& rSet,
                             sal_uInt16 nNxt, SwTwips nEZ, SwTwips nLeft,
                             SwTwips nUpper, SwTwips nLower )
@@ -263,12 +263,12 @@ namespace
         rSet.Put( aUL );
 
         if( pColl )
-            pColl->SetNextTextFormatColl( *pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nNxt ));
+            pColl->SetNextTextFormatColl( *rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nNxt ));
     }
 
-    void lcl_PutStdPageSizeIntoItemSet( SwDoc* pDoc, SfxItemSet& rSet )
+    void lcl_PutStdPageSizeIntoItemSet( SwDoc& rDoc, SfxItemSet& rSet )
     {
-        SwPageDesc* pStdPgDsc = pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
+        SwPageDesc* pStdPgDsc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
         SwFormatFrameSize aFrameSz( pStdPgDsc->GetMaster().GetFrameSize() );
         if( pStdPgDsc->GetLandscape() )
         {
@@ -826,70 +826,70 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
             {
                 SvxULSpaceItem aUL( PT_12, PT_6, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 0, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 0, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE2:        // Heading 2
             {
                 SvxULSpaceItem aUL( PT_10, PT_6, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 1, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 1, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE3:        // Heading 3
             {
                 SvxULSpaceItem aUL( PT_7, PT_6, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 2, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 2, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE4:        // Heading 4
             {
                 SvxULSpaceItem aUL( PT_6, PT_6, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 3, true );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 3, true );
             }
             break;
         case RES_POOLCOLL_HEADLINE5:        // Heading 5
             {
                 SvxULSpaceItem aUL( PT_6, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 4, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 4, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE6:        // Heading 6
             {
                 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 5, true );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 5, true );
             }
             break;
         case RES_POOLCOLL_HEADLINE7:        // Heading 7
             {
                 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 6, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 6, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE8:        // Heading 8
             {
                 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 7, true );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 7, true );
             }
             break;
         case RES_POOLCOLL_HEADLINE9:        // Heading 9
             {
                 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 8, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 8, false );
             }
             break;
         case RES_POOLCOLL_HEADLINE10:       // Heading 10
             {
                 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
                 aSet.Put( aUL );
-                lcl_SetHeadline( &m_rDoc, pNewColl, aSet, nOutLvlBits, 9, false );
+                lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 9, false );
             }
             break;
 
@@ -997,7 +997,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
 
         // User defined indexes:
         case RES_POOLCOLL_TOX_USERH:            // Header
-            lcl_SetRegister( &m_rDoc, aSet, 0, true, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, true, false );
             {
                 SwFormatLineNumber aLN;
                 aLN.SetCountLines( false );
@@ -1005,39 +1005,39 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
             }
             break;
         case RES_POOLCOLL_TOX_USER1:            // 1st level
-            lcl_SetRegister( &m_rDoc, aSet, 0, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 0, false, true );
             break;
         case RES_POOLCOLL_TOX_USER2:            // 2nd level
-            lcl_SetRegister( &m_rDoc, aSet, 1, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 1, false, true );
             break;
         case RES_POOLCOLL_TOX_USER3:            // 3rd level
-            lcl_SetRegister( &m_rDoc, aSet, 2, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 2, false, true );
             break;
         case RES_POOLCOLL_TOX_USER4:            // 4th level
-            lcl_SetRegister( &m_rDoc, aSet, 3, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 3, false, true );
             break;
         case RES_POOLCOLL_TOX_USER5:            // 5th level
-            lcl_SetRegister( &m_rDoc, aSet, 4, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 4, false, true );
             break;
         case RES_POOLCOLL_TOX_USER6:            // 6th level
-            lcl_SetRegister( &m_rDoc, aSet, 5, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 5, false, true );
             break;
         case RES_POOLCOLL_TOX_USER7:            // 7th level
-            lcl_SetRegister( &m_rDoc, aSet, 6, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 6, false, true );
             break;
         case RES_POOLCOLL_TOX_USER8:            // 8th level
-            lcl_SetRegister( &m_rDoc, aSet, 7, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 7, false, true );
             break;
         case RES_POOLCOLL_TOX_USER9:            // 9th level
-            lcl_SetRegister( &m_rDoc, aSet, 8, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 8, false, true );
             break;
         case RES_POOLCOLL_TOX_USER10:           // 10th level
-            lcl_SetRegister( &m_rDoc, aSet, 9, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 9, false, true );
             break;
 
         // Index
         case RES_POOLCOLL_TOX_IDXH:         // Header
-            lcl_SetRegister( &m_rDoc, aSet, 0, true, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, true, false );
             {
                 SwFormatLineNumber aLN;
                 aLN.SetCountLines( false );
@@ -1045,21 +1045,21 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
             }
             break;
         case RES_POOLCOLL_TOX_IDX1:         // 1st level
-            lcl_SetRegister( &m_rDoc, aSet, 0, false, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, false, false );
             break;
         case RES_POOLCOLL_TOX_IDX2:         // 2nd level
-            lcl_SetRegister( &m_rDoc, aSet, 1, false, false );
+            lcl_SetRegister( m_rDoc, aSet, 1, false, false );
             break;
         case RES_POOLCOLL_TOX_IDX3:         // 3rd level
-            lcl_SetRegister( &m_rDoc, aSet, 2, false, false );
+            lcl_SetRegister( m_rDoc, aSet, 2, false, false );
             break;
         case RES_POOLCOLL_TOX_IDXBREAK:     // Separator
-            lcl_SetRegister( &m_rDoc, aSet, 0, false, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, false, false );
             break;
 
         // Table of Content
         case RES_POOLCOLL_TOX_CNTNTH:       // Header
-            lcl_SetRegister( &m_rDoc, aSet, 0, true, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, true, false );
             {
                 SwFormatLineNumber aLN;
                 aLN.SetCountLines( false );
@@ -1067,41 +1067,41 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
             }
             break;
         case RES_POOLCOLL_TOX_CNTNT1:       // 1st level
-            lcl_SetRegister( &m_rDoc, aSet, 0, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 0, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT2:       // 2nd level
-            lcl_SetRegister( &m_rDoc, aSet, 1, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 1, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT3:       // 3rd level
-            lcl_SetRegister( &m_rDoc, aSet, 2, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 2, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT4:       // 4th level
-            lcl_SetRegister( &m_rDoc, aSet, 3, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 3, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT5:       // 5th level
-            lcl_SetRegister( &m_rDoc, aSet, 4, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 4, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT6:       // 6th level
-            lcl_SetRegister( &m_rDoc, aSet, 5, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 5, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT7:       // 7th level
-            lcl_SetRegister( &m_rDoc, aSet, 6, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 6, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT8:       // 8th level
-            lcl_SetRegister( &m_rDoc, aSet, 7, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 7, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT9:       // 9th level
-            lcl_SetRegister( &m_rDoc, aSet, 8, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 8, false, true );
             break;
         case RES_POOLCOLL_TOX_CNTNT10:      // 10th level
-            lcl_SetRegister( &m_rDoc, aSet, 9, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 9, false, true );
             break;
 
         case RES_POOLCOLL_TOX_ILLUSH:
         case RES_POOLCOLL_TOX_OBJECTH:
         case RES_POOLCOLL_TOX_TABLESH:
         case RES_POOLCOLL_TOX_AUTHORITIESH:
-            lcl_SetRegister( &m_rDoc, aSet, 0, true, false );
+            lcl_SetRegister( m_rDoc, aSet, 0, true, false );
             {
                 SwFormatLineNumber aLN;
                 aLN.SetCountLines( false );
@@ -1112,198 +1112,198 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
         case RES_POOLCOLL_TOX_OBJECT1:
         case RES_POOLCOLL_TOX_TABLES1:
         case RES_POOLCOLL_TOX_AUTHORITIES1:
-            lcl_SetRegister( &m_rDoc, aSet, 0, false, true );
+            lcl_SetRegister( m_rDoc, aSet, 0, false, true );
         break;
 
         case RES_POOLCOLL_NUM_LEVEL1S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL1:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL1E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_NUM_NONUM1:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM1,
                             0, SwNumRule::GetNumIndent( 0 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL2S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL2:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL2E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_NUM_NONUM2:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM2,
                             0, SwNumRule::GetNumIndent( 1 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL3S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL3:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL3E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_NUM_NONUM3:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM3,
                             0, SwNumRule::GetNumIndent( 2 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL4S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL4:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL4E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_NUM_NONUM4:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM4,
                             0, SwNumRule::GetNumIndent( 3 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL5S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL5:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_NUM_LEVEL5E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
                             lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_NUM_NONUM5:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM5,
                             0, SwNumRule::GetNumIndent( 4 ), 0, PT_6 );
             break;
 
         case RES_POOLCOLL_BULLET_LEVEL1S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL1:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL1E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_BULLET_NONUM1:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM1,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM1,
                             0, SwNumRule::GetBullIndent( 0 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL2S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL2:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL2E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_BULLET_NONUM2:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM2,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM2,
                             0, SwNumRule::GetBullIndent( 1 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL3S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL3:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL3E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_BULLET_NONUM3:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM3,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM3,
                             0, SwNumRule::GetBullIndent( 2 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL4S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL4:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL4E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_BULLET_NONUM4:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM4,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM4,
                             0, SwNumRule::GetBullIndent( 3 ), 0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL5S:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
                             PT_12, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL5:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
                             0, PT_6 );
             break;
         case RES_POOLCOLL_BULLET_LEVEL5E:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
                             lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
                             0, PT_12 );
             break;
         case RES_POOLCOLL_BULLET_NONUM5:
-            lcl_SetNumBul( &m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM5,
+            lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM5,
                             0, SwNumRule::GetBullIndent( 4 ), 0, PT_6 );
             break;
 
@@ -1772,7 +1772,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
     case RES_POOLPAGE_FIRST:        // "First Page"
     case RES_POOLPAGE_REGISTER:     // "Index"
         {
-            lcl_PutStdPageSizeIntoItemSet( &m_rDoc, aSet );
+            lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
             aSet.Put( aLR );
             aSet.Put( aUL );
             pNewPgDsc->SetUseOn( UseOnPage::All );
@@ -1783,7 +1783,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
 
     case RES_POOLPAGE_LEFT:         // "Left Page"
         {
-            lcl_PutStdPageSizeIntoItemSet( &m_rDoc, aSet );
+            lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
             aSet.Put( aLR );
             aSet.Put( aUL );
             bSetLeft = false;
@@ -1795,7 +1795,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
         break;
     case RES_POOLPAGE_RIGHT:        // "Right Page"
         {
-            lcl_PutStdPageSizeIntoItemSet( &m_rDoc, aSet );
+            lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
             aSet.Put( aLR );
             aSet.Put( aUL );
             bSetLeft = false;
@@ -1821,7 +1821,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
 
     case RES_POOLPAGE_HTML:         // "HTML"
         {
-            lcl_PutStdPageSizeIntoItemSet( &m_rDoc, aSet );
+            lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
             aLR.SetRight( GetMetricVal( CM_1 ));
             aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetRight()) );
             aUL.SetLower( static_cast<sal_uInt16>(aLR.GetRight()) );
@@ -1835,7 +1835,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
     case RES_POOLPAGE_FOOTNOTE:     // "Footnote"
     case RES_POOLPAGE_ENDNOTE:      // "Endnote"
         {
-            lcl_PutStdPageSizeIntoItemSet( &m_rDoc, aSet );
+            lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
             aSet.Put( aLR );
             aSet.Put( aUL );
             pNewPgDsc->SetUseOn( UseOnPage::All );
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 7b9e4847da5f..dfd44aa959fe 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -938,7 +938,7 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
                         sFormula.clear();
 
                         // evaluate field
-                        const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->Evaluate(&rDoc);
+                        const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->Evaluate(rDoc);
                         // trigger formatting
                         const_cast<SwFormatField*>(pFormatField)->UpdateTextNode(nullptr, nullptr);
                     }
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 6a898f6f0048..62559485e76b 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -573,9 +573,9 @@ std::unique_ptr<SwField> SwDBNextSetField::Copy() const
     return std::unique_ptr<SwField>(pTmp.release());
 }
 
-void SwDBNextSetField::Evaluate(SwDoc const * pDoc)
+void SwDBNextSetField::Evaluate(const SwDoc& rDoc)
 {
-    SwDBManager* pMgr = pDoc->GetDBManager();
+    SwDBManager* pMgr = rDoc.GetDBManager();
     const SwDBData& rData = GetDBData();
     if( !m_bCondValid ||
             !pMgr || !pMgr->IsDataSourceOpen(rData.sDataSource, rData.sCommand, false))
@@ -659,9 +659,9 @@ std::unique_ptr<SwField> SwDBNumSetField::Copy() const
     return std::unique_ptr<SwField>(pTmp.release());
 }
 
-void SwDBNumSetField::Evaluate(SwDoc const * pDoc)
+void SwDBNumSetField::Evaluate(const SwDoc& rDoc)
 {
-    SwDBManager* pMgr = pDoc->GetDBManager();
+    SwDBManager* pMgr = rDoc.GetDBManager();
     const SwDBData& aTmpData = GetDBData();
 
     if( m_bCondValid && pMgr && pMgr->IsInMerge() &&
@@ -807,9 +807,9 @@ OUString SwDBSetNumberField::ExpandImpl(SwRootFrame const*const) const
     return FormatNumber(m_nNumber, static_cast<SvxNumType>(GetFormat()));
 }
 
-void SwDBSetNumberField::Evaluate(SwDoc const * pDoc)
+void SwDBSetNumberField::Evaluate(const SwDoc& rDoc)
 {
-    SwDBManager* pMgr = pDoc->GetDBManager();
+    SwDBManager* pMgr = rDoc.GetDBManager();
 
     const SwDBData& aTmpData = GetDBData();
     if (!pMgr || !pMgr->IsInMerge() ||
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 35bf08b5a96e..cca0e4ee8c7f 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -392,16 +392,16 @@ bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
     return true;
 }
 
-SwFileNameFieldType::SwFileNameFieldType(SwDoc *pDocument)
+SwFileNameFieldType::SwFileNameFieldType(SwDoc& rDocument)
     : SwFieldType( SwFieldIds::Filename )
+    , m_rDoc(rDocument)
 {
-    m_pDoc = pDocument;
 }
 
 OUString SwFileNameFieldType::Expand(sal_uLong nFormat) const
 {
     OUString aRet;
-    const SwDocShell* pDShell = m_pDoc->GetDocShell();
+    const SwDocShell* pDShell = m_rDoc.GetDocShell();
     if( pDShell && pDShell->HasName() )
     {
         const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
@@ -452,7 +452,7 @@ OUString SwFileNameFieldType::Expand(sal_uLong nFormat) const
 
 std::unique_ptr<SwFieldType> SwFileNameFieldType::Copy() const
 {
-    return std::make_unique<SwFileNameFieldType>(m_pDoc);
+    return std::make_unique<SwFileNameFieldType>(m_rDoc);
 }
 
 SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFormat)
@@ -564,10 +564,10 @@ bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
     return true;
 }
 
-SwTemplNameFieldType::SwTemplNameFieldType(SwDoc *pDocument)
+SwTemplNameFieldType::SwTemplNameFieldType(SwDoc& rDocument)
     : SwFieldType( SwFieldIds::TemplateName )
+    , m_rDoc(rDocument)
 {
-    m_pDoc = pDocument;
 }
 
 OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const
@@ -575,7 +575,7 @@ OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const
     OSL_ENSURE( nFormat < FF_END, "Expand: no valid Format!" );
 
     OUString aRet;
-    SwDocShell *pDocShell(m_pDoc->GetDocShell());
+    SwDocShell *pDocShell(m_rDoc.GetDocShell());
     OSL_ENSURE(pDocShell, "no SwDocShell");
     if (pDocShell) {
         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
@@ -622,7 +622,7 @@ OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const
 
 std::unique_ptr<SwFieldType> SwTemplNameFieldType::Copy() const
 {
-    return std::make_unique<SwTemplNameFieldType>(m_pDoc);
+    return std::make_unique<SwTemplNameFieldType>(m_rDoc);
 }
 
 SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFormat)
@@ -705,16 +705,17 @@ bool SwTemplNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
     return true;
 }
 
-SwDocStatFieldType::SwDocStatFieldType(SwDoc* pDocument)
-    : SwFieldType( SwFieldIds::DocStat ), m_nNumberingType( SVX_NUM_ARABIC )
+SwDocStatFieldType::SwDocStatFieldType(SwDoc& rDocument)
+    : SwFieldType(SwFieldIds::DocStat)
+    , m_rDoc(rDocument)
+    , m_nNumberingType(SVX_NUM_ARABIC)
 {
-    m_pDoc = pDocument;
 }
 
 OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, SvxNumType nFormat) const
 {
     sal_uInt32 nVal = 0;
-    const SwDocStat& rDStat = m_pDoc->getIDocumentStatistics().GetDocStat();
+    const SwDocStat& rDStat = m_rDoc.getIDocumentStatistics().GetDocStat();
     switch( nSubType )
     {
         case DS_TBL:  nVal = rDStat.nTable;   break;
@@ -724,8 +725,8 @@ OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, SvxNumType nFormat) con
         case DS_WORD: nVal = rDStat.nWord;  break;
         case DS_CHAR: nVal = rDStat.nChar;  break;
         case DS_PAGE:
-            if( m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
-                const_cast<SwDocStat &>(rDStat).nPage = m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetPageNum();
+            if( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )
+                const_cast<SwDocStat &>(rDStat).nPage = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->GetPageNum();
             nVal = rDStat.nPage;
             if( SVX_NUM_PAGEDESC == nFormat )
                 nFormat = m_nNumberingType;
@@ -742,7 +743,7 @@ OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, SvxNumType nFormat) con
 
 std::unique_ptr<SwFieldType> SwDocStatFieldType::Copy() const
 {
-    return std::make_unique<SwDocStatFieldType>(m_pDoc);
+    return std::make_unique<SwDocStatFieldType>(m_rDoc);
 }
 
 /**
@@ -1319,17 +1320,15 @@ OUString SwHiddenTextField::ExpandImpl(SwRootFrame const*const) const
 }
 
 /// get current field value and cache it
-void SwHiddenTextField::Evaluate(SwDoc* pDoc)
+void SwHiddenTextField::Evaluate(SwDoc& rDoc)
 {
-    OSL_ENSURE(pDoc, "got no document");
-
     if( SwFieldTypesEnum::ConditionalText != m_nSubType )
         return;
 
 #if !HAVE_FEATURE_DBCONNECTIVITY
-    (void) pDoc;
+    (void) rDoc;
 #else
-    SwDBManager* pMgr = pDoc->GetDBManager();
+    SwDBManager* pMgr = rDoc.GetDBManager();
 #endif
     m_bValid = false;
     OUString sTmpName = (m_bCanToggle && !m_bIsHidden) ? m_aTRUEText : m_aFALSEText;
@@ -1356,7 +1355,7 @@ void SwHiddenTextField::Evaluate(SwDoc* pDoc)
         if( pMgr)
         {
             sal_Int32 nIdx{ 0 };
-            OUString sDBName( GetDBName( sTmpName, pDoc ));
+            OUString sDBName( GetDBName( sTmpName, rDoc ));
             OUString sDataSource(sDBName.getToken(0, DB_DELIM, nIdx));
             OUString sDataTableOrQuery(sDBName.getToken(0, DB_DELIM, nIdx));
             if( pMgr->IsInMerge() && !sDBName.isEmpty() &&
@@ -1514,7 +1513,7 @@ OUString SwHiddenTextField::GetColumnName(const OUString& rName)
     return rName;
 }
 
-OUString SwHiddenTextField::GetDBName(const OUString& rName, SwDoc *pDoc)
+OUString SwHiddenTextField::GetDBName(const OUString& rName, SwDoc& rDoc)
 {
     sal_Int32 nPos = rName.indexOf(DB_DELIM);
     if( nPos>=0 )
@@ -1525,7 +1524,7 @@ OUString SwHiddenTextField::GetDBName(const OUString& rName, SwDoc *pDoc)
             return rName.copy(0, nPos);
     }
 
-    SwDBData aData = pDoc->GetDBData();
+    SwDBData aData = rDoc.GetDBData();
     return aData.sDataSource + OUStringChar(DB_DELIM) + aData.sCommand;
 }
 
@@ -1708,14 +1707,14 @@ OUString SwHiddenParaField::GetPar1() const
 
 // PostIt field type
 
-SwPostItFieldType::SwPostItFieldType(SwDoc *pDoc)
+SwPostItFieldType::SwPostItFieldType(SwDoc& rDoc)
     : SwFieldType( SwFieldIds::Postit )
-    , mpDoc(pDoc)
+    , mrDoc(rDoc)
 {}
 
 std::unique_ptr<SwFieldType> SwPostItFieldType::Copy() const
 {
-    return std::make_unique<SwPostItFieldType>(mpDoc);
+    return std::make_unique<SwPostItFieldType>(mrDoc);
 }
 
 // PostIt field
@@ -1856,8 +1855,8 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
             if ( !m_xTextObject.is() )
             {
                 SwPostItFieldType* pGetType = static_cast<SwPostItFieldType*>(GetTyp());
-                SwDoc* pDoc = pGetType->GetDoc();
-                auto pObj = std::make_unique<SwTextAPIEditSource>( pDoc );
+                SwDoc& rDoc = pGetType->GetDoc();
+                auto pObj = std::make_unique<SwTextAPIEditSource>( &rDoc );
                 const_cast <SwPostItField*> (this)->m_xTextObject = new SwTextAPIObject( std::move(pObj) );
             }
 
@@ -2154,14 +2153,14 @@ bool SwRefPageSetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
 
 // relative page numbers - query field
 
-SwRefPageGetFieldType::SwRefPageGetFieldType( SwDoc* pDc )
-    : SwFieldType( SwFieldIds::RefPageGet ), m_pDoc( pDc ), m_nNumberingType( SVX_NUM_ARABIC )
+SwRefPageGetFieldType::SwRefPageGetFieldType( SwDoc& rDc )
+    : SwFieldType( SwFieldIds::RefPageGet ), m_rDoc( rDc ), m_nNumberingType( SVX_NUM_ARABIC )
 {
 }
 
 std::unique_ptr<SwFieldType> SwRefPageGetFieldType::Copy() const
 {
-    std::unique_ptr<SwRefPageGetFieldType> pNew(new SwRefPageGetFieldType( m_pDoc ));
+    std::unique_ptr<SwRefPageGetFieldType> pNew(new SwRefPageGetFieldType( m_rDoc ));
     pNew->m_nNumberingType = m_nNumberingType;
     return pNew;
 }
@@ -2186,7 +2185,7 @@ void SwRefPageGetFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem*
     {
         SwRootFrame const* pLayout(nullptr);
         SwRootFrame const* pLayoutRLHidden(nullptr);
-        for (SwRootFrame const*const pLay : m_pDoc->GetAllLayouts())
+        for (SwRootFrame const*const pLay : m_rDoc.GetAllLayouts())
         {
             if (pLay->IsHideRedlines())
             {
@@ -2211,7 +2210,7 @@ void SwRefPageGetFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem*
 bool SwRefPageGetFieldType::MakeSetList(SetGetExpFields& rTmpLst,
         SwRootFrame const*const pLayout)
 {
-    IDocumentRedlineAccess const& rIDRA(m_pDoc->getIDocumentRedlineAccess());
+    IDocumentRedlineAccess const& rIDRA(m_rDoc.getIDocumentRedlineAccess());
     std::vector<SwFormatField*> vFields;
     GatherFields(vFields);
     for(auto pFormatField: vFields)
@@ -2243,8 +2242,8 @@ bool SwRefPageGetFieldType::MakeSetList(SetGetExpFields& rTmpLst,
             else
             {
                 //  create index for determination of the TextNode
-                SwPosition aPos( m_pDoc->GetNodes().GetEndOfPostIts() );
-                bool const bResult = GetBodyTextNode( *m_pDoc, aPos, *pFrame );
+                SwPosition aPos( m_rDoc.GetNodes().GetEndOfPostIts() );
+                bool const bResult = GetBodyTextNode( m_rDoc, aPos, *pFrame );
                 OSL_ENSURE(bResult, "where is the Field?");
                 pNew.reset( new SetGetExpField( aPos.nNode, pTField,
                                             &aPos.nContent ) );
@@ -2266,7 +2265,7 @@ void SwRefPageGetFieldType::UpdateField( SwTextField const * pTextField,
     // then search the correct RefPageSet field
     SwTextNode* pTextNode = &pTextField->GetTextNode();
     if( pTextNode->StartOfSectionIndex() >
-        m_pDoc->GetNodes().GetEndOfExtras().GetIndex() )
+        m_rDoc.GetNodes().GetEndOfExtras().GetIndex() )
     {
         SwNodeIndex aIdx( *pTextNode );
         SetGetExpField aEndField( aIdx, pTextField );
@@ -2351,9 +2350,9 @@ void SwRefPageGetField::ChangeExpansion(const SwFrame& rFrame,
 {
     // only fields in Footer, Header, FootNote, Flys
     SwRefPageGetFieldType* pGetType = static_cast<SwRefPageGetFieldType*>(GetTyp());
-    SwDoc* pDoc = pGetType->GetDoc();
+    SwDoc& rDoc = pGetType->GetDoc();
     if( pField->GetTextNode().StartOfSectionIndex() >
-        pDoc->GetNodes().GetEndOfExtras().GetIndex() )
+        rDoc.GetNodes().GetEndOfExtras().GetIndex() )
         return;
 
     SwRootFrame const& rLayout(*rFrame.getRootFrame());
@@ -2368,8 +2367,8 @@ void SwRefPageGetField::ChangeExpansion(const SwFrame& rFrame,
         return ;
 
     //  create index for determination of the TextNode
-    SwPosition aPos( SwNodeIndex( pDoc->GetNodes() ) );
-    SwTextNode* pTextNode = const_cast<SwTextNode*>(GetBodyTextNode(*pDoc, aPos, rFrame));
+    SwPosition aPos( SwNodeIndex( rDoc.GetNodes() ) );
+    SwTextNode* pTextNode = const_cast<SwTextNode*>(GetBodyTextNode(rDoc, aPos, rFrame));
 
     // If no layout exists, ChangeExpansion is called for header and
     // footer lines via layout formatting without existing TextNode.
@@ -2447,19 +2446,19 @@ bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
 
 // field type to jump to and edit
 
-SwJumpEditFieldType::SwJumpEditFieldType( SwDoc* pD )
-    : SwFieldType( SwFieldIds::JumpEdit ), m_pDoc( pD ), m_aDep( *this )
+SwJumpEditFieldType::SwJumpEditFieldType( SwDoc& rD )
+    : SwFieldType( SwFieldIds::JumpEdit ), m_rDoc( rD ), m_aDep( *this )
 {
 }
 
 std::unique_ptr<SwFieldType> SwJumpEditFieldType::Copy() const
 {
-    return std::make_unique<SwJumpEditFieldType>( m_pDoc );
+    return std::make_unique<SwJumpEditFieldType>( m_rDoc );
 }
 
 SwCharFormat* SwJumpEditFieldType::GetCharFormat()
 {
-    SwCharFormat* pFormat = m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( RES_POOLCHR_JUMPEDIT );
+    SwCharFormat* pFormat = m_rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( RES_POOLCHR_JUMPEDIT );
     m_aDep.StartListening(pFormat);
     return pFormat;
 }
diff --git a/sw/source/core/fields/macrofld.cxx b/sw/source/core/fields/macrofld.cxx
index 2847ecbb16c9..c9fd26870f99 100644
--- a/sw/source/core/fields/macrofld.cxx
+++ b/sw/source/core/fields/macrofld.cxx
@@ -27,15 +27,15 @@
 
 using namespace ::com::sun::star;
 
-SwMacroFieldType::SwMacroFieldType(SwDoc* pDocument)
-    : SwFieldType( SwFieldIds::Macro ),
-      m_pDoc(pDocument)
+SwMacroFieldType::SwMacroFieldType(SwDoc& rDocument)
+    : SwFieldType( SwFieldIds::Macro )
+    , m_rDoc(rDocument)
 {
 }
 
 std::unique_ptr<SwFieldType> SwMacroFieldType::Copy() const
 {
-    return std::make_unique<SwMacroFieldType>(m_pDoc);
+    return std::make_unique<SwMacroFieldType>(m_rDoc);
 }
 
 SwMacroField::SwMacroField(SwMacroFieldType* pInitType,
diff --git a/sw/source/core/fields/scrptfld.cxx b/sw/source/core/fields/scrptfld.cxx
index 37f2e3dc2084..ded42cc7f0ba 100644
--- a/sw/source/core/fields/scrptfld.cxx
+++ b/sw/source/core/fields/scrptfld.cxx
@@ -25,13 +25,13 @@
 
 using namespace ::com::sun::star;
 
-SwScriptFieldType::SwScriptFieldType( SwDoc* pD )
-    : SwFieldType( SwFieldIds::Script ), m_pDoc( pD )
+SwScriptFieldType::SwScriptFieldType( SwDoc& rD )
+    : SwFieldType( SwFieldIds::Script ), m_rDoc( rD )
 {}
 
 std::unique_ptr<SwFieldType> SwScriptFieldType::Copy() const
 {
-    return std::make_unique<SwScriptFieldType>( m_pDoc );
+    return std::make_unique<SwScriptFieldType>( m_rDoc );
 }
 
 SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index be1aff542c13..a2008e7c4393 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -720,10 +720,9 @@ SwTextAnnotationField::~SwTextAnnotationField()
     auto pPostItField = dynamic_cast<const SwPostItField*>(GetFormatField().GetField());
     assert(pPostItField);
 
-    SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
-    assert(pDoc != nullptr);
+    SwDoc& rDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
 
-    IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
+    IDocumentMarkAccess* pMarksAccess = rDoc.getIDocumentMarkAccess();
     IDocumentMarkAccess::const_iterator_t pMark = pMarksAccess->findAnnotationMark( pPostItField->GetName() );
     return pMark != pMarksAccess->getAnnotationMarksEnd()
            ? *pMark


More information about the Libreoffice-commits mailing list