[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 14 15:46:55 UTC 2019


 sc/inc/scmod.hxx                                               |    2 
 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx |    4 -
 sc/source/ui/StatisticsDialogs/SamplingDialog.cxx              |    6 -
 sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx |    6 -
 sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx |    8 +-
 sc/source/ui/app/inputhdl.cxx                                  |   16 ++---
 sc/source/ui/app/scmod.cxx                                     |    6 -
 sc/source/ui/condformat/condformatdlg.cxx                      |    2 
 sc/source/ui/dbgui/PivotLayoutDialog.cxx                       |   32 +++++-----
 sc/source/ui/dbgui/consdlg.cxx                                 |    8 +-
 sc/source/ui/dbgui/dbnamdlg.cxx                                |    4 -
 sc/source/ui/dbgui/filtdlg.cxx                                 |    4 -
 sc/source/ui/dbgui/sfiltdlg.cxx                                |    8 +-
 sc/source/ui/dbgui/validate.cxx                                |    4 -
 sc/source/ui/formdlg/formula.cxx                               |    8 +-
 sc/source/ui/inc/IAnyRefDialog.hxx                             |    2 
 sc/source/ui/inc/PivotLayoutDialog.hxx                         |    4 -
 sc/source/ui/inc/RandomNumberGeneratorDialog.hxx               |    2 
 sc/source/ui/inc/SamplingDialog.hxx                            |    2 
 sc/source/ui/inc/StatisticsInputOutputDialog.hxx               |    2 
 sc/source/ui/inc/StatisticsTwoVariableDialog.hxx               |    2 
 sc/source/ui/inc/anyrefdg.hxx                                  |    2 
 sc/source/ui/inc/areasdlg.hxx                                  |    2 
 sc/source/ui/inc/condformatdlg.hxx                             |    2 
 sc/source/ui/inc/consdlg.hxx                                   |    2 
 sc/source/ui/inc/crnrdlg.hxx                                   |    2 
 sc/source/ui/inc/dbnamdlg.hxx                                  |    2 
 sc/source/ui/inc/filtdlg.hxx                                   |    4 -
 sc/source/ui/inc/formula.hxx                                   |    2 
 sc/source/ui/inc/highred.hxx                                   |    2 
 sc/source/ui/inc/inputhdl.hxx                                  |    2 
 sc/source/ui/inc/namedefdlg.hxx                                |    2 
 sc/source/ui/inc/namedlg.hxx                                   |    2 
 sc/source/ui/inc/optsolver.hxx                                 |    2 
 sc/source/ui/inc/simpref.hxx                                   |    2 
 sc/source/ui/inc/solvrdlg.hxx                                  |    2 
 sc/source/ui/inc/tabopdlg.hxx                                  |    2 
 sc/source/ui/inc/validate.hxx                                  |   10 +--
 sc/source/ui/inc/xmlsourcedlg.hxx                              |    2 
 sc/source/ui/miscdlgs/anyrefdg.cxx                             |    2 
 sc/source/ui/miscdlgs/crnrdlg.cxx                              |    2 
 sc/source/ui/miscdlgs/highred.cxx                              |    4 -
 sc/source/ui/miscdlgs/optsolver.cxx                            |    8 +-
 sc/source/ui/miscdlgs/simpref.cxx                              |    6 -
 sc/source/ui/miscdlgs/solvrdlg.cxx                             |    4 -
 sc/source/ui/miscdlgs/tabopdlg.cxx                             |   10 +--
 sc/source/ui/namedlg/namedefdlg.cxx                            |    6 -
 sc/source/ui/namedlg/namedlg.cxx                               |    6 -
 sc/source/ui/pagedlg/areasdlg.cxx                              |    2 
 sc/source/ui/view/gridwin.cxx                                  |    2 
 sc/source/ui/view/tabcont.cxx                                  |    2 
 sc/source/ui/view/tabview4.cxx                                 |    4 -
 sc/source/ui/xmlsource/xmlsourcedlg.cxx                        |    4 -
 53 files changed, 120 insertions(+), 120 deletions(-)

New commits:
commit 80ee721c64014b373bbdbdd1fbf14e003dbd142f
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 14 12:24:56 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 14 16:45:17 2019 +0100

    mpDocument is assumed to be non-null
    
    Change-Id: I2ca91a1baf2c34b89b972871025c4039f0eea85b
    Reviewed-on: https://gerrit.libreoffice.org/82683
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index e86ad9970685..f5011412bb03 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -74,9 +74,9 @@ ScPivotLayoutDialog::ScPivotLayoutDialog(
     , maPivotTableObject(*pPivotTableObject)
     , mpPreviouslyFocusedListBox(nullptr)
     , mpViewData(pViewData)
-    , mpDocument(pViewData->GetDocument())
+    , mrDocument(*pViewData->GetDocument())
     , mbNewPivotTable(bNewPivotTable)
-    , maAddressDetails(mpDocument->GetAddressConvention(), 0, 0)
+    , maAddressDetails(mrDocument.GetAddressConvention(), 0, 0)
     , mbDialogLostFocus(false)
     , mpActiveEdit(nullptr)
     , mxListBoxField(new ScPivotLayoutTreeListLabel(m_xBuilder->weld_tree_view("listbox-fields")))
@@ -210,7 +210,7 @@ void ScPivotLayoutDialog::SetupSource()
         }
         else
         {
-            OUString aSourceRangeName = aSourceRange.Format(ScRefFlags::RANGE_ABS_3D, mpDocument, maAddressDetails);
+            OUString aSourceRangeName = aSourceRange.Format(ScRefFlags::RANGE_ABS_3D, &mrDocument, maAddressDetails);
             mxSourceEdit->SetText(aSourceRangeName);
         }
     }
@@ -225,7 +225,7 @@ void ScPivotLayoutDialog::SetupSource()
     // Setup Named Ranges
     bool bIsNamedRange = false;
 
-    ScAreaNameIterator aIterator(mpDocument);
+    ScAreaNameIterator aIterator(&mrDocument);
     OUString aEachName;
     ScRange aEachRange;
 
@@ -265,7 +265,7 @@ void ScPivotLayoutDialog::SetupDestination()
     mxDestinationListBox->clear();
 
     // Fill up named ranges
-    ScAreaNameIterator aIterator(mpDocument);
+    ScAreaNameIterator aIterator(&mrDocument);
     OUString aName;
     ScRange aRange;
 
