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

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


 sw/inc/editsh.hxx                                       |    2 
 sw/inc/fesh.hxx                                         |    8 
 sw/inc/reffld.hxx                                       |    6 
 sw/inc/unochart.hxx                                     |    2 
 sw/qa/core/txtnode/txtnode.cxx                          |    4 
 sw/qa/extras/uiwriter/uiwriter.cxx                      |   34 +-
 sw/source/core/doc/DocumentChartDataProviderManager.cxx |    2 
 sw/source/core/doc/DocumentFieldsManager.cxx            |    2 
 sw/source/core/edit/eddel.cxx                           |   39 +--
 sw/source/core/fields/reffld.cxx                        |   34 +-
 sw/source/core/frmedt/fecopy.cxx                        |  184 +++++++---------
 sw/source/core/inc/UndoBookmark.hxx                     |    2 
 sw/source/core/inc/rolbck.hxx                           |    4 
 sw/source/core/layout/atrfrm.cxx                        |    2 
 sw/source/core/undo/rolbck.cxx                          |   16 -
 sw/source/core/undo/unbkmk.cxx                          |   16 -
 sw/source/core/unocore/unochart.cxx                     |    4 
 sw/source/core/view/vprint.cxx                          |    2 
 sw/source/uibase/dochdl/swdtflvr.cxx                    |   14 -
 sw/source/uibase/docvw/edtwin.cxx                       |    2 
 20 files changed, 186 insertions(+), 193 deletions(-)

New commits:
commit a4dbf43bf505980e6acc587aa13096c215aa99e9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Oct 5 09:59:11 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 5 18:35:23 2020 +0200

    SwGetRefFieldType ctor never passed a null SwDoc*
    
    ditto:
    SwFEShell::Copy
    SwEditShell::Copy
    SwFEShell::CopyDrawSel
    SwFEShell::Paste
    SwChartDataProvider ctor
    ResetInDoc family
    
    Change-Id: I2d1544c09919f0e566fadc04d3b160b18ea62fc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103957
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index b5d0068bd86a..b2ba48315230 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -194,7 +194,7 @@ public:
     void SetLinkUpdMode( sal_uInt16 nMode );
 
     /// Copy content of all ranges at current position of cursor to given Shell.
-    bool Copy( SwEditShell* pDestShell );
+    bool Copy( SwEditShell& rDestShell );
 
     /** For copying via ClipBoard:
        If table is copied into table, move all cursors away from it.
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 741462379db2..570597a7e580 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -234,7 +234,7 @@ private:
     SAL_DLLPRIVATE bool ImpEndCreate();
 
     /// Methods for copying of draw objects.
-    SAL_DLLPRIVATE bool CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
+    SAL_DLLPRIVATE bool CopyDrawSel( SwFEShell& rDestShell, const Point& rSttPt,
                                 const Point& rInsPt, bool bIsMove,
                                 bool bSelectInsert );
 
@@ -255,14 +255,14 @@ public:
     virtual ~SwFEShell() override;
 
     /// Copy and Paste methods for internal clipboard.
-    void Copy( SwDoc* pClpDoc, const OUString* pNewClpText = nullptr );
-    bool Paste( SwDoc* pClpDoc, bool bNestedTable = false );
+    void Copy( SwDoc& rClpDoc, const OUString* pNewClpText = nullptr );
+    bool Paste( SwDoc& rClpDoc, bool bNestedTable = false );
 
     /// Paste some pages into another doc - used in mailmerge.
     void PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage);
 
     /// Copy-Method for Drag&Drop
-    bool Copy( SwFEShell*, const Point& rSttPt, const Point& rInsPt,
+    bool Copy( SwFEShell&, const Point& rSttPt, const Point& rInsPt,
                bool bIsMove = false, bool bSelectInsert = true );
 
     void SelectFlyFrame( SwFlyFrame& rFrame );
diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index f59ea0d55b43..6d9ee86f7950 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -64,15 +64,15 @@ enum REFERENCEMARK
 
 class SAL_DLLPUBLIC_RTTI SwGetRefFieldType final : public SwFieldType
 {
-    SwDoc* m_pDoc;
+    SwDoc& m_rDoc;
 
     /// Overlay in order to update all ref-fields.
     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
 public:
-    SwGetRefFieldType(SwDoc* pDoc );
+    SwGetRefFieldType(SwDoc& rDoc );
     virtual std::unique_ptr<SwFieldType> Copy() const override;
 
-    SwDoc*                  GetDoc() const { return m_pDoc; }
+    SwDoc&                  GetDoc() const { return m_rDoc; }
 
     void MergeWithOtherDoc( SwDoc& rDestDoc );
 
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 7eb499a848f8..7147f8a036eb 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -142,7 +142,7 @@ class SwChartDataProvider final :
     static OUString GetBrokenCellRangeForExport( const OUString &rCellRangeRepresentation );
 
 public:
-    SwChartDataProvider( const SwDoc* pDoc );
+    SwChartDataProvider( const SwDoc& rDoc );
     virtual ~SwChartDataProvider() override;
 
     // XDataProvider
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 217c32f51f5f..ce55e517e196 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -52,9 +52,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxCopyAnchor)
     SwWrtShell* pWrtShell = pShell->GetWrtShell();
     SwDoc aClipboard;
     pWrtShell->SelAll();
-    pWrtShell->Copy(&aClipboard);
+    pWrtShell->Copy(aClipboard);
     pWrtShell->SttEndDoc(/*bStart=*/false);
-    pWrtShell->Paste(&aClipboard);
+    pWrtShell->Paste(aClipboard);
 
     const SwFrameFormats& rFormats = *pShell->GetDoc()->GetSpzFrameFormats();
     // Without the accompanying fix in place, this test would have failed with:
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6df15abeb888..525f4cc81d0e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1022,7 +1022,7 @@ void SwUiWriterTest::testExportRTF()
     // Create the clipboard document.
     rtl::Reference<SwDoc> xClpDoc(new SwDoc());
     xClpDoc->SetClipBoard(true);
-    pWrtShell->Copy(xClpDoc.get());
+    pWrtShell->Copy(*xClpDoc);
 
     // And finally export it as RTF.
     WriterRef xWrt;
@@ -1554,8 +1554,8 @@ void SwUiWriterTest::testFdo82191()
     SdrObject* pObject = pPage->GetObj(0);
     // Select it, then copy and paste.
     pWrtShell->SelectObj(Point(), 0, pObject);
-    pWrtShell->Copy(&aClipboard);
-    pWrtShell->Paste(&aClipboard);
+    pWrtShell->Copy(aClipboard);
+    pWrtShell->Paste(aClipboard);
 
     // This was one: the textbox of the shape wasn't copied.
     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), SwTextBoxHelper::getCount(*pDoc));
@@ -2975,7 +2975,7 @@ void SwUiWriterTest::testTdf77342()
     pCursor->Move(fnMoveForward);
     pCursor->Move(fnMoveForward);
     //copying the selection to clipboard
-    pWrtShell->Copy(xClpDoc.get());
+    pWrtShell->Copy(*xClpDoc);
     //deleting selection mark after copy
     pCursor->DeleteMark();
     //checking that the footnotes reference fields have same values after copy operation
@@ -3005,7 +3005,7 @@ void SwUiWriterTest::testTdf77342()
     //moving cursor to the end of the document
     pWrtShell->EndOfSection();
     //pasting the copied selection at current cursor position
