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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 23 07:41:50 UTC 2020


 sc/inc/PivotTableDataProvider.hxx              |    2 -
 sc/inc/address.hxx                             |    4 +--
 sc/inc/refdata.hxx                             |    4 +--
 sc/inc/sharedformula.hxx                       |    4 +--
 sc/source/core/data/column.cxx                 |    2 -
 sc/source/core/data/column4.cxx                |    8 +++----
 sc/source/core/data/table7.cxx                 |    4 +--
 sc/source/core/tool/address.cxx                |   14 ++++++------
 sc/source/core/tool/refdata.cxx                |   20 ++++++++---------
 sc/source/core/tool/sharedformula.cxx          |   12 +++++-----
 sc/source/core/tool/token.cxx                  |   28 ++++++++++++-------------
 sc/source/ui/drawfunc/fuins2.cxx               |    2 -
 sc/source/ui/unoobj/PivotTableDataProvider.cxx |    7 ++----
 sc/source/ui/unoobj/TablePivotCharts.cxx       |    2 -
 sc/source/ui/unoobj/servuno.cxx                |    2 -
 15 files changed, 57 insertions(+), 58 deletions(-)

New commits:
commit 8db6083692e92389d50565bbf8643c60572e4aca
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 22 19:46:35 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 23 09:41:08 2020 +0200

    some places where ScDocument* is never passed a nullptr
    
    allow some never-hit null checks to be dropped
    
    Change-Id: I27a3979af19b556bc9a8e4f893bf0e65cdc439a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103215
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/PivotTableDataProvider.hxx b/sc/inc/PivotTableDataProvider.hxx
index 80cfc597af86..3dadfa94cd8e 100644
--- a/sc/inc/PivotTableDataProvider.hxx
+++ b/sc/inc/PivotTableDataProvider.hxx
@@ -48,7 +48,7 @@ class PivotTableDataProvider final : public PivotTableDataProvider_Base, public
 {
 public:
 
-    explicit PivotTableDataProvider(ScDocument* pDoc);
+    explicit PivotTableDataProvider(ScDocument& rDoc);
     virtual ~PivotTableDataProvider() override;
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
 
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 8426a5011808..fd40f29b3c12 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -653,12 +653,12 @@ public:
     /** Increment or decrement end column unless sticky or until it becomes
         sticky. Checks if the range encompasses at least two columns so should
         be called before adjusting the start column. */
-    void IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta );
+    void IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta );
 
     /** Increment or decrement end row unless sticky or until it becomes
         sticky. Checks if the range encompasses at least two rows so should
         be called before adjusting the start row. */
-    void IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta );
+    void IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta );
 
     inline bool operator==( const ScRange& rRange ) const;
     inline bool operator!=( const ScRange& rRange ) const;
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 5874f673e128..9429ba0d8cff 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -189,12 +189,12 @@ struct ScComplexRefData
     /** Increment or decrement end column unless or until sticky.
         @see ScRange::IncEndColSticky()
         @return TRUE if changed. */
-    bool IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta, const ScAddress& rPos );
+    bool IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta, const ScAddress& rPos );
 
     /** Increment or decrement end row unless or until sticky.
         @see ScRange::IncEndRowSticky()
         @return TRUE if changed. */
-    bool IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta, const ScAddress& rPos );
+    bool IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta, const ScAddress& rPos );
 
     bool IsDeleted() const;
 
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index c61ce62b6b79..00c098541e9a 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -85,7 +85,7 @@ public:
      * @return TRUE if there indeed was a split, else FALSE (e.g. split
      *         positions were only top or bottom cells or no formula group).
      */
-    static bool splitFormulaCellGroups(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds);
+    static bool splitFormulaCellGroups(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds);
 
     /**
      * See if two specified adjacent formula cells can be merged, and if they
@@ -128,7 +128,7 @@ public:
      * @param rCells cell storage container
      * @param rRows row positions at which to unshare formula cells.
      */