@@ -293,7 +293,7 @@ void ScPivotLayoutDialog::SetupDestination()
         if (maPivotParameters.nTab != MAXTAB + 1)
         {
             ScAddress aAddress(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
-            OUString aAddressString = aAddress.Format(ScRefFlags::ADDR_ABS_3D, mpDocument, maAddressDetails);
+            OUString aAddressString = aAddress.Format(ScRefFlags::ADDR_ABS_3D, &mrDocument, maAddressDetails);
             mxDestinationEdit->SetText(aAddressString);
             mxDestinationRadioSelection->set_active(true);
         }
@@ -398,7 +398,7 @@ void ScPivotLayoutDialog::UpdateSourceRange()
     if (mxSourceRadioNamedRange->get_active())
     {
         OUString aEntryString = mxSourceListBox->get_active_text();
-        ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, mpDocument);
+        ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, &mrDocument);
         if (!aSourceRange.IsValid() || aSourceSheet.GetSourceRange() == aSourceRange)
             return;
         aSourceSheet.SetRangeName(aEntryString);
@@ -407,7 +407,7 @@ void ScPivotLayoutDialog::UpdateSourceRange()
     {
         OUString aSourceString = mxSourceEdit->GetText();
         ScRange aSourceRange;
-        ScRefFlags nResult = aSourceRange.Parse(aSourceString, mpDocument, maAddressDetails);
+        ScRefFlags nResult = aSourceRange.Parse(aSourceString, &mrDocument, maAddressDetails);
 
         bool bIsValid = (nResult & ScRefFlags::VALID) == ScRefFlags::VALID; // aSourceString is valid
 
@@ -418,13 +418,13 @@ void ScPivotLayoutDialog::UpdateSourceRange()
             ScRefAddress aStart;
             ScRefAddress aEnd;
 
-            ConvertDoubleRef(mpDocument, aSourceString, 1, aStart, aEnd, maAddressDetails);
+            ConvertDoubleRef(&mrDocument, aSourceString, 1, aStart, aEnd, maAddressDetails);
             aSourceRange.aStart = aStart.GetAddress();
             aSourceRange.aEnd = aEnd.GetAddress();
         }
         else
         {
-            aSourceRange = lclGetRangeForNamedRange(aSourceString, mpDocument);
+            aSourceRange = lclGetRangeForNamedRange(aSourceString, &mrDocument);
         }
 
         if (!aSourceRange.IsValid())
@@ -461,7 +461,7 @@ void ScPivotLayoutDialog::ApplyChanges()
     ApplySaveData(aSaveData);
     ApplyLabelData(aSaveData);
 
-    ScDPObject *pOldDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+    ScDPObject *pOldDPObj = mrDocument.GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
     ScRange aDestinationRange;
     bool bToNewSheet = false;
 