-    pWrtShell->Paste(xClpDoc.get());
+    pWrtShell->Paste(*xClpDoc);
     //checking the fields, both new and old, for proper values
     pWrtShell->StartOfSection();
     //old reference field 1
@@ -3077,7 +3077,7 @@ void SwUiWriterTest::testTdf77342()
     //moving the cursor to the starting of document
     pWrtShell->StartOfSection();
     //pasting the selection again at current cursor position
-    pWrtShell->Paste(xClpDoc.get());
+    pWrtShell->Paste(*xClpDoc);
     //checking the fields, both new and old, for proper values
     pWrtShell->StartOfSection();
     //new reference field 1
@@ -3230,7 +3230,7 @@ void SwUiWriterTest::testTdf63553()
     pCursor->Move(fnMoveForward);
     pCursor->Move(fnMoveForward);
     //copying the selection to clipboard
-    pWrtShell->Copy(xClpDoc.get());
+    pWrtShell->Copy(*xClpDoc);
     //deleting selection mark after copy
     pCursor->DeleteMark();
     //checking whether the sequence and reference fields have same values after copy operation
@@ -3275,7 +3275,7 @@ void SwUiWriterTest::testTdf63553()
     //moving cursor to the end of the document
     pWrtShell->EndOfSection();
     //pasting the copied selection at current cursor position
-    pWrtShell->Paste(xClpDoc.get());
+    pWrtShell->Paste(*xClpDoc);
     //checking the fields, both new and old, for proper values
     pWrtShell->StartOfSection();
     //now we have ref1-ref2-ref3-seq1-seq2-seq3-nref1-nref2-nseq1-nseq2
@@ -3341,7 +3341,7 @@ void SwUiWriterTest::testTdf63553()
     //moving the cursor to the starting of document
     pWrtShell->StartOfSection();
     //pasting the selection again at current cursor position
-    pWrtShell->Paste(xClpDoc.get());
+    pWrtShell->Paste(*xClpDoc);
     //checking the fields, both new and old, for proper values
     pWrtShell->StartOfSection();
     //now we have [nnref1-nnref2-nnseq1-nnseq2]-ref1-[ref2-ref3-seq1-seq2]-seq3-[nref1-nref2-nseq1-nseq2]
@@ -5551,9 +5551,9 @@ void SwUiWriterTest::testRedlineCopyPaste()
 
     // Select the whole content, copy, delete the original and paste the copied content
     pWrtShell->SelAll();
-    pWrtShell->Copy(&aClipboard);
+    pWrtShell->Copy(aClipboard);
     pWrtShell->Delete();
-    pWrtShell->Paste(&aClipboard);
+    pWrtShell->Paste(aClipboard);
 
     // With the bug this is "abzcdefgh", ie. contains the first deleted piece, too
     CPPUNIT_ASSERT_EQUAL(OUString("abcdefgh"), pTextNode->GetText());
@@ -5853,7 +5853,7 @@ void SwUiWriterTest::testTdf95699()
     SwDoc aClipboard;
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     pWrtShell->SelAll();
-    pWrtShell->Copy(&aClipboard);
+    pWrtShell->Copy(aClipboard);
     pMarkAccess = aClipboard.getIDocumentMarkAccess();
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
     ::sw::mark::IFieldmark* pFieldMark = pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()));
@@ -5871,9 +5871,9 @@ void SwUiWriterTest::testTdf104032()
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     pWrtShell->StartOfSection();
     pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
-    pWrtShell->Copy(&aClipboard);
+    pWrtShell->Copy(aClipboard);
     pWrtShell->EndOfSection();
-    pWrtShell->Paste(&aClipboard);
+    pWrtShell->Paste(aClipboard);
     rUndoManager.Undo();
 }
 
@@ -6825,11 +6825,11 @@ void SwUiWriterTest::testTdf113790()
     pWrtShell->Down(/*bSelect=*/false, 4);
     pWrtShell->SelPara(nullptr);
     CPPUNIT_ASSERT_EQUAL(OUString("ABCD"), pWrtShell->GetSelText());
-    pWrtShell->Copy(&aClipboard);
+    pWrtShell->Copy(aClipboard);
 
     // Go down to next-to-last (empty) line above "Title3"
     pWrtShell->Down(/*bSelect=*/false, 4);
-    pWrtShell->Paste(&aClipboard);
+    pWrtShell->Paste(aClipboard);
 
     // Save it as DOCX & load it again
     reload("Office Open XML Text", "tdf113790.docx");
@@ -6964,7 +6964,7 @@ void SwUiWriterTest::testTdf115065()
 
     pWrtShell->SelTableCol();
     // The copy operation (or closing document after that) segfaulted
-    pWrtShell->Copy(pWrtShell, ptFrom, ptTo);
+    pWrtShell->Copy(*pWrtShell, ptFrom, ptTo);
 }
 
 void SwUiWriterTest::testTdf115132()
diff --git a/sw/source/core/doc/DocumentChartDataProviderManager.cxx b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
index 72640b4629d4..cd5aae52308e 100644
--- a/sw/source/core/doc/DocumentChartDataProviderManager.cxx
+++ b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
@@ -48,7 +48,7 @@ SwChartDataProvider * DocumentChartDataProviderManager::GetChartDataProvider( bo
 
     if (bCreate && !maChartDataProviderImplRef.is())
     {
-        maChartDataProviderImplRef = new SwChartDataProvider( & m_rDoc );
+        maChartDataProviderImplRef = new SwChartDataProvider(m_rDoc);
     }
     return maChartDataProviderImplRef.get();
 }
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 72ed8ae8ef4a..d322463e6a9a 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1767,7 +1767,7 @@ void DocumentFieldsManager::InitFieldTypes()       // is being called by the CTO
     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 SwGetRefFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwHiddenTextFieldType );
     mpFieldTypes->emplace_back( new SwPostItFieldType(m_rDoc) );
     mpFieldTypes->emplace_back( new SwDocStatFieldType(m_rDoc) );
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index b501833fc16d..87999e1f869e 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -160,12 +160,9 @@ bool SwEditShell::Delete()
     return bRet;
 }
 