-    static void unshareFormulaCells(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rRows);
+    static void unshareFormulaCells(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rRows);
 
     /**
      * Have all formula cells belonging to a group start listening to their
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 1647dfaa0b5a..3d98018f64ac 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2525,7 +2525,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc
     }
 
     // Do the actual splitting.
-    const bool bSplit = sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds);
+    const bool bSplit = sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
 
     // Collect all formula groups.
     std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 1d21b8b2bca1..bd919be1d9e9 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -441,7 +441,7 @@ void ScColumn::ConvertFormulaToValue(
         aBounds.push_back(nRow2+1);
 
     // Split formula cell groups at top and bottom boundaries (if applicable).
-    sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds);
+    sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
 
     // Parse all formulas within the range and store their results into temporary storage.
     ConvertFormulaToValueHandler aFunc(GetDoc().GetSheetLimits());
@@ -502,7 +502,7 @@ void ScColumn::SwapNonEmpty(
         aBounds.push_back(rRange.aEnd.Row()+1);
 
     // Split formula cell groups at top and bottom boundaries (if applicable).
-    sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds);
+    sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
     std::vector<sc::CellValueSpan> aSpans = rValues.getNonEmptySpans(nTab, nCol);
 
     // Detach formula cells within the spans (if any).
@@ -1200,13 +1200,13 @@ void ScColumn::SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange )
     aBounds.push_back(rBoundRange.aStart.Row());
     if (rBoundRange.aEnd.Row() < GetDoc().MaxRow())
         aBounds.push_back(rBoundRange.aEnd.Row()+1);
-    sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds);
+    sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
 
     RelativeRefBoundChecker aFunc(rBoundRange);
     sc::ProcessFormula(
         maCells.begin(), maCells, rBoundRange.aStart.Row(), rBoundRange.aEnd.Row(), aFunc);
     aFunc.swapBounds(aBounds);
-    sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), maCells, aBounds);
+    sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
 }
 
 namespace {
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index cbe785995898..fc821133ef65 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -270,7 +270,7 @@ void ScTable::SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows )
     if (!IsColValid(nCol))
         return;
 
-    sc::SharedFormulaUtil::splitFormulaCellGroups(&GetDoc(), aCol[nCol].maCells, rRows);
+    sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), aCol[nCol].maCells, rRows);
 }
 
 void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
@@ -278,7 +278,7 @@ void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
     if (!IsColValid(nCol))
         return;
 
-    sc::SharedFormulaUtil::unshareFormulaCells(&rDocument, aCol[nCol].maCells, rRows);
+    sc::SharedFormulaUtil::unshareFormulaCells(rDocument, aCol[nCol].maCells, rRows);
 }
 
 void ScTable::RegroupFormulaCells( SCCOL nCol )
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 6c32d10e2e70..1fb89ad7af15 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2444,7 +2444,7 @@ void ScRange::IncRowIfNotLessThan(const ScDocument* pDoc, SCROW nStartRow, SCROW
     }
 }
 
-void ScRange::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta )
+void ScRange::IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta )
 {
     SCCOL nCol = aEnd.Col();
     if (aStart.Col() >= nCol)
@@ -2454,7 +2454,7 @@ void ScRange::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta )
         return;
     }
 
-    const SCCOL nMaxCol = (pDoc ? pDoc->MaxCol() : MAXCOL);
+    const SCCOL nMaxCol = rDoc.MaxCol();
     if (nCol == nMaxCol)
         // already sticky
         return;
@@ -2465,7 +2465,7 @@ void ScRange::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta )
         aEnd.IncCol( nDelta);   // was greater than nMaxCol, caller should know...
 }
 
-void ScRange::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta )
+void ScRange::IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta )
 {
     SCROW nRow = aEnd.Row();
     if (aStart.Row() >= nRow)
@@ -2475,14 +2475,14 @@ void ScRange::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta )
         return;
     }
 
-    if (nRow == pDoc->MaxRow())
+    if (nRow == rDoc.MaxRow())
         // already sticky
         return;
 
-    if (nRow < pDoc->MaxRow())
-        aEnd.SetRow( ::std::min( static_cast<SCROW>(nRow + nDelta), pDoc->MaxRow()));
+    if (nRow < rDoc.MaxRow())
+        aEnd.SetRow( ::std::min( static_cast<SCROW>(nRow + nDelta), rDoc.MaxRow()));
     else
-        aEnd.IncRow( nDelta);   // was greater than pDoc->MaxRow(), caller should know...
+        aEnd.IncRow( nDelta);   // was greater than rDoc.MaxRow(), caller should know...
 }
 
 OUString ScAddress::GetColRowString() const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 0451a5d4edbe..8f49acb3160b 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -506,7 +506,7 @@ void ScComplexRefData::PutInOrder( const ScAddress& rPos )
     ScSingleRefData::PutInOrder( Ref1, Ref2, rPos);
 }
 
-bool ScComplexRefData::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta, const ScAddress& rPos )
+bool ScComplexRefData::IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta, const ScAddress& rPos )
 {
     SCCOL nCol1 = Ref1.IsColRel() ? Ref1.Col() + rPos.Col() : Ref1.Col();
     SCCOL nCol2 = Ref2.IsColRel() ? Ref2.Col() + rPos.Col() : Ref2.Col();
@@ -517,25 +517,25 @@ bool ScComplexRefData::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta, co
         return true;
     }
 
-    if (nCol2 == pDoc->MaxCol())
+    if (nCol2 == rDoc.MaxCol())
         // already sticky
         return false;
 
-    if (nCol2 < pDoc->MaxCol())
+    if (nCol2 < rDoc.MaxCol())
     {
-        SCCOL nCol = ::std::min( static_cast<SCCOL>(nCol2 + nDelta), pDoc->MaxCol());
+        SCCOL nCol = ::std::min( static_cast<SCCOL>(nCol2 + nDelta), rDoc.MaxCol());
         if (Ref2.IsColRel())
             Ref2.SetRelCol( nCol - rPos.Col());
         else
             Ref2.SetAbsCol( nCol);
     }
     else
-        Ref2.IncCol( nDelta);   // was greater than pDoc->.MaxCol(), caller should know...
+        Ref2.IncCol( nDelta);   // was greater than rDoc.MaxCol(), caller should know...
 
     return true;
 }
 
-bool ScComplexRefData::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta, const ScAddress& rPos )
+bool ScComplexRefData::IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta, const ScAddress& rPos )
 {
     SCROW nRow1 = Ref1.IsRowRel() ? Ref1.Row() + rPos.Row() : Ref1.Row();
     SCROW nRow2 = Ref2.IsRowRel() ? Ref2.Row() + rPos.Row() : Ref2.Row();
@@ -546,20 +546,20 @@ bool ScComplexRefData::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta, co
         return true;
     }
 
-    if (nRow2 == pDoc->MaxRow())
+    if (nRow2 == rDoc.MaxRow())
         // already sticky
         return false;
 
-    if (nRow2 < pDoc->MaxRow())
+    if (nRow2 < rDoc.MaxRow())
     {
-        SCROW nRow = ::std::min( static_cast<SCROW>(nRow2 + nDelta), pDoc->MaxRow());
+        SCROW nRow = ::std::min( static_cast<SCROW>(nRow2 + nDelta), rDoc.MaxRow());
         if (Ref2.IsRowRel())
             Ref2.SetRelRow( nRow - rPos.Row());
         else
             Ref2.SetAbsRow( nRow);
     }
     else
-        Ref2.IncRow( nDelta);   // was greater than pDoc->.MaxRow(), caller should know...
+        Ref2.IncRow( nDelta);   // was greater than rDoc.MaxRow(), caller should know...
 
     return true;
 }
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 495f0d2e75a6..4617239fe91d 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -120,7 +120,7 @@ bool SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
     return true;
 }
 
-bool SharedFormulaUtil::splitFormulaCellGroups(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds)
+bool SharedFormulaUtil::splitFormulaCellGroups(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds)
 {
     if (rBounds.empty())
         return false;
@@ -141,7 +141,7 @@ bool SharedFormulaUtil::splitFormulaCellGroups(const ScDocument* pDoc, CellStore
     for (++it; it != itEnd; ++it)
     {
         nRow = *it;
-        if (pDoc->ValidRow(nRow))
+        if (rDoc.ValidRow(nRow))
         {
             aPos = rCells.position(aPos.first, nRow);
             if (aPos.first == rCells.end())
@@ -354,7 +354,7 @@ void SharedFormulaUtil::unshareFormulaCell(const CellStoreType::position_type& a
     rCell.SetCellGroup(xNone);
 }
 
-void SharedFormulaUtil::unshareFormulaCells(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rRows)
+void SharedFormulaUtil::unshareFormulaCells(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rRows)
 {
     if (rRows.empty())
         return;
@@ -367,19 +367,19 @@ void SharedFormulaUtil::unshareFormulaCells(const ScDocument* pDoc, CellStoreTyp
     std::vector<SCROW> aRows2;
     for (const auto& rRow : rRows)
     {
-        if (rRow > pDoc->MaxRow())
+        if (rRow > rDoc.MaxRow())
             break;
 
         aRows2.push_back(rRow);
 
-        if (rRow < pDoc->MaxRow())
+        if (rRow < rDoc.MaxRow())
             aRows2.push_back(rRow+1);
     }
 
     // Remove duplicates again (the vector should still be sorted).
     aRows2.erase(std::unique(aRows2.begin(), aRows2.end()), aRows2.end());
 
-    splitFormulaCellGroups(pDoc, rCells, aRows2);
+    splitFormulaCellGroups(rDoc, rCells, aRows2);
 }
 
 void SharedFormulaUtil::startListeningAsGroup( sc::StartListeningContext& rCxt, ScFormulaCell** ppSharedTop )
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6bf0342a6809..3466c6ba94d0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2803,7 +2803,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
                 // The reference range is truncated on the left.
                 SCCOL nOffset = rDeletedRange.aStart.Col() - rRefRange.aStart.Col();
                 SCCOL nDelta = rRefRange.aStart.Col() - rDeletedRange.aEnd.Col() - 1;
-                rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta+nOffset);
+                rRefRange.IncEndColSticky(rCxt.mrDoc, nDelta+nOffset);
                 rRefRange.aStart.IncCol(nOffset);
             }
         }
@@ -2816,7 +2816,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
             // Reference is deleted in the middle. Move the last column
             // position to the left.
             SCCOL nDelta = rDeletedRange.aStart.Col() - rDeletedRange.aEnd.Col() - 1;
-            rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
+            rRefRange.IncEndColSticky(rCxt.mrDoc, nDelta);
         }
         else
         {
@@ -2826,7 +2826,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
 
             // The reference range is truncated on the right.
             SCCOL nDelta = rDeletedRange.aStart.Col() - rRefRange.aEnd.Col() - 1;
-            rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
+            rRefRange.IncEndColSticky(rCxt.mrDoc, nDelta);
         }
         return SHRUNK;
     }
@@ -2854,7 +2854,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
                 // The reference range is truncated on the top.
                 SCROW nOffset = rDeletedRange.aStart.Row() - rRefRange.aStart.Row();
                 SCROW nDelta = rRefRange.aStart.Row() - rDeletedRange.aEnd.Row() - 1;
-                rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta+nOffset);
+                rRefRange.IncEndRowSticky(rCxt.mrDoc, nDelta+nOffset);
                 rRefRange.aStart.IncRow(nOffset);
             }
         }
@@ -2867,7 +2867,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
             // Reference is deleted in the middle. Move the last row
             // position upward.
             SCROW nDelta = rDeletedRange.aStart.Row() - rDeletedRange.aEnd.Row() - 1;
-            rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
+            rRefRange.IncEndRowSticky(rCxt.mrDoc, nDelta);
         }
         else
         {
@@ -2877,7 +2877,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
 
             // The reference range is truncated on the bottom.
             SCROW nDelta = rDeletedRange.aStart.Row() - rRefRange.aEnd.Row() - 1;
-            rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
+            rRefRange.IncEndRowSticky(rCxt.mrDoc, nDelta);
         }
         return SHRUNK;
     }
@@ -2921,7 +2921,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc
 
         // Move the last column position to the right.
         SCCOL nDelta = rSelectedRange.aEnd.Col() - rSelectedRange.aStart.Col() + 1;
-        rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
+        rRefRange.IncEndColSticky(rCxt.mrDoc, nDelta);
         return true;
     }
     else if (rCxt.mnRowDelta > 0)
@@ -2954,7 +2954,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc
 
         // Move the last row position down.
         SCROW nDelta = rSelectedRange.aEnd.Row() - rSelectedRange.aStart.Row() + 1;
-        rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
+        rRefRange.IncEndRowSticky(rCxt.mrDoc, nDelta);
         return true;
     }
     return false;
@@ -3001,7 +3001,7 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co
 
         // Move the last column position to the right.
         SCCOL nDelta = rSelectedRange.aEnd.Col() - rSelectedRange.aStart.Col() + 1;
-        rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
+        rRefRange.IncEndColSticky(rCxt.mrDoc, nDelta);
         return true;
     }
     else if (rCxt.mnRowDelta > 0)
@@ -3028,7 +3028,7 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co
 
         // Move the last row position down.
         SCROW nDelta = rSelectedRange.aEnd.Row() - rSelectedRange.aStart.Row() + 1;
-        rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
+        rRefRange.IncEndRowSticky(rCxt.mrDoc, nDelta);
         return true;
     }
 
@@ -3564,7 +3564,7 @@ bool adjustSingleRefInName(
         {
             if (pEndOfComplex)
             {
-                if (pEndOfComplex->IncEndColSticky( &rCxt.mrDoc, rCxt.mnColDelta, rPos))
+                if (pEndOfComplex->IncEndColSticky(rCxt.mrDoc, rCxt.mnColDelta, rPos))
                     bChanged = true;
             }
             else
@@ -3582,7 +3582,7 @@ bool adjustSingleRefInName(
         {
             if (pEndOfComplex)
             {
-                if (pEndOfComplex->IncEndRowSticky( &rCxt.mrDoc, rCxt.mnRowDelta, rPos))
+                if (pEndOfComplex->IncEndRowSticky(rCxt.mrDoc, rCxt.mnRowDelta, rPos))
                     bChanged = true;
             }
             else
@@ -3621,7 +3621,7 @@ bool adjustDoubleRefInName(
                 {
                     // Selection intersects the referenced range. Only expand the
                     // bottom position.
-                    rRef.IncEndRowSticky(&rCxt.mrDoc, rCxt.mnRowDelta, rPos);
+                    rRef.IncEndRowSticky(rCxt.mrDoc, rCxt.mnRowDelta, rPos);
                     return true;
                 }
             }
@@ -3638,7 +3638,7 @@ bool adjustDoubleRefInName(
                 {
                     // Selection intersects the referenced range. Only expand the
                     // right position.
-                    rRef.IncEndColSticky(&rCxt.mrDoc, rCxt.mnColDelta, rPos);
+                    rRef.IncEndColSticky(rCxt.mrDoc, rCxt.mnColDelta, rPos);
                     return true;
                 }
             }
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index e606054eb089..11217f783bde 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -131,7 +131,7 @@ void lcl_ChartInit(const uno::Reference <embed::XEmbeddedObject>& xObj, ScViewDa
     uno::Reference<chart2::data::XDataProvider> xDataProvider;
     if (bRangeIsPivotTable)
     {
-        std::unique_ptr<sc::PivotTableDataProvider> pPivotTableDataProvider(new sc::PivotTableDataProvider(&rScDoc));
+        std::unique_ptr<sc::PivotTableDataProvider> pPivotTableDataProvider(new sc::PivotTableDataProvider(rScDoc));
         pPivotTableDataProvider->setPivotTableName(aRangeString);
         xDataProvider.set(pPivotTableDataProvider.release());
     }
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index 21ecd47686ce..ae1fb2c73820 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -134,15 +134,14 @@ SC_SIMPLE_SERVICE_INFO(PivotTableDataProvider, "PivotTableDataProvider", SC_SERV
 
 // DataProvider ==============================================================
 
-PivotTableDataProvider::PivotTableDataProvider(ScDocument* pDoc)
-    : m_pDocument(pDoc)
+PivotTableDataProvider::PivotTableDataProvider(ScDocument& rDoc)
+    : m_pDocument(&rDoc)
     , m_aPropSet(lcl_GetDataProviderPropertyMap())
     , m_bIncludeHiddenCells(true)
     , m_bNeedsUpdate(true)
     , m_xContext(comphelper::getProcessComponentContext())
 {
-    if (m_pDocument)
-        m_pDocument->AddUnoObject(*this);
+    rDoc.AddUnoObject(*this);
 }
 
 PivotTableDataProvider::~PivotTableDataProvider()
diff --git a/sc/source/ui/unoobj/TablePivotCharts.cxx b/sc/source/ui/unoobj/TablePivotCharts.cxx
index 0c85943854c4..3356125df9fb 100644
--- a/sc/source/ui/unoobj/TablePivotCharts.cxx
+++ b/sc/source/ui/unoobj/TablePivotCharts.cxx
@@ -125,7 +125,7 @@ void SAL_CALL TablePivotCharts::addNewByName(OUString const & rName,
     aAwtSize.Width = aSize.Width();
     aAwtSize.Height = aSize.Height();
 
-    std::unique_ptr<sc::PivotTableDataProvider> pPivotTableDataProvider(new sc::PivotTableDataProvider(&rDoc));
+    std::unique_ptr<sc::PivotTableDataProvider> pPivotTableDataProvider(new sc::PivotTableDataProvider(rDoc));
     pPivotTableDataProvider->setPivotTableName(rDataPilotName);
 
     uno::Reference<chart2::data::XDataProvider> xDataProvider(pPivotTableDataProvider.release());
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index b3e650d5d41e..ac3e93771cb1 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -547,7 +547,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
             break;
         case Type::CHART_PIVOTTABLE_DATAPROVIDER:
             if (pDocShell)
-                xRet = *new sc::PivotTableDataProvider(&pDocShell->GetDocument());
+                xRet = *new sc::PivotTableDataProvider(pDocShell->GetDocument());
             break;
         case Type::FORMULAPARS:
             if (pDocShell)


More information about the Libreoffice-commits mailing list