@@ -494,7 +494,7 @@ void ScPivotLayoutDialog::ApplyChanges()
             if ( ( ( rOldRange != aDestinationRange ) && !rOldRange.In( aDestinationRange ) )
                  || bToNewSheet )
             {
-                pDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+                pDPObj = mrDocument.GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
             }
             if (pDPObj)
             {
@@ -583,14 +583,14 @@ bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNe
     if (mxDestinationRadioNamedRange->get_active())
     {
         OUString aName = mxDestinationListBox->get_active_text();
-        aDestinationRange = lclGetRangeForNamedRange(aName, mpDocument);
+        aDestinationRange = lclGetRangeForNamedRange(aName, &mrDocument);
         if (!aDestinationRange.IsValid())
             return false;
     }
     else if (mxDestinationRadioSelection->get_active())
     {
         ScAddress aAddress;
-        aAddress.Parse(mxDestinationEdit->GetText(), mpDocument, maAddressDetails);
+        aAddress.Parse(mxDestinationEdit->GetText(), &mrDocument, maAddressDetails);
         aDestinationRange = ScRange(aAddress);
     }
     else
diff --git a/sc/source/ui/inc/PivotLayoutDialog.hxx b/sc/source/ui/inc/PivotLayoutDialog.hxx
index 4dda18a06193..a01a8de02dff 100644
--- a/sc/source/ui/inc/PivotLayoutDialog.hxx
+++ b/sc/source/ui/inc/PivotLayoutDialog.hxx
@@ -41,7 +41,7 @@ public:
 
 private:
     ScViewData* mpViewData;
-    ScDocument* const mpDocument;
+    ScDocument& mrDocument;
 
     bool const mbNewPivotTable;
 
commit 914f9ee7bf7254f2f469bde4cf4c151a4ab25110
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 14 12:20:05 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 14 16:44:57 2019 +0100

    SetReference ScDocument arg is never null
    
    Change-Id: Ifdfe305e5319926d804e14962e786389b79fe476
    Reviewed-on: https://gerrit.libreoffice.org/82682
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index e214771bd2e4..adae2196df5a 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -225,7 +225,7 @@ public:
     bool                IsFormulaMode();
     bool                IsRefDialogOpen();
     bool                IsTableLocked();
-    void                SetReference( const ScRange& rRef, ScDocument* pDoc,
+    void                SetReference( const ScRange& rRef, ScDocument& rDoc,
                                         const ScMarkData* pMarkData = nullptr );
     void                AddRefEntry();
     void                EndReference();
diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
index fcde4b6c59ae..9a7673450570 100644
--- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
@@ -130,7 +130,7 @@ void ScRandomNumberGeneratorDialog::Close()
     DoClose( ScRandomNumberGeneratorDialogWrapper::GetChildWindowId() );
 }
 
-void ScRandomNumberGeneratorDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDoc )
+void ScRandomNumberGeneratorDialog::SetReference( const ScRange& rReferenceRange, ScDocument& rDoc )
 {
     if (mxInputRangeEdit->GetWidget()->get_sensitive())
     {
@@ -139,7 +139,7 @@ void ScRandomNumberGeneratorDialog::SetReference( const ScRange& rReferenceRange
 
         maInputRange = rReferenceRange;
 
-        OUString aReferenceString(maInputRange.Format(ScRefFlags::RANGE_ABS_3D, pDoc, pDoc->GetAddressConvention()));
+        OUString aReferenceString(maInputRange.Format(ScRefFlags::RANGE_ABS_3D, &rDoc, rDoc.GetAddressConvention()));
         mxInputRangeEdit->SetRefString( aReferenceString );
 
         mxButtonApply->set_sensitive(true);
diff --git a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
index 85dc8cb9a0d0..7600ec78830c 100644
--- a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
@@ -126,7 +126,7 @@ void ScSamplingDialog::Close()
     DoClose( ScSamplingDialogWrapper::GetChildWindowId() );
 }
 
-void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
+void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument& rDocument )
 {
     if ( mpActiveEdit )
     {
@@ -138,7 +138,7 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument*
         if ( mpActiveEdit == mxInputRangeEdit.get() )
         {
             mInputRange = rReferenceRange;
-            aReferenceString = mInputRange.Format(ScRefFlags::RANGE_ABS_3D, pDocument, mAddressDetails);
+            aReferenceString = mInputRange.Format(ScRefFlags::RANGE_ABS_3D, &rDocument, mAddressDetails);
             mxInputRangeEdit->SetRefString( aReferenceString );
 
             LimitSampleSizeAndPeriod();
@@ -150,7 +150,7 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument*
             ScRefFlags nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ?
                                                              ScRefFlags::ADDR_ABS :
                                                              ScRefFlags::ADDR_ABS_3D;
-            aReferenceString = mOutputAddress.Format(nFormat, pDocument, pDocument->GetAddressConvention());
+            aReferenceString = mOutputAddress.Format(nFormat, &rDocument, rDocument.GetAddressConvention());
             mxOutputRangeEdit->SetRefString( aReferenceString );
 
             // Change sampling size according to output range selection
diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
index ee017c67254d..fcb9666678da 100644
--- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
@@ -137,7 +137,7 @@ void ScStatisticsInputOutputDialog::SetActive()
     RefInputDone();
 }
 
-void ScStatisticsInputOutputDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
+void ScStatisticsInputOutputDialog::SetReference( const ScRange& rReferenceRange, ScDocument& rDocument )
 {
     if ( mpActiveEdit )
     {
@@ -149,7 +149,7 @@ void ScStatisticsInputOutputDialog::SetReference( const ScRange& rReferenceRange
         if (mpActiveEdit == mxInputRangeEdit.get())
         {
             mInputRange = rReferenceRange;
-            aReferenceString = mInputRange.Format(ScRefFlags::RANGE_ABS_3D, pDocument, mAddressDetails);
+            aReferenceString = mInputRange.Format(ScRefFlags::RANGE_ABS_3D, &rDocument, mAddressDetails);
             mxInputRangeEdit->SetRefString( aReferenceString );
         }
         else if (mpActiveEdit == mxOutputRangeEdit.get())
@@ -159,7 +159,7 @@ void ScStatisticsInputOutputDialog::SetReference( const ScRange& rReferenceRange
             ScRefFlags nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ?
                                                              ScRefFlags::ADDR_ABS :
                                                              ScRefFlags::ADDR_ABS_3D;
-            aReferenceString = mOutputAddress.Format(nFormat, pDocument, pDocument->GetAddressConvention());
+            aReferenceString = mOutputAddress.Format(nFormat, &rDocument, rDocument.GetAddressConvention());
             mxOutputRangeEdit->SetRefString( aReferenceString );
         }
     }
diff --git a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx
index f7794b5381df..fb0b34d6be4f 100644
--- a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx
@@ -143,7 +143,7 @@ void ScStatisticsTwoVariableDialog::SetActive()
     RefInputDone();
 }
 
-void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
+void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange, ScDocument& rDocument )
 {
     if ( mpActiveEdit != nullptr )
     {
@@ -155,13 +155,13 @@ void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange
         if ( mpActiveEdit == mxVariable1RangeEdit.get() )
         {
             mVariable1Range = rReferenceRange;
-            aReferenceString = mVariable1Range.Format(ScRefFlags::RANGE_ABS_3D, pDocument, mAddressDetails);
+            aReferenceString = mVariable1Range.Format(ScRefFlags::RANGE_ABS_3D, &rDocument, mAddressDetails);
             mxVariable1RangeEdit->SetRefString(aReferenceString);
         }
         else if ( mpActiveEdit == mxVariable2RangeEdit.get() )
         {
             mVariable2Range = rReferenceRange;
-            aReferenceString = mVariable2Range.Format(ScRefFlags::RANGE_ABS_3D, pDocument, mAddressDetails);
+            aReferenceString = mVariable2Range.Format(ScRefFlags::RANGE_ABS_3D, &rDocument, mAddressDetails);
             mxVariable2RangeEdit->SetRefString(aReferenceString);
         }
         else if ( mpActiveEdit == mxOutputRangeEdit.get() )
@@ -171,7 +171,7 @@ void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange
             ScRefFlags nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ?
                                                              ScRefFlags::ADDR_ABS :
                                                              ScRefFlags::ADDR_ABS_3D;
-            aReferenceString = mOutputAddress.Format(nFormat, pDocument, pDocument->GetAddressConvention());
+            aReferenceString = mOutputAddress.Format(nFormat, &rDocument, rDocument.GetAddressConvention());
             mxOutputRangeEdit->SetRefString( aReferenceString );
         }
     }
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 7556ef49d1ac..8f9e7fd9b733 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3182,20 +3182,20 @@ void ScInputHandler::AddRefEntry()
     DataChanged();
 }
 
-void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument* pDoc )
+void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument& rDoc )
 {
     HideTip();
 
     const ScDocument* pThisDoc = nullptr;
-    bool bOtherDoc = (pRefViewSh && ((pThisDoc = pRefViewSh->GetViewData().GetDocument()) != pDoc));
-    if (bOtherDoc && !pDoc->GetDocumentShell()->HasName())
+    bool bOtherDoc = (pRefViewSh && ((pThisDoc = pRefViewSh->GetViewData().GetDocument()) != &rDoc));
+    if (bOtherDoc && !rDoc.GetDocumentShell()->HasName())
     {
         // References to unnamed document; that doesn't work
         // SetReference should not be called, then
         return;
     }
     if (!pThisDoc)
-        pThisDoc = pDoc;
+        pThisDoc = &rDoc;
 
     UpdateActiveView();
     if (!pTableView && !pTopView)
@@ -3239,9 +3239,9 @@ void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument* pDoc )
         OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
 
         // Always 3D and absolute.