-bool SwEditShell::Copy( SwEditShell* pDestShell )
+bool SwEditShell::Copy( SwEditShell& rDestShell )
 {
-    if( !pDestShell )
-        pDestShell = this;
-
-    CurrShell aCurr( pDestShell );
+    CurrShell aCurr( &rDestShell );
 
     // List of insert positions for smart insert of block selections
     std::vector< std::shared_ptr<SwPosition> > aInsertList;
@@ -179,7 +176,7 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
         {
             if( !pPos )
             {
-                if( pDestShell == this )
+                if( &rDestShell == this )
                 {
                     // First cursor represents the target position!!
                     rPaM.DeleteMark();
@@ -187,7 +184,7 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
                     continue;
                 }
                 else
-                    pPos = pDestShell->GetCursor()->GetPoint();
+                    pPos = rDestShell.GetCursor()->GetPoint();
             }
             if( IsBlockMode() )
             {   // In block mode different insert positions will be calculated
@@ -207,27 +204,27 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
             }
             SwPosition *pTmp = IsBlockMode() ? pInsertPos.get() : pPos;
             // Check if a selection would be copied into itself
-            if( pDestShell->GetDoc() == GetDoc() &&
+            if( rDestShell.GetDoc() == GetDoc() &&
                 *rPaM.Start() <= *pTmp && *pTmp < *rPaM.End() )
                 return false;
         }
     }
 
-    pDestShell->StartAllAction();
+    rDestShell.StartAllAction();
     SwPosition *pPos = nullptr;
     bool bRet = false;
     bool bFirstMove = true;
-    SwNodeIndex aSttNdIdx( pDestShell->GetDoc()->GetNodes() );
+    SwNodeIndex aSttNdIdx( rDestShell.GetDoc()->GetNodes() );
     sal_Int32 nSttCntIdx = 0;
     // For block selection this list is filled with the insert positions
     auto pNextInsert = aInsertList.begin();
 
-    pDestShell->GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
+    rDestShell.GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
     for(SwPaM& rPaM : GetCursor()->GetRingContainer())
     {
         if( !pPos )
         {
-            if( pDestShell == this )
+            if( &rDestShell == this )
             {
                 // First cursor represents the target position!!
                 rPaM.DeleteMark();
@@ -235,7 +232,7 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
                 continue;
             }
             else
-                pPos = pDestShell->GetCursor()->GetPoint();
+                pPos = rDestShell.GetCursor()->GetPoint();
         }
         if( !bFirstMove )
         {
@@ -265,7 +262,7 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
             continue;
 
         SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx));
-        pDestShell->GetDoc()->MakeUniqueNumRules(aInsertPaM);
+        rDestShell.GetDoc()->MakeUniqueNumRules(aInsertPaM);
 
         bRet = true;
     }
@@ -273,7 +270,7 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
     // Maybe nothing has been moved?
     if( !bFirstMove )
     {
-        SwPaM* pCursor = pDestShell->GetCursor();
+        SwPaM* pCursor = rDestShell.GetCursor();
         pCursor->SetMark();
         pCursor->GetPoint()->nNode = aSttNdIdx.GetIndex()+1;
         pCursor->GetPoint()->nContent.Assign( pCursor->GetContentNode(),nSttCntIdx);
@@ -282,13 +279,13 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
     else
     {
         // If the cursor moved during move process, move also its GetMark
-        pDestShell->GetCursor()->SetMark();
-        pDestShell->GetCursor()->DeleteMark();
+        rDestShell.GetCursor()->SetMark();
+        rDestShell.GetCursor()->DeleteMark();
     }
 #if OSL_DEBUG_LEVEL > 0
     // check if the indices are registered in the correct nodes
     {
-        for(SwPaM& rCmp : pDestShell->GetCursor()->GetRingContainer())
+        for(SwPaM& rCmp : rDestShell.GetCursor()->GetRingContainer())
         {
             OSL_ENSURE( rCmp.GetPoint()->nContent.GetIdxReg()
                         == rCmp.GetContentNode(), "Point in wrong Node" );
@@ -299,10 +296,10 @@ bool SwEditShell::Copy( SwEditShell* pDestShell )
 #endif
 
     // close Undo container here
-    pDestShell->GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
-    pDestShell->EndAllAction();
+    rDestShell.GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
+    rDestShell.EndAllAction();
 
-    pDestShell->SaveTableBoxContent( pDestShell->GetCursor()->GetPoint() );
+    rDestShell.SaveTableBoxContent( rDestShell.GetCursor()->GetPoint() );
 
     return bRet;
 }
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 6fb93aa2f9d7..7d9e73feb7de 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -395,7 +395,7 @@ const SwTextNode* SwGetRefField::GetReferencedTextNode() const
     if (!pTyp)
         return nullptr;
     sal_Int32 nDummy = -1;
-    return SwGetRefFieldType::FindAnchor( pTyp->GetDoc(), m_sSetRefName, m_nSubType, m_nSeqNo, &nDummy );
+    return SwGetRefFieldType::FindAnchor( &pTyp->GetDoc(), m_sSetRefName, m_nSubType, m_nSeqNo, &nDummy );
 }
 
 // #i85090#
@@ -464,12 +464,12 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
     m_sText.clear();
     m_sTextRLHidden.clear();
 
-    SwDoc* pDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
+    SwDoc& rDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
     // finding the reference target (the number)
     sal_Int32 nNumStart = -1;
     sal_Int32 nNumEnd = -1;
     SwTextNode* pTextNd = SwGetRefFieldType::FindAnchor(
-        pDoc, m_sSetRefName, m_nSubType, m_nSeqNo, &nNumStart, &nNumEnd
+        &rDoc, m_sSetRefName, m_nSubType, m_nSeqNo, &nNumStart, &nNumEnd
     );
     // not found?
     if ( !pTextNd )
@@ -481,7 +481,7 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
 
     SwRootFrame const* pLayout(nullptr);
     SwRootFrame const* pLayoutRLHidden(nullptr);
-    for (SwRootFrame const*const pLay : pDoc->GetAllLayouts())
+    for (SwRootFrame const*const pLay : rDoc.GetAllLayouts())
     {
         if (pLay->IsHideRedlines())
         {
@@ -541,7 +541,7 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
                         const sal_Int32 nFrom = bHasCat
                             ? std::max(nNumStart + 1, nCatEnd)
                             : nNumStart + 1;
-                        nStart = SwGetExpField::GetReferenceTextPos( pTextAttr->GetFormatField(), *pDoc, nFrom );
+                        nStart = SwGetExpField::GetReferenceTextPos( pTextAttr->GetFormatField(), rDoc, nFrom );
                     } else {
                         nStart = bHasCat ? std::max(nNumEnd, nCatEnd) : nNumEnd;
                     }
@@ -580,13 +580,13 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
             case REF_FOOTNOTE:
             case REF_ENDNOTE:
                 // get number or numString
-                for( size_t i = 0; i < pDoc->GetFootnoteIdxs().size(); ++i )
+                for( size_t i = 0; i < rDoc.GetFootnoteIdxs().size(); ++i )
                 {
-                    SwTextFootnote* const pFootnoteIdx = pDoc->GetFootnoteIdxs()[i];
+                    SwTextFootnote* const pFootnoteIdx = rDoc.GetFootnoteIdxs()[i];
                     if( m_nSeqNo == pFootnoteIdx->GetSeqRefNo() )
                     {
-                        m_sText = pFootnoteIdx->GetFootnote().GetViewNumStr(*pDoc, nullptr);
-                        m_sTextRLHidden = pFootnoteIdx->GetFootnote().GetViewNumStr(*pDoc, pLayoutRLHidden);
+                        m_sText = pFootnoteIdx->GetFootnote().GetViewNumStr(rDoc, nullptr);
+                        m_sTextRLHidden = pFootnoteIdx->GetFootnote().GetViewNumStr(rDoc, pLayoutRLHidden);
                         if (!m_sSetReferenceLanguage.isEmpty())
                         {
                             lcl_formatReferenceLanguage(m_sText, false, GetLanguage(), m_sSetReferenceLanguage);
@@ -1031,10 +1031,10 @@ void SwGetRefField::ConvertProgrammaticToUIName()
     if(!(GetTyp() && REF_SEQUENCEFLD == m_nSubType))
         return;
 
-    SwDoc* pDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
+    SwDoc& rDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
     const OUString rPar1 = GetPar1();
     // don't convert when the name points to an existing field type
-    if(pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rPar1, false))
+    if (rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rPar1, false))
         return;
 
     sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromProgName( rPar1, SwGetPoolIdFromName::TxtColl );
@@ -1061,13 +1061,13 @@ void SwGetRefField::ConvertProgrammaticToUIName()
         SetPar1(SwResId(pResId));
 }
 
-SwGetRefFieldType::SwGetRefFieldType( SwDoc* pDc )
-    : SwFieldType( SwFieldIds::GetRef ), m_pDoc( pDc )
+SwGetRefFieldType::SwGetRefFieldType( SwDoc& rDc )
+    : SwFieldType( SwFieldIds::GetRef ), m_rDoc( rDc )
 {}
 
 std::unique_ptr<SwFieldType> SwGetRefFieldType::Copy() const
 {
-    return std::make_unique<SwGetRefFieldType>( m_pDoc );
+    return std::make_unique<SwGetRefFieldType>( m_rDoc );
 }
 
 void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
@@ -1409,7 +1409,7 @@ void RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rField,
 ///    what is most desirable since it's going to be wrong anyway
 void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc )
 {
-    if( &rDestDoc == m_pDoc )
+    if (&rDestDoc == &m_rDoc)
         return;
 
     if (rDestDoc.IsClipBoard())
@@ -1449,13 +1449,13 @@ void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc )
                     aFieldMap.push_back(std::unique_ptr<RefIdsMap>(pMap));
                 }
 