-        OUString aTmp(rRef.Format( ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, pDoc, aAddrDetails));
+        OUString aTmp(rRef.Format( ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, &rDoc, aAddrDetails));
 
-        SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+        SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
         // #i75893# convert escaped URL of the document to something user friendly
         OUString aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::Unambiguous );
 
@@ -3264,9 +3264,9 @@ void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument* pDoc )
         if ( rRef.aStart.Tab() != aCursorPos.Tab() ||
              rRef.aStart.Tab() != rRef.aEnd.Tab() )
             // pointer-selected => absolute sheet reference
-            aRefStr = rRef.Format(ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, pDoc, aAddrDetails);
+            aRefStr = rRef.Format(ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, &rDoc, aAddrDetails);
         else
-            aRefStr = rRef.Format(ScRefFlags::VALID, pDoc, aAddrDetails);
+            aRefStr = rRef.Format(ScRefFlags::VALID, &rDoc, aAddrDetails);
     }
 
     if (pTableView || pTopView)
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 739d13322051..dfc13e4a0b8f 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1668,7 +1668,7 @@ static void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rE
     }
 }
 
-void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
+void ScModule::SetReference( const ScRange& rRef, ScDocument& rDoc,
                                     const ScMarkData* pMarkData )
 {
     //TODO: Move reference dialog handling to view
@@ -1702,7 +1702,7 @@ void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
                     // hide the (color) selection now instead of later from LoseFocus,
                     // don't abort the ref input that causes this call (bDoneRefMode = sal_False)
                     pRefDlg->HideReference( false );
-                    pRefDlg->SetReference( aNew, pDoc );
+                    pRefDlg->SetReference( aNew, rDoc );
                 }
             }
         }
@@ -1711,7 +1711,7 @@ void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
     {
         ScInputHandler* pHdl = GetInputHdl();
         if (pHdl)
-            pHdl->SetReference( aNew, pDoc );
+            pHdl->SetReference( aNew, rDoc );
         else
         {
             OSL_FAIL("SetReference without receiver");
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 9a86807f70ee..6b29156e47f4 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -529,7 +529,7 @@ bool ScCondFormatDlg::IsRefInputMode() const
     return mxEdRange->GetWidget()->get_sensitive();
 }
 
-void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*)
+void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument&)
 {
     formula::RefEdit* pEdit = mpLastEdit;
     if (!mpLastEdit)
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index d9b89a5fadf2..e86ad9970685 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -331,7 +331,7 @@ void ScPivotLayoutDialog::SetActive()
     RefInputDone();
 }
 
-void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocument* pDocument)
+void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocument& rDocument)
 {
     if (!mbDialogLostFocus)
         return;
@@ -342,7 +342,7 @@ void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocumen
     if (rReferenceRange.aStart != rReferenceRange.aEnd)
         RefInputStart(mpActiveEdit);
 
-    OUString aReferenceString = rReferenceRange.Format(ScRefFlags::RANGE_ABS_3D, pDocument, maAddressDetails);
+    OUString aReferenceString = rReferenceRange.Format(ScRefFlags::RANGE_ABS_3D, &rDocument, maAddressDetails);
 
     if (mpActiveEdit == mxSourceEdit.get())
     {
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
index 3378a92f8bb8..a7cf9b1d6589 100644
--- a/sc/source/ui/dbgui/consdlg.cxx
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -229,7 +229,7 @@ void ScConsolidateDlg::FillAreaLists()
 // Handover of a range within a table that has been selected by the mouse.
 // This range is then shown in the reference window as new selection.
 
-void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if ( m_pRefInputEdit )
     {
@@ -238,15 +238,15 @@ void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 
         OUString      aStr;
         ScRefFlags      nFmt = ScRefFlags::RANGE_ABS_3D;       //!!! nCurTab is still missing
-        const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+        const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention();
 
         if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
             nFmt |= ScRefFlags::TAB2_3D;
 
         if ( m_pRefInputEdit == m_xEdDataArea.get())
-            aStr = rRef.Format(nFmt, pDocP, eConv);
+            aStr = rRef.Format(nFmt, &rDocP, eConv);
         else if ( m_pRefInputEdit == m_xEdDestArea.get() )
-            aStr = rRef.aStart.Format(nFmt, pDocP, eConv);
+            aStr = rRef.aStart.Format(nFmt, &rDocP, eConv);
 
         m_pRefInputEdit->SetRefString( aStr );
         ModifyHdl( *m_pRefInputEdit );
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index 6f0b35506817..5f7ad383c979 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -275,7 +275,7 @@ void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
 // Transfer of a table area selected with the mouse, which is then displayed
 // as a new selection in the reference window.
 
-void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_xEdAssign->GetWidget()->get_sensitive())
     {
@@ -284,7 +284,7 @@ void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 
         theCurArea = rRef;
 
-        OUString aRefStr(theCurArea.Format(ScRefFlags::RANGE_ABS_3D, pDocP, aAddrDetails));
+        OUString aRefStr(theCurArea.Format(ScRefFlags::RANGE_ABS_3D, &rDocP, aAddrDetails));
         m_xEdAssign->SetRefString( aRefStr );
         m_xOptions->set_sensitive(true);
         m_xBtnAdd->set_sensitive(true);
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 9ee84fc714cd..addfedbe0f4c 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -357,13 +357,13 @@ void ScFilterDlg::Close()
 // Mouse-selected cell area becomes the new selection and is shown in the
 // reference text box
 
-void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if ( bRefInputMode )    // Only possible if in reference edit mode
     {
         if ( rRef.aStart != rRef.aEnd )
             RefInputStart( m_xEdCopyArea.get() );
-        OUString aRefStr(rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, pDocP, pDocP->GetAddressConvention()));
+        OUString aRefStr(rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, rDocP.GetAddressConvention()));
         m_xEdCopyArea->SetRefString( aRefStr );
     }
 }
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index 53045ebf0725..3b5d8ff55b81 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -196,7 +196,7 @@ void ScSpecialFilterDlg::Close()
 // Transfer of a table area selected with the mouse, which is then displayed
 // as a new selection in the reference edit.
 
-void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if ( bRefInputMode && m_pRefInputEdit )       // only possible if in the reference edit mode
     {
@@ -204,12 +204,12 @@ void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
             RefInputStart( m_pRefInputEdit );
 
         OUString aRefStr;
-        const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+        const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention();
 
         if (m_pRefInputEdit == m_xEdCopyArea.get())
-            aRefStr = rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, pDocP, eConv);
+            aRefStr = rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, eConv);
         else if (m_pRefInputEdit == m_xEdFilterArea.get())
-            aRefStr = rRef.Format(ScRefFlags::RANGE_ABS_3D, pDocP, eConv);
+            aRefStr = rRef.Format(ScRefFlags::RANGE_ABS_3D, &rDocP, eConv);
 
         m_pRefInputEdit->SetRefString( aRefStr );
     }
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index 41bc913db911..84de0b56b862 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -101,7 +101,7 @@ ScValidationDlg::~ScValidationDlg()
         RemoveRefDlg(false);
 }
 
-void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , const ScDocument* pDoc )
+void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , const ScDocument& rDoc )
 {
     if ( rRange.aStart != rRange.aEnd )
         if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
@@ -110,7 +110,7 @@ void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , const ScDocume
 
     if ( m_pRefEdit )
     {
-        OUString aStr(rRange.Format(ScRefFlags::RANGE_ABS_3D, pDoc, pDoc->GetAddressConvention()));
+        OUString aStr(rRange.Format(ScRefFlags::RANGE_ABS_3D, &rDoc, rDoc.GetAddressConvention()));
         m_pRefEdit->SetRefString( aStr );
     }
 }
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 697d407d6f4f..fa876f5cfed2 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -389,7 +389,7 @@ void ScFormulaDlg::RefInputDone( bool bForced )
     RefInputDoneAfter( bForced );
 }
 
-void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
+void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
 {
     const IFunctionDescription* pFunc = getCurrentFunctionDescription();
     if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
@@ -403,7 +403,7 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
         }
 
         OUString      aRefStr;
-        bool bOtherDoc = (pRefDoc != m_pDoc && pRefDoc->GetDocumentShell()->HasName());
+        bool bOtherDoc = (&rRefDoc != m_pDoc && rRefDoc.GetDocumentShell()->HasName());
         if ( bOtherDoc )
         {
             //  reference to other document - like inputhdl.cxx
@@ -411,9 +411,9 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
             OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
 
             // Always 3D and absolute.
-            OUString aTmp( rRef.Format( ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, pRefDoc));
+            OUString aTmp( rRef.Format( ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D, &rRefDoc));
 
-            SfxObjectShell* pObjSh = pRefDoc->GetDocumentShell();
+            SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
 
             // #i75893# convert escaped URL of the document to something user friendly
 //           OUString aFileName = pObjSh->GetMedium()->GetName();
diff --git a/sc/source/ui/inc/IAnyRefDialog.hxx b/sc/source/ui/inc/IAnyRefDialog.hxx
index a9c876f15f0d..57d6004c8444 100644
--- a/sc/source/ui/inc/IAnyRefDialog.hxx
+++ b/sc/source/ui/inc/IAnyRefDialog.hxx
@@ -34,7 +34,7 @@ class SAL_NO_VTABLE IAnyRefDialog : public formula::IControlReferenceHandler
 public:
     virtual ~IAnyRefDialog() COVERITY_NOEXCEPT_FALSE {}
 
-    virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
+    virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) = 0;
     virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) = 0;
     virtual void RefInputDone( bool bForced = false ) = 0;
     virtual bool IsTableLocked() const = 0;
diff --git a/sc/source/ui/inc/PivotLayoutDialog.hxx b/sc/source/ui/inc/PivotLayoutDialog.hxx
index 7397972a7ada..4dda18a06193 100644
--- a/sc/source/ui/inc/PivotLayoutDialog.hxx
+++ b/sc/source/ui/inc/PivotLayoutDialog.hxx
@@ -117,7 +117,7 @@ public:
                              ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bCreateNewPivotTable);
     virtual ~ScPivotLayoutDialog() override;
 
-    virtual void SetReference(const ScRange& rReferenceRange, ScDocument* pDocument) override;
+    virtual void SetReference(const ScRange& rReferenceRange, ScDocument& rDocument) override;
     virtual void SetActive() override;
     virtual bool IsRefInputMode() const override;
 
diff --git a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
index b63f549ae574..00a109b311a4 100644
--- a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
+++ b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
@@ -26,7 +26,7 @@ public:
 
     virtual ~ScRandomNumberGeneratorDialog() override;
 
-    virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void SetActive() override;
     virtual void Close() override;
 
diff --git a/sc/source/ui/inc/SamplingDialog.hxx b/sc/source/ui/inc/SamplingDialog.hxx
index 6d8582cd8c19..f71c7bb87e25 100644
--- a/sc/source/ui/inc/SamplingDialog.hxx
+++ b/sc/source/ui/inc/SamplingDialog.hxx
@@ -24,7 +24,7 @@ public:
 
     virtual ~ScSamplingDialog() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void    SetActive() override;
     virtual void    Close() override;
 
diff --git a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx
index 5640dfaa5222..69fd05bf92de 100644
--- a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx
+++ b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx
@@ -31,7 +31,7 @@ public:
 
     virtual ~ScStatisticsInputOutputDialog() override;
 
-    virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void        SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void        SetActive() override;
 
 protected:
diff --git a/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx b/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx
index 607e3ac1afe4..83379cd5ebdb 100644
--- a/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx
+++ b/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx
@@ -30,7 +30,7 @@ public:
 
     virtual ~ScStatisticsTwoVariableDialog() override;
 
-    virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void        SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void        SetActive() override;
 
 protected:
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index 4d18444583ac..2ee83f4c8573 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -108,7 +108,7 @@ public:
                         ScRefHandler(SfxDialogController &rController, SfxBindings* pB, bool bBindRef);
     virtual             ~ScRefHandler() COVERITY_NOEXCEPT_FALSE override;
 
-    virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) override = 0;
+    virtual void        SetReference( const ScRange& rRef, ScDocument& rDoc ) override = 0;
     virtual void        AddRefEntry() override;
 
     virtual bool        IsRefInputMode() const override;