-                pMap->Check( *m_pDoc, rDestDoc, rRefField, true );
+                pMap->Check(m_rDoc, rDestDoc, rRefField, true);
             }
             break;
 
         case REF_FOOTNOTE:
         case REF_ENDNOTE:
-            aFntMap.Check( *m_pDoc, rDestDoc, rRefField, false );
+            aFntMap.Check(m_rDoc, rDestDoc, rRefField, false);
             break;
         }
     }
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 2ee2dc9092b3..ffb74b457180 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -74,28 +74,26 @@
 using namespace ::com::sun::star;
 
 // Copy for the internal clipboard. Copies all selections to the clipboard.
-void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
+void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText )
 {
-    OSL_ENSURE( pClpDoc, "No Clipboard document"  );
-
-    pClpDoc->GetIDocumentUndoRedo().DoUndo(false); // always false!
+    rClpDoc.GetIDocumentUndoRedo().DoUndo(false); // always false!
 
     // delete content if ClpDocument contains content
-    SwNodeIndex aSttIdx( pClpDoc->GetNodes().GetEndOfExtras(), 2 );
+    SwNodeIndex aSttIdx( rClpDoc.GetNodes().GetEndOfExtras(), 2 );
     SwNodeIndex aEndNdIdx( *aSttIdx.GetNode().EndOfSectionNode() );
     SwTextNode* pTextNd = aSttIdx.GetNode().GetTextNode();
     if (!pTextNd || !pTextNd->GetText().isEmpty() ||
-        aSttIdx.GetIndex()+1 != pClpDoc->GetNodes().GetEndOfContent().GetIndex() )
+        aSttIdx.GetIndex()+1 != rClpDoc.GetNodes().GetEndOfContent().GetIndex() )
     {
-        pClpDoc->GetNodes().Delete( aSttIdx,
-            pClpDoc->GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
-        pTextNd = pClpDoc->GetNodes().MakeTextNode( aSttIdx,
-                            pClpDoc->GetDfltTextFormatColl() );
+        rClpDoc.GetNodes().Delete( aSttIdx,
+            rClpDoc.GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
+        pTextNd = rClpDoc.GetNodes().MakeTextNode( aSttIdx,
+                            rClpDoc.GetDfltTextFormatColl() );
         --aSttIdx;
     }
 
     // also delete surrounding FlyFrames if any
-    for( const auto pFly : *pClpDoc->GetSpzFrameFormats() )
+    for( const auto pFly : *rClpDoc.GetSpzFrameFormats() )
     {
         SwFormatAnchor const*const pAnchor = &pFly->GetAnchor();
         SwPosition const*const pAPos = pAnchor->GetContentAnchor();
@@ -104,11 +102,11 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
              (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
             aSttIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx )
         {
-            pClpDoc->getIDocumentLayoutAccess().DelLayoutFormat( pFly );
+            rClpDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFly );
         }
     }
 
-    pClpDoc->GetDocumentFieldsManager().GCFieldTypes();        // delete the FieldTypes
+    rClpDoc.GetDocumentFieldsManager().GCFieldTypes();        // delete the FieldTypes
 
     // if a string was passed, copy it to the clipboard-
     // document. Then also the Calculator can use the internal
@@ -119,8 +117,8 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
         return;                // that's it
     }
 
-    pClpDoc->getIDocumentFieldsAccess().LockExpFields();
-    pClpDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::DeleteRedlines );
+    rClpDoc.getIDocumentFieldsAccess().LockExpFields();
+    rClpDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::DeleteRedlines );
 
     // do we want to copy a FlyFrame?
     if( IsFrameSelected() )
@@ -142,11 +140,11 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
             }
             aAnchor.SetAnchor( &aPos );
         }
-        pFlyFormat = pClpDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
+        pFlyFormat = rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
 
         // assure the "RootFormat" is the first element in Spz-Array
         // (if necessary Flys were copied in Flys)
-        SwFrameFormats& rSpzFrameFormats = *pClpDoc->GetSpzFrameFormats();
+        SwFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats();
         if( rSpzFrameFormats[ 0 ] != pFlyFormat )
         {
 #ifndef NDEBUG
@@ -184,17 +182,17 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
             if( Imp()->GetDrawView()->IsGroupEntered() ||
                 ( !pObj->GetUserCall() && pObj->getParentSdrObjectFromSdrObject()) )
             {
-                SfxItemSet aSet( pClpDoc->GetAttrPool(), aFrameFormatSetRange );
+                SfxItemSet aSet( rClpDoc.GetAttrPool(), aFrameFormatSetRange );
 
                 SwFormatAnchor aAnchor( RndStdIds::FLY_AT_PARA );
                 aAnchor.SetAnchor( &aPos );
                 aSet.Put( aAnchor );
 
                 SdrObject *const pNew =
-                    pClpDoc->CloneSdrObj( *pObj );
+                    rClpDoc.CloneSdrObj( *pObj );
 
                 SwPaM aTemp(aPos);
-                pClpDoc->getIDocumentContentOperations().InsertDrawObj(aTemp, *pNew, aSet );
+                rClpDoc.getIDocumentContentOperations().InsertDrawObj(aTemp, *pNew, aSet );
             }
             else
             {
@@ -209,17 +207,17 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText )
                     aAnchor.SetAnchor( &aPos );
                 }
 
-                pClpDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true );
+                rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true );
             }
         }
     }
     else
-        CopySelToDoc(*pClpDoc);     // copy the selections
+        CopySelToDoc(rClpDoc);     // copy the selections
 
-    pClpDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE );
-    pClpDoc->getIDocumentFieldsAccess().UnlockExpFields();
-    if( !pClpDoc->getIDocumentFieldsAccess().IsExpFieldsLocked() )
-        pClpDoc->getIDocumentFieldsAccess().UpdateExpFields(nullptr, true);
+    rClpDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE );
+    rClpDoc.getIDocumentFieldsAccess().UnlockExpFields();
+    if( !rClpDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() )
+        rClpDoc.getIDocumentFieldsAccess().UpdateExpFields(nullptr, true);
 }
 
 static const Point &lcl_FindBasePos( const SwFrame *pFrame, const Point &rPt )