diff --git a/sc/source/ui/inc/areasdlg.hxx b/sc/source/ui/inc/areasdlg.hxx
index a685120ab14b..33d8f89970cd 100644
--- a/sc/source/ui/inc/areasdlg.hxx
+++ b/sc/source/ui/inc/areasdlg.hxx
@@ -33,7 +33,7 @@ public:
     ScPrintAreasDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent);
     virtual ~ScPrintAreasDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void    AddRefEntry() override;
 
     virtual bool    IsTableLocked() const override;
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index a244e9816504..ff9caa56f4d3 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -116,7 +116,7 @@ public:
 
     std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const;
 
-    virtual void SetReference(const ScRange&, ScDocument*) override;
+    virtual void SetReference(const ScRange&, ScDocument&) override;
     virtual bool IsRefInputMode() const override;
     virtual void SetActive() override;
     virtual bool IsTableLocked() const override;
diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx
index 9d292c156e4a..92851019fbad 100644
--- a/sc/source/ui/inc/consdlg.hxx
+++ b/sc/source/ui/inc/consdlg.hxx
@@ -35,7 +35,7 @@ public:
                      const SfxItemSet& rArgSet);
     virtual ~ScConsolidateDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override { return true; }
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/crnrdlg.hxx b/sc/source/ui/inc/crnrdlg.hxx
index 5054476613a5..ab705a287426 100644
--- a/sc/source/ui/inc/crnrdlg.hxx
+++ b/sc/source/ui/inc/crnrdlg.hxx
@@ -35,7 +35,7 @@ public:
                           ScViewData* ptrViewData);
     virtual ~ScColRowNameRangesDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx
index 525fd71fb2ea..eae20618d961 100644
--- a/sc/source/ui/inc/dbnamdlg.hxx
+++ b/sc/source/ui/inc/dbnamdlg.hxx
@@ -34,7 +34,7 @@ public:
                 ScViewData* ptrViewData);
     virtual ~ScDbNameDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
index de306709a2b6..8445f1c462a6 100644
--- a/sc/source/ui/inc/filtdlg.hxx
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -53,7 +53,7 @@ public:
                 const SfxItemSet& rArgSet);
     virtual ~ScFilterDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
@@ -161,7 +161,7 @@ public:
                        const SfxItemSet& rArgSet);
     virtual ~ScSpecialFilterDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index 5b19928e933f..8fc552073e5e 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -80,7 +80,7 @@ public:
     // sc::IAnyRefDialog
     virtual void ShowReference(const OUString& _sRef) override;
     virtual void HideReference( bool bDoneRefMode = true ) override;
-    virtual void SetReference( const ScRange& rRef, ScDocument* pD ) override;
+    virtual void SetReference( const ScRange& rRef, ScDocument& rD ) override;
 
     virtual void ReleaseFocus( formula::RefEdit* pEdit ) override;
     virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton ) override;
diff --git a/sc/source/ui/inc/highred.hxx b/sc/source/ui/inc/highred.hxx
index e2b6c104590e..316c5a62ee07 100644
--- a/sc/source/ui/inc/highred.hxx
+++ b/sc/source/ui/inc/highred.hxx
@@ -65,7 +65,7 @@ public:
     virtual ~ScHighlightChgDlg() override;
 
     virtual void    SetActive() override;
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual void    Close() override;
     virtual bool    IsRefInputMode() const override;
 
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index ff60dcdbb4c3..7180ab6efac2 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -197,7 +197,7 @@ public:
     bool            KeyInput( const KeyEvent& rKEvt, bool bStartEdit );
     void            EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );
     void            CancelHandler();
-    void            SetReference( const ScRange& rRef, const ScDocument* pDoc );
+    void            SetReference( const ScRange& rRef, const ScDocument& rDoc );
     void            AddRefEntry();
 
     void            InputCommand( const CommandEvent& rCEvt );
diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 33f58b36d9c2..8c46f64fb43c 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -78,7 +78,7 @@ public:
 
     virtual ~ScNameDefDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual bool    IsRefInputMode() const override;
 
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 6442eae743a2..e7bb0a1df579 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -113,7 +113,7 @@ public:
                std::map<OUString, std::unique_ptr<ScRangeName>>* pRangeMap = nullptr);
     virtual         ~ScNameDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual bool    IsRefInputMode() const override;
 
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx
index ec922823ce07..3208416989a4 100644
--- a/sc/source/ui/inc/optsolver.hxx
+++ b/sc/source/ui/inc/optsolver.hxx
@@ -93,7 +93,7 @@ public:
                  ScDocShell* pDocSh, const ScAddress& aCursorPos );
     virtual ~ScOptSolverDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
     virtual void    Close() override;
diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx
index 8c9835f586fc..ce62242f6de2 100644
--- a/sc/source/ui/inc/simpref.hxx
+++ b/sc/source/ui/inc/simpref.hxx
@@ -58,7 +58,7 @@ public:
                     ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent);
     virtual        ~ScSimpleRefDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
 
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
diff --git a/sc/source/ui/inc/solvrdlg.hxx b/sc/source/ui/inc/solvrdlg.hxx
index f6fac01c7f97..3fcadd881e0a 100644
--- a/sc/source/ui/inc/solvrdlg.hxx
+++ b/sc/source/ui/inc/solvrdlg.hxx
@@ -39,7 +39,7 @@ public:
                  const ScAddress& aCursorPos );
     virtual ~ScSolverDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual bool    IsRefInputMode() const override;
     virtual void    SetActive() override;
     virtual void    Close() override;
diff --git a/sc/source/ui/inc/tabopdlg.hxx b/sc/source/ui/inc/tabopdlg.hxx
index 80d6b16869f6..471039fca686 100644
--- a/sc/source/ui/inc/tabopdlg.hxx
+++ b/sc/source/ui/inc/tabopdlg.hxx
@@ -42,7 +42,7 @@ public:
                const ScRefAddress& rCursorPos);
     virtual ~ScTabOpDlg() override;
 
-    virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
+    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
     virtual bool    IsRefInputMode() const override { return true; }
     virtual void    SetActive() override;
 
diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx
index 2c562717f921..314b9ea014a5 100644
--- a/sc/source/ui/inc/validate.hxx
+++ b/sc/source/ui/inc/validate.hxx
@@ -37,7 +37,7 @@ protected:
 #ifdef _WIN32
     #pragma pack(push, 16)
 #endif
-    void            (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument* );
+    void            (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument& );
     void            (ScRefHandlerCaller::*m_pSetActiveHdl)();
     void            (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, const formula::RefButton* pButton );
     void            (ScRefHandlerCaller::*m_pRefInputDonePostHdl)();
@@ -46,7 +46,7 @@ protected:
 #endif
 
 public:
-    typedef void            (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument* );
+    typedef void            (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument& );
     typedef void            (ScRefHandlerCaller::*PCOMMONHDLTYPE)();
     typedef void            (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)(  formula::RefEdit* pEdit, const formula::RefButton* pButton );
 
@@ -132,7 +132,7 @@ private:
     weld::Container* m_pRefEditParent;
     weld::Container* m_pBtnRefParent;
 
-    void            SetReferenceHdl( const ScRange& , const ScDocument* );
+    void            SetReferenceHdl( const ScRange& , const ScDocument& );
     void            SetActiveHdl();
     void            RefInputStartPreHdl(formula::RefEdit* pEdit, const formula::RefButton* pButton);
     void            RefInputDonePostHdl();
@@ -176,10 +176,10 @@ public:
 
     void            SetModal(bool bModal) { m_xDialog->set_modal(bModal); }
 
-    virtual void            SetReference( const ScRange& rRef, ScDocument* pDoc ) override
+    virtual void            SetReference( const ScRange& rRef, ScDocument& rDoc ) override
     {
         if ( m_pHandler && m_pSetReferenceHdl )
-            (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc );
+            (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
     }
 
     virtual void            SetActive() override
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index 50114022f934..dc73b0382a1e 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -69,7 +69,7 @@ public:
     virtual ~ScXMLSourceDlg() override;
 
     virtual bool IsRefInputMode() const override;
-    virtual void SetReference(const ScRange& rRange, ScDocument* pDoc) override;
+    virtual void SetReference(const ScRange& rRange, ScDocument& rDoc) override;
     virtual void Deactivate() override;
     virtual void SetActive() override;
     virtual void Close() override;
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 484352be29b7..ed81d8980ef6 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -304,7 +304,7 @@ void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit )
                         rRange.aStart.Row(), SC_FOLLOW_JUMP, false, false );
                     pViewShell->MoveCursorAbs( rRange.aEnd.Col(),
                         rRange.aEnd.Row(), SC_FOLLOW_JUMP, true, false );
-                    m_pDlg->SetReference( rRange, pDoc );
+                    m_pDlg->SetReference( rRange, *pDoc );
                 }
             }
         }
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
index 1098f2772b86..424782050ec8 100644
--- a/sc/source/ui/miscdlgs/crnrdlg.cxx
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -303,7 +303,7 @@ void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange, bool bR
 
 // Set the reference to a cell range selected with the mouse and update
 // the selection form element
-void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument& /* rDoc */ )
 {
     if ( m_pEdActive )
     {
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx
index ad3bb9b7e2c2..c99c79c80f18 100644
--- a/sc/source/ui/miscdlgs/highred.cxx
+++ b/sc/source/ui/miscdlgs/highred.cxx
@@ -126,13 +126,13 @@ void ScHighlightChgDlg::Init()
 
 // Set the reference to a cell range selected with the mouse. This is then
 // shown as the new selection in the reference field.
-void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_xEdAssign->GetWidget()->get_visible())
     {
         if ( rRef.aStart != rRef.aEnd )
             RefInputStart(m_xEdAssign.get());
-        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, pDocP, pDocP->GetAddressConvention()));
+        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, &rDocP, rDocP.GetAddressConvention()));
         m_xEdAssign->SetRefString( aRefStr );
         m_xFilterCtr->SetRange(aRefStr);
     }
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index 4ce5b8b6ba07..2087e6fec152 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -445,7 +445,7 @@ void ScOptSolverDlg::SetActive()
     RefInputDone();
 }
 
-void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if( mpEdActive )
     {
@@ -462,15 +462,15 @@ void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
             aNewRef.aEnd = aAdr;
 
         OUString aName;
-        if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) )            // named range: show name
+        if ( rDocP.GetRangeAtBlock( aNewRef, &aName ) )            // named range: show name
             aStr = aName;
         else                                                        // format cell/range reference
         {
             ScRefFlags nFmt = ( aAdr.Tab() == mnCurTab ) ? ScRefFlags::ADDR_ABS : ScRefFlags::ADDR_ABS_3D;
             if ( bSingle )
-                aStr = aAdr.Format(nFmt, pDocP, pDocP->GetAddressConvention());
+                aStr = aAdr.Format(nFmt, &rDocP, rDocP.GetAddressConvention());
             else
-                aStr = rRef.Format(nFmt | ScRefFlags::RANGE_ABS, pDocP, pDocP->GetAddressConvention());
+                aStr = rRef.Format(nFmt | ScRefFlags::RANGE_ABS, &rDocP, rDocP.GetAddressConvention());
         }
 
         // variable cells can be several ranges, so only the selection is replaced
diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx
index 51511e815210..884ed1e22d1e 100644
--- a/sc/source/ui/miscdlgs/simpref.cxx
+++ b/sc/source/ui/miscdlgs/simpref.cxx
@@ -66,7 +66,7 @@ void ScSimpleRefDlg::Init()
 
 // Set the reference to a cell range selected with the mouse. This is then
 // shown as the new selection in the reference field.
-void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_xEdAssign->GetWidget()->get_sensitive())
     {
@@ -78,10 +78,10 @@ void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
         if ( bSingleCell )
         {
             ScAddress aAdr = rRef.aStart;
-            aRefStr = aAdr.Format(ScRefFlags::ADDR_ABS_3D, pDocP, pDocP->GetAddressConvention());
+            aRefStr = aAdr.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, rDocP.GetAddressConvention());
         }
         else
-            aRefStr = theCurArea.Format(ScRefFlags::RANGE_ABS_3D, pDocP, pDocP->GetAddressConvention());
+            aRefStr = theCurArea.Format(ScRefFlags::RANGE_ABS_3D, &rDocP, rDocP.GetAddressConvention());
 
         if ( bMultiSelection )
         {
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
index 25a36c30941d..6608ea8e9488 100644
--- a/sc/source/ui/miscdlgs/solvrdlg.cxx
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -128,7 +128,7 @@ void ScSolverDlg::SetActive()
     RefInputDone();
 }
 