@@ -274,7 +272,7 @@ static bool lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrame
     return bRet;
 }
 
-bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
+bool SwFEShell::CopyDrawSel( SwFEShell& rDestShell, const Point& rSttPt,
                     const Point& rInsPt, bool bIsMove, bool bSelectInsert )
 {
     bool bRet = true;
@@ -282,17 +280,17 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
     // The list should be copied, because below new objects will be selected
     const SdrMarkList aMrkList( Imp()->GetDrawView()->GetMarkedObjectList() );
     const size_t nMarkCount = aMrkList.GetMarkCount();
-    if( !pDestShell->Imp()->GetDrawView() )
+    if( !rDestShell.Imp()->GetDrawView() )
         // should create it now
-        pDestShell->MakeDrawView();
+        rDestShell.MakeDrawView();
     else if( bSelectInsert )
-        pDestShell->Imp()->GetDrawView()->UnmarkAll();
+        rDestShell.Imp()->GetDrawView()->UnmarkAll();
 
-    SdrPageView *pDestPgView = pDestShell->Imp()->GetPageView(),
+    SdrPageView *pDestPgView = rDestShell.Imp()->GetPageView(),
                 *pSrcPgView = Imp()->GetPageView();
-    SwDrawView *pDestDrwView = pDestShell->Imp()->GetDrawView(),
+    SwDrawView *pDestDrwView = rDestShell.Imp()->GetDrawView(),
                 *pSrcDrwView = Imp()->GetDrawView();
-    SwDoc* pDestDoc = pDestShell->GetDoc();
+    SwDoc* pDestDoc = rDestShell.GetDoc();
 
     Size aSiz( rInsPt.X() - rSttPt.X(), rInsPt.Y() - rSttPt.Y() );
     for( size_t i = 0; i < nMarkCount; ++i )
@@ -331,7 +329,7 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
                 (RndStdIds::FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
                 (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
             {
-                if ( this == pDestShell )
+                if ( this == &rDestShell )
                 {
                     // same shell? Then request the position
                     // from the passed DocumentPosition
@@ -345,24 +343,24 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
                         bRet = false;
                     else
                         bRet = ::lcl_SetAnchor( aPos, *pNd, nullptr, rInsPt,
-                                *pDestShell, aAnchor, aNewAnch, false );
+                                rDestShell, aAnchor, aNewAnch, false );
                 }
                 else
                 {
-                    SwPaM *pCursor = pDestShell->GetCursor();
+                    SwPaM *pCursor = rDestShell.GetCursor();
                     if( pCursor->GetNode().IsNoTextNode() )
                         bRet = false;
                     else
                         bRet = ::lcl_SetAnchor( *pCursor->GetPoint(),
                                                 pCursor->GetNode(), nullptr, rInsPt,
-                                                *pDestShell, aAnchor,
+                                                rDestShell, aAnchor,
                                                 aNewAnch, false );
                 }
             }
             else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
             {
-                aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) );
-                const SwRootFrame* pTmpRoot = pDestShell->GetLayout();
+                aAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
+                const SwRootFrame* pTmpRoot = rDestShell.GetLayout();
                 const SwFrame* pPg = pTmpRoot->GetPageAtPos( rInsPt, nullptr, true );
                 if ( pPg )
                     aNewAnch = pPg->getFrameArea().Pos();
@@ -377,7 +375,7 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
                     aSet.Put( aAnchor );
                     SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
                                                 GetDoc() == pDestDoc );
-                    pFormat = pDestDoc->getIDocumentContentOperations().InsertDrawObj( *pDestShell->GetCursor(), *pNew, aSet );
+                    pFormat = pDestDoc->getIDocumentContentOperations().InsertDrawObj( *rDestShell.GetCursor(), *pNew, aSet );
                 }
                 else
                     pFormat = pDestDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true );
@@ -413,7 +411,7 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
 
     if ( bIsMove && bRet )
     {
-        if( pDestShell == this )
+        if( &rDestShell == this )
         {
             const SdrMarkList aList( pSrcDrwView->GetMarkedObjectList() );
             pSrcDrwView->UnmarkAll();
@@ -437,19 +435,18 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
     return bRet;
 }
 
-bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
+bool SwFEShell::Copy( SwFEShell& rDestShell, const Point& rSttPt,
                     const Point& rInsPt, bool bIsMove, bool bSelectInsert )
 {
     bool bRet = false;
 
-    OSL_ENSURE( pDestShell, "Copy without DestShell." );
-    OSL_ENSURE( this == pDestShell || !pDestShell->IsObjSelected(),
+    OSL_ENSURE( this == &rDestShell || !rDestShell.IsObjSelected(),
             "Dest-Shell cannot be in Obj-Mode" );
 
-    CurrShell aCurr( pDestShell );
+    CurrShell aCurr( &rDestShell );
 
-    pDestShell->StartAllAction();
-    pDestShell->GetDoc()->getIDocumentFieldsAccess().LockExpFields();
+    rDestShell.StartAllAction();
+    rDestShell.GetDoc()->getIDocumentFieldsAccess().LockExpFields();
 
     // Shift references
     bool bCopyIsMove = mxDoc->IsCopyIsMove();
@@ -457,13 +454,13 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
         // set a flag in Doc, handled in TextNodes
         mxDoc->SetCopyIsMove( true );
 
-    RedlineFlags eOldRedlMode = pDestShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
-    pDestShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode | RedlineFlags::DeleteRedlines );
+    RedlineFlags eOldRedlMode = rDestShell.GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
+    rDestShell.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode | RedlineFlags::DeleteRedlines );
 
     // If there are table formulas in the area, then display the table first
     // so that the table formula can calculate a new value first
     // (individual boxes in the area are retrieved via the layout)
-    SwFieldType* pTableFieldTyp = pDestShell->GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Table );
+    SwFieldType* pTableFieldTyp = rDestShell.GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Table );
 
     if( IsFrameSelected() )
     {
@@ -478,7 +475,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
             (RndStdIds::FLY_AT_FLY  == aAnchor.GetAnchorId()) ||
             (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
         {
-            if ( this == pDestShell )
+            if ( this == &rDestShell )
             {
                 // same shell? Then request the position
                 // from the passed DocumentPosition
@@ -501,24 +498,24 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
                     }
                     else
                         bRet = ::lcl_SetAnchor( aPos, *pNd, pFly, rInsPt,
-                                        *pDestShell, aAnchor, aNewAnch, true );
+                                        rDestShell, aAnchor, aNewAnch, true );
                 }
             }
             else
             {
-                const SwPaM *pCursor = pDestShell->GetCursor();
+                const SwPaM *pCursor = rDestShell.GetCursor();
                 if( pCursor->GetNode().IsNoTextNode() )
                     bRet = false;
                 else
                     bRet = ::lcl_SetAnchor( *pCursor->GetPoint(), pCursor->GetNode(),
-                                            pFly, rInsPt, *pDestShell, aAnchor,
-                                    aNewAnch, GetDoc() == pDestShell->GetDoc());
+                                            pFly, rInsPt, rDestShell, aAnchor,
+                                    aNewAnch, GetDoc() == rDestShell.GetDoc());
             }
         }
         else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
         {
-            aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) );
-            const SwRootFrame* pTmpRoot = pDestShell->GetLayout();
+            aAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
+            const SwRootFrame* pTmpRoot = rDestShell.GetLayout();
             const SwFrame* pPg = pTmpRoot->GetPageAtPos( rInsPt, nullptr, true );
             if ( pPg )
                 aNewAnch = pPg->getFrameArea().Pos();