-void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if( m_pEdActive )
     {
@@ -140,7 +140,7 @@ void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
                                 ? ScRefFlags::ADDR_ABS
                                 : ScRefFlags::ADDR_ABS_3D;
 
-        OUString aStr(aAdr.Format(nFmt, pDocP, pDocP->GetAddressConvention()));
+        OUString aStr(aAdr.Format(nFmt, &rDocP, rDocP.GetAddressConvention()));
         m_pEdActive->SetRefString( aStr );
 
         if (m_pEdActive == m_xEdFormulaCell.get())
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
index 43a6b0497f44..0eae510542e1 100644
--- a/sc/source/ui/miscdlgs/tabopdlg.cxx
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -124,11 +124,11 @@ void ScTabOpDlg::SetActive()
     RefInputDone();
 }
 
-void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_pEdActive)
     {
-        ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
+        ScAddress::Details aDetails(rDocP.GetAddressConvention(), 0, 0);
 
         if ( rRef.aStart != rRef.aEnd )
             RefInputStart(m_pEdActive);
@@ -142,17 +142,17 @@ void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
         {
             theFormulaCell.Set( rRef.aStart, false, false, false);
             theFormulaEnd.Set( rRef.aEnd, false, false, false);
-            aStr = rRef.Format(nFmt, pDocP, aDetails);
+            aStr = rRef.Format(nFmt, &rDocP, aDetails);
         }
         else if (m_pEdActive == m_xEdRowCell.get())
         {
             theRowCell.Set( rRef.aStart, false, false, false);
-            aStr = rRef.aStart.Format(nFmt, pDocP, aDetails);
+            aStr = rRef.aStart.Format(nFmt, &rDocP, aDetails);
         }
         else if (m_pEdActive == m_xEdColCell.get())
         {
             theColCell.Set( rRef.aStart, false, false, false);
-            aStr = rRef.aStart.Format(nFmt, pDocP, aDetails);
+            aStr = rRef.aStart.Format(nFmt, &rDocP, aDetails);
         }
 
         m_pEdActive->SetRefString( aStr );
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 79e4923f5b8b..06f8c720f1b7 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -284,14 +284,14 @@ void ScNameDefDlg::RefInputDone( bool bForced)
     IsNameValid();
 }
 
-void ScNameDefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScNameDefDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_xEdRange->GetWidget()->get_sensitive())
     {
         if ( rRef.aStart != rRef.aEnd )
             RefInputStart(m_xEdRange.get());
-        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, pDocP,
-                ScAddress::Details(pDocP->GetAddressConvention(), 0, 0)));
+        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, &rDocP,
+                ScAddress::Details(rDocP.GetAddressConvention(), 0, 0)));
         m_xEdRange->SetRefString( aRefStr );
     }
 }
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index cdb9e5b18077..cf9da658f1d4 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -158,14 +158,14 @@ void ScNameDlg::RefInputDone( bool bForced)
     RefEdModifyHdl(*m_xEdAssign);
 }
 
-void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+void ScNameDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
 {
     if (m_xEdAssign->GetWidget()->get_sensitive())
     {
         if ( rRef.aStart != rRef.aEnd )
             RefInputStart(m_xEdAssign.get());
-        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, pDocP,
-                ScAddress::Details(pDocP->GetAddressConvention(), 0, 0)));
+        OUString aRefStr(rRef.Format(ScRefFlags::RANGE_ABS_3D, &rDocP,
+                ScAddress::Details(rDocP.GetAddressConvention(), 0, 0)));
         m_xEdAssign->SetRefString( aRefStr );
     }
 }
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index c6a1d2dfa88f..ddd8eb868b64 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -164,7 +164,7 @@ bool ScPrintAreasDlg::IsTableLocked() const
     return true;
 }
 
-void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument& /* rDoc */ )
 {
     if ( m_pRefInputEdit )
     {
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index c286b7b5d173..9f4917b78be3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3199,7 +3199,7 @@ void ScGridWindow::KeyInput(const KeyEvent& rKEvt)
             ScRange aRef(
                 pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
                 pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
-            SC_MOD()->SetReference( aRef, pViewData->GetDocument() );
+            SC_MOD()->SetReference( aRef, *pViewData->GetDocument() );
         }
         pViewData->GetViewShell()->SelectionChanged();
         return ;
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 53e897cc6aa7..61e570bd2bbc 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -314,7 +314,7 @@ void ScTabControl::Select()
             ScRange aRange(
                     pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
                     pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
-            pScMod->SetReference( aRange, pDoc, &rMark );
+            pScMod->SetReference( aRange, *pDoc, &rMark );
             pScMod->EndReference();                     // due to Auto-Hide
         }
 }
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 3cbd121fb10b..f584dfdc8482 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -231,7 +231,7 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ )
             ScRange aRef(
                     aViewData.GetRefStartX(), aViewData.GetRefStartY(), aViewData.GetRefStartZ(),
                     aViewData.GetRefEndX(), aViewData.GetRefEndY(), aViewData.GetRefEndZ() );
-            SC_MOD()->SetReference( aRef, pDoc, &rMark );
+            SC_MOD()->SetReference( aRef, *pDoc, &rMark );
             ShowRefTip();
         }
         else if ( eType == SC_REFTYPE_EMBED_LT || eType == SC_REFTYPE_EMBED_RB )
@@ -331,7 +331,7 @@ void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eT
 
             //  SetReference without Merge-Adjustment
             ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ );
-            SC_MOD()->SetReference( aRef, pDoc, &rMark );
+            SC_MOD()->SetReference( aRef, *pDoc, &rMark );
         }
 
         ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl();
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 2711953daac8..227ca99da3f4 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -113,7 +113,7 @@ bool ScXMLSourceDlg::IsRefInputMode() const
     return mpActiveEdit != nullptr && mpActiveEdit->GetWidget()->get_sensitive();
 }
 
-void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
+void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument& rDoc)
 {
     if (!mpActiveEdit)
         return;
@@ -121,7 +121,7 @@ void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
     if (rRange.aStart != rRange.aEnd)
         RefInputStart(mpActiveEdit);
 
-    OUString aStr(rRange.aStart.Format(ScRefFlags::ADDR_ABS_3D, pDoc, pDoc->GetAddressConvention()));
+    OUString aStr(rRange.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDoc, rDoc.GetAddressConvention()));
     mpActiveEdit->SetRefString(aStr);
 
     RefEditModified();


More information about the Libreoffice-commits mailing list