@@ -530,7 +527,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
         if( bRet )
         {
             SwFrameFormat *pOldFormat = pFlyFormat;
-            pFlyFormat = pDestShell->GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
+            pFlyFormat = rDestShell.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
 
             if ( RndStdIds::FLY_AS_CHAR != aAnchor.GetAnchorId() )
             {
@@ -541,7 +538,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
                 pFlyFormat->SetFormatAttr( SwFormatVertOrient( aPos.getY(),text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
             }
 
-            const Point aPt( pDestShell->GetCursorDocPos() );
+            const Point aPt( rDestShell.GetCursorDocPos() );
 
             if( bIsMove )
                 GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( pOldFormat );
@@ -553,17 +550,17 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
                 if( pFlyFrame )
                 {
                     //JP 12.05.98: should this be in SelectFlyFrame???
-                    pDestShell->Imp()->GetDrawView()->UnmarkAll();
-                    pDestShell->SelectFlyFrame( *pFlyFrame );
+                    rDestShell.Imp()->GetDrawView()->UnmarkAll();
+                    rDestShell.SelectFlyFrame( *pFlyFrame );
                 }
             }
 
-            if (this != pDestShell && !pDestShell->HasShellFocus())
-                pDestShell->Imp()->GetDrawView()->hideMarkHandles();
+            if (this != &rDestShell && !rDestShell.HasShellFocus())
+                rDestShell.Imp()->GetDrawView()->hideMarkHandles();
         }
     }
     else if ( IsObjSelected() )
-        bRet = CopyDrawSel( pDestShell, rSttPt, rInsPt, bIsMove, bSelectInsert );
+        bRet = CopyDrawSel( rDestShell, rSttPt, rInsPt, bIsMove, bSelectInsert );
     else if( IsTableMode() )
     {
         // Copy parts from a table: create a table with the same
@@ -578,7 +575,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
         if (nullptr != pTableNd)
         {
             std::unique_ptr<SwPosition> pDstPos;
-            if( this == pDestShell )
+            if( this == &rDestShell )
             {
                 // same shell? Then create new Cursor at the
                 // DocumentPosition passed
@@ -588,33 +585,33 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
                 if( !pDstPos->nNode.GetNode().IsNoTextNode() )
                     bRet = true;
             }
-            else if( !pDestShell->GetCursor()->GetNode().IsNoTextNode() )
+            else if( !rDestShell.GetCursor()->GetNode().IsNoTextNode() )
             {
-                pDstPos.reset(new SwPosition( *pDestShell->GetCursor()->GetPoint() ));
+                pDstPos.reset(new SwPosition( *rDestShell.GetCursor()->GetPoint() ));
                 bRet = true;
             }
 
             if( bRet )
             {
-                if( GetDoc() == pDestShell->GetDoc() )
+                if( GetDoc() == rDestShell.GetDoc() )
                     ParkTableCursor();
 
-                bRet = pDestShell->GetDoc()->InsCopyOfTable( *pDstPos, aBoxes,nullptr,
-                                        bIsMove && this == pDestShell &&
+                bRet = rDestShell.GetDoc()->InsCopyOfTable( *pDstPos, aBoxes,nullptr,
+                                        bIsMove && this == &rDestShell &&
                                         aBoxes.size() == pTableNd->GetTable().
                                         GetTabSortBoxes().size(),
-                                        this != pDestShell );
+                                        this != &rDestShell );
 
-                if( this != pDestShell )
-                    *pDestShell->GetCursor()->GetPoint() = *pDstPos;
+                if( this != &rDestShell )
+                    *rDestShell.GetCursor()->GetPoint() = *pDstPos;
 
                 // create all parked Cursor?
-                if( GetDoc() == pDestShell->GetDoc() )
+                if( GetDoc() == rDestShell.GetDoc() )
                     GetCursor();
 
                 // JP 16.04.99: Bug 64908 - Set InsPos, to assure the parked
                 //              Cursor is positioned at the insert position
-                if( this == pDestShell )
+                if( this == &rDestShell )
                     GetCursorDocPos() = rInsPt;
             }
         }
@@ -622,7 +619,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
     else
     {
         bRet = true;
-        if( this == pDestShell )
+        if( this == &rDestShell )
         {
             // same shell? then request the position
             // at the passed document position
@@ -631,14 +628,14 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
             GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
             bRet = !aPos.nNode.GetNode().IsNoTextNode();
         }
-        else if( pDestShell->GetCursor()->GetNode().IsNoTextNode() )
+        else if( rDestShell.GetCursor()->GetNode().IsNoTextNode() )
             bRet = false;
 
         if( bRet )
-            bRet = SwEditShell::Copy( pDestShell );
+            bRet = SwEditShell::Copy( rDestShell );
     }
 
-    pDestShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode );
+    rDestShell.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode );
     mxDoc->SetCopyIsMove( bCopyIsMove );
 
     // have new table formulas been inserted?
@@ -647,16 +644,16 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
         // finish old actions: the table frames are created and
         // a selection can be made
         sal_uInt16 nActCnt;
-        for( nActCnt = 0; pDestShell->ActionPend(); ++nActCnt )
-            pDestShell->EndAllAction();
+        for( nActCnt = 0; rDestShell.ActionPend(); ++nActCnt )
+            rDestShell.EndAllAction();
 
         for( ; nActCnt; --nActCnt )
-            pDestShell->StartAllAction();
+            rDestShell.StartAllAction();
     }
-    pDestShell->GetDoc()->getIDocumentFieldsAccess().UnlockExpFields();
-    pDestShell->GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
+    rDestShell.GetDoc()->getIDocumentFieldsAccess().UnlockExpFields();
+    rDestShell.GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
 
-    pDestShell->EndAllAction();
+    rDestShell.EndAllAction();
     return bRet;
 }
 
@@ -673,12 +670,11 @@ namespace {
     }
 }
 
-bool SwFEShell::Paste( SwDoc* pClpDoc, bool bNestedTable )
+bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
 {
     CurrShell aCurr( this );
-    OSL_ENSURE( pClpDoc, "no clipboard document"  );
     // then till end of the nodes array
-    SwNodeIndex aIdx( pClpDoc->GetNodes().GetEndOfExtras(), 2 );
+    SwNodeIndex aIdx( rClpDoc.GetNodes().GetEndOfExtras(), 2 );
     SwPaM aCpyPam( aIdx ); //DocStart
 
     // If there are table formulas in the area, then display the table first
@@ -711,7 +707,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bNestedTable )
     // if there are more text portions to insert than cursor in this ring,
     // the additional insert positions will be created by moving the last
     // cursor position into the next line (like pressing the cursor down key)
-    if( pClpDoc->IsColumnSelection() && !IsTableMode() )
+    if( rClpDoc.IsColumnSelection() && !IsTableMode() )
     {
         // Creation of the list of insert positions
         std::vector< Insertion > aCopyVector;
@@ -799,7 +795,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bNestedTable )
             {
                 SwNodeIndex aIndexBefore(rInsPos.nNode);
                 --aIndexBefore;
-                pClpDoc->getIDocumentContentOperations().CopyRange(rCopy, rInsPos, SwCopyFlags::CheckPosInFly);
+                rClpDoc.getIDocumentContentOperations().CopyRange(rCopy, rInsPos, SwCopyFlags::CheckPosInFly);
                 {
                     ++aIndexBefore;
                     SwPaM aPaM(SwPosition(aIndexBefore),
@@ -885,13 +881,13 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bNestedTable )
                 break;      // exit the "while-loop"
             }
             else if( *aCpyPam.GetPoint() == *aCpyPam.GetMark() &&
-                 !pClpDoc->GetSpzFrameFormats()->empty() )
+                 !rClpDoc.GetSpzFrameFormats()->empty() )
             {
                 // we need a DrawView
                 if( !Imp()->GetDrawView() )
                     MakeDrawView();
 
-                for ( auto pCpyFormat : *pClpDoc->GetSpzFrameFormats() )
+                for ( auto pCpyFormat : *rClpDoc.GetSpzFrameFormats() )
                 {
                     bool bInsWithFormat = true;
 
@@ -1038,7 +1034,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bNestedTable )
 
                     --aIndexBefore;
 
-                    pClpDoc->getIDocumentContentOperations().CopyRange(aCpyPam, rInsPos, SwCopyFlags::CheckPosInFly);
+                    rClpDoc.getIDocumentContentOperations().CopyRange(aCpyPam, rInsPos, SwCopyFlags::CheckPosInFly);
                     // Note: aCpyPam is invalid now
 
                     ++aIndexBefore;
@@ -1134,7 +1130,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
     GetDoc()->getIDocumentFieldsAccess().LockExpFields();
     SetSelection(aCpyPam);
     // copy the text of the selection
-    SwEditShell::Copy(&rToFill);
+    SwEditShell::Copy(rToFill);
 
     if(pTableNode)
     {
diff --git a/sw/source/core/inc/UndoBookmark.hxx b/sw/source/core/inc/UndoBookmark.hxx
index 4246389aa756..68f47d204cf6 100644
--- a/sw/source/core/inc/UndoBookmark.hxx
+++ b/sw/source/core/inc/UndoBookmark.hxx
@@ -42,7 +42,7 @@ protected:
     SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& );
 
     void SetInDoc( SwDoc* );
-    void ResetInDoc( SwDoc* );
+    void ResetInDoc( SwDoc& );
 
 public:
     virtual ~SwUndoBookmark() override;
diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx
index 087ef74b58d2..295279fd9396 100644
--- a/sw/source/core/inc/rolbck.hxx
+++ b/sw/source/core/inc/rolbck.hxx
@@ -274,7 +274,7 @@ class SwHistoryNoTextFieldmark : public SwHistoryHint
     public:
         SwHistoryNoTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark);
         virtual void SetInDoc(SwDoc* pDoc, bool) override;
-        void ResetInDoc(SwDoc* pDoc);
+        void ResetInDoc(SwDoc& rDoc);
 
     private:
         const OUString m_sType;
@@ -289,7 +289,7 @@ class SwHistoryTextFieldmark : public SwHistoryHint
     public:
         SwHistoryTextFieldmark(const ::sw::mark::IFieldmark& rFieldMark);
         virtual void SetInDoc(SwDoc* pDoc, bool) override;
-        void ResetInDoc(SwDoc* pDoc);
+        void ResetInDoc(SwDoc& rDoc);
 
     private:
         const OUString m_sName;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 59c9cd2b367e..6202099748fc 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3396,7 +3396,7 @@ SwHandleAnchorNodeChg::~SwHandleAnchorNodeChg() COVERITY_NOEXCEPT_FALSE
     *mpWrtShell->GetCurrentShellCursor().GetPoint() = *rNewAnchorFormat.GetContentAnchor();
 
     // Move by copying and deleting.
-    mpWrtShell->SwEditShell::Copy(mpWrtShell);
+    mpWrtShell->SwEditShell::Copy(*mpWrtShell);
     mpWrtShell->DestroyCursor();
 
     mpWrtShell->Delete();
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index f8732386da21..d7464b6f58d2 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -745,11 +745,11 @@ void SwHistoryNoTextFieldmark::SetInDoc(SwDoc* pDoc, bool)
     }
 }
 
-void SwHistoryNoTextFieldmark::ResetInDoc(SwDoc* pDoc)
+void SwHistoryNoTextFieldmark::ResetInDoc(SwDoc& rDoc)
 {
-    ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
+    ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
 
-    SwNodes& rNds = pDoc->GetNodes();
+    SwNodes& rNds = rDoc.GetNodes();
     std::unique_ptr<SwPaM> pPam;
 
     const SwContentNode* pContentNd = rNds[m_nNode]->GetContentNode();
@@ -758,7 +758,7 @@ void SwHistoryNoTextFieldmark::ResetInDoc(SwDoc* pDoc)
 
     if (pPam)
     {
-        IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+        IDocumentMarkAccess* pMarkAccess = rDoc.getIDocumentMarkAccess();
         pMarkAccess->deleteFieldmarkAt(*pPam->GetPoint());
     }
 }
@@ -803,11 +803,11 @@ void SwHistoryTextFieldmark::SetInDoc(SwDoc* pDoc, bool)
     rMarksAccess.makeFieldBookmark(pam, m_sName, m_sType, &sepPos);
 }
 
-void SwHistoryTextFieldmark::ResetInDoc(SwDoc* pDoc)
+void SwHistoryTextFieldmark::ResetInDoc(SwDoc& rDoc)
 {
-    ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
+    ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
 
-    SwNodes& rNds = pDoc->GetNodes();
+    SwNodes& rNds = rDoc.GetNodes();
 
     assert(rNds[m_nStartNode]->IsContentNode());
     assert(rNds[m_nEndNode]->IsContentNode());
@@ -815,7 +815,7 @@ void SwHistoryTextFieldmark::ResetInDoc(SwDoc* pDoc)
 
     SwPosition const pos(*rNds[m_nStartNode]->GetContentNode(), m_nStartContent);
 
-    IDocumentMarkAccess & rMarksAccess(*pDoc->getIDocumentMarkAccess());
+    IDocumentMarkAccess & rMarksAccess(*rDoc.getIDocumentMarkAccess());
     rMarksAccess.deleteFieldmarkAt(pos);
 }
 
diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx
index cabcd02a5170..973f15566bba 100644
--- a/sw/source/core/undo/unbkmk.cxx
+++ b/sw/source/core/undo/unbkmk.cxx
@@ -46,9 +46,9 @@ void SwUndoBookmark::SetInDoc( SwDoc* pDoc )
     m_pHistoryBookmark->SetInDoc( pDoc, false );
 }
 
-void SwUndoBookmark::ResetInDoc( SwDoc* pDoc )
+void SwUndoBookmark::ResetInDoc( SwDoc& rDoc )
 {
-    IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
+    IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess();
     for ( IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getAllMarksBegin();
           ppBkmk != pMarkAccess->getAllMarksEnd();
           ++ppBkmk )
@@ -77,7 +77,7 @@ SwUndoInsBookmark::SwUndoInsBookmark( const ::sw::mark::IMark& rBkmk )
 
 void SwUndoInsBookmark::UndoImpl(::sw::UndoRedoContext & rContext)
 {
-    ResetInDoc( &rContext.GetDoc() );
+    ResetInDoc( rContext.GetDoc() );
 }
 
 void SwUndoInsBookmark::RedoImpl(::sw::UndoRedoContext & rContext)
@@ -97,7 +97,7 @@ void SwUndoDeleteBookmark::UndoImpl(::sw::UndoRedoContext & rContext)
 
 void SwUndoDeleteBookmark::RedoImpl(::sw::UndoRedoContext & rContext)
 {
-    ResetInDoc( &rContext.GetDoc() );
+    ResetInDoc( rContext.GetDoc() );
 }
 
 SwUndoRenameBookmark::SwUndoRenameBookmark( const OUString& rOldName, const OUString& rNewName, const SwDoc* pDoc )
@@ -155,7 +155,7 @@ SwUndoInsNoTextFieldmark::SwUndoInsNoTextFieldmark(const ::sw::mark::IFieldmark&
 
 void SwUndoInsNoTextFieldmark::UndoImpl(::sw::UndoRedoContext & rContext)
 {
-    m_pHistoryNoTextFieldmark->ResetInDoc(&rContext.GetDoc());
+    m_pHistoryNoTextFieldmark->ResetInDoc(rContext.GetDoc());
 }
 
 void SwUndoInsNoTextFieldmark::RedoImpl(::sw::UndoRedoContext & rContext)
@@ -178,7 +178,7 @@ void SwUndoDelNoTextFieldmark::UndoImpl(::sw::UndoRedoContext & rContext)
 
 void SwUndoDelNoTextFieldmark::RedoImpl(::sw::UndoRedoContext & rContext)
 {
-    m_pHistoryNoTextFieldmark->ResetInDoc(&rContext.GetDoc());
+    m_pHistoryNoTextFieldmark->ResetInDoc(rContext.GetDoc());
 }
 
 SwUndoInsTextFieldmark::SwUndoInsTextFieldmark(const ::sw::mark::IFieldmark& rFieldmark)
@@ -189,7 +189,7 @@ SwUndoInsTextFieldmark::SwUndoInsTextFieldmark(const ::sw::mark::IFieldmark& rFi
 
 void SwUndoInsTextFieldmark::UndoImpl(::sw::UndoRedoContext & rContext)
 {
-    m_pHistoryTextFieldmark->ResetInDoc(&rContext.GetDoc());
+    m_pHistoryTextFieldmark->ResetInDoc(rContext.GetDoc());
 }
 
 void SwUndoInsTextFieldmark::RedoImpl(::sw::UndoRedoContext & rContext)
@@ -212,7 +212,7 @@ void SwUndoDelTextFieldmark::UndoImpl(::sw::UndoRedoContext & rContext)
 
 void SwUndoDelTextFieldmark::RedoImpl(::sw::UndoRedoContext & rContext)
 {
-    m_pHistoryTextFieldmark->ResetInDoc(&rContext.GetDoc());
+    m_pHistoryTextFieldmark->ResetInDoc(rContext.GetDoc());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 666ed4a3dd57..8bc55cc0487e 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -502,9 +502,9 @@ static void SortSubranges( uno::Sequence< OUString > &rSubRanges, bool bCmpByCol
     }
 }
 
-SwChartDataProvider::SwChartDataProvider( const SwDoc* pSwDoc ) :
+SwChartDataProvider::SwChartDataProvider( const SwDoc& rSwDoc ) :
     m_aEventListeners( GetChartMutex() ),
-    m_pDoc( pSwDoc )
+    m_pDoc( &rSwDoc )
 {
     m_bDisposed = false;
 }
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 08897174b970..be02dcfce5d8 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -373,7 +373,7 @@ void SwViewShell::FillPrtDoc( SwDoc& rPrtDoc, const SfxPrinter* pPrt)
     }
 
     // fill it with the selected content
-    pFESh->Copy( &rPrtDoc );
+    pFESh->Copy(rPrtDoc);
 
     // set the page style at the first paragraph
     {
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 47027b764e1e..b41601be1ea5 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -395,7 +395,7 @@ namespace
         //by the selection, e.g. apply SwDoc::IsUsed on styles ?
         rDest.ReplaceStyles(rSrc, false);
 
-        rSrcWrtShell.Copy(&rDest);
+        rSrcWrtShell.Copy(rDest);
 
         rDest.GetMetaFieldManager().copyDocumentProperties(rSrc);
     }
@@ -892,7 +892,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
 
         m_pClpDocFac.reset(new SwDocFac);
         SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
-        m_pWrtShell->Copy( &rDoc );
+        m_pWrtShell->Copy(rDoc);
 
 #if HAVE_FEATURE_DESKTOP
         if (m_pOrigGraphic && !m_pOrigGraphic->GetBitmapEx().IsEmpty())
@@ -920,7 +920,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
         SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
         m_aDocShellRef = new SwDocShell(rDoc, SfxObjectCreateMode::EMBEDDED);
         m_aDocShellRef->DoInitNew();
-        m_pWrtShell->Copy(&rDoc);
+        m_pWrtShell->Copy(rDoc);
 
         AddFormat( SotClipboardFormatId::EMBED_SOURCE );
 
@@ -1147,7 +1147,7 @@ void SwTransferable::CalculateAndCopy()
 
     m_pClpDocFac.reset(new SwDocFac);
     SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
-    m_pWrtShell->Copy(&rDoc, & aStr);
+    m_pWrtShell->Copy(rDoc, &aStr);
     m_eBufferType = TransferBufferType::Document;
     AddFormat( SotClipboardFormatId::STRING );
 
@@ -3751,7 +3751,7 @@ bool SwTransferable::PrivatePaste(SwWrtShell& rShell, SwPasteContext* pContext,
     bool bRet = true;
     // m_pWrtShell is nullptr when the source document is closed already.
     if (!m_pWrtShell || lcl_checkClassification(m_pWrtShell->GetDoc(), rShell.GetDoc()))
-        bRet = rShell.Paste(&m_pClpDocFac->GetDoc(), ePasteTable == PasteTableType::PASTE_TABLE);
+        bRet = rShell.Paste(m_pClpDocFac->GetDoc(), ePasteTable == PasteTableType::PASTE_TABLE);
 
     if( bKillPaMs )
         rShell.KillPams();
@@ -3995,8 +3995,8 @@ bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
         aSttPt = rSrcSh.GetObjRect().Pos();
     }
 
-    bool bRet = rSrcSh.SwFEShell::Copy( &rSh, aSttPt, rDragPt, bMove,
-                                            !bIsXSelection );
+    bool bRet = rSrcSh.SwFEShell::Copy(rSh, aSttPt, rDragPt, bMove,
+                                       !bIsXSelection);
 
     if( !bIsXSelection )
     {
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 69d7d6b60b38..ea103fa2bfac 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4624,7 +4624,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                         if ( aSttPt != aEndPt )
                         {
                             rSh.StartUndo( SwUndoId::UI_DRAG_AND_COPY );
-                            rSh.Copy(&rSh, aSttPt, aEndPt);
+                            rSh.Copy(rSh, aSttPt, aEndPt);
                             rSh.EndUndo( SwUndoId::UI_DRAG_AND_COPY );
                         }
                     }


More information about the Libreoffice-commits mailing list