[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/inc sc/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Dec 18 10:19:19 UTC 2017


 sc/inc/attarray.hxx                      |    3 
 sc/inc/column.hxx                        |   13 +--
 sc/source/core/data/cellvalue.cxx        |    4 -
 sc/source/core/data/column.cxx           |  103 +++++++++++++++--------------
 sc/source/core/data/column2.cxx          |   30 +++++---
 sc/source/core/data/column3.cxx          |  107 ++++++++++++++++---------------
 sc/source/core/data/column4.cxx          |   19 +++--
 sc/source/core/data/dociter.cxx          |    4 -
 sc/source/core/data/table4.cxx           |    2 
 sc/source/ui/docshell/externalrefmgr.cxx |    2 
 10 files changed, 153 insertions(+), 134 deletions(-)

New commits:
commit dc3f0bde0bdef2a1e94055be146b433cb9fc54ba
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Dec 6 19:41:45 2017 -0500

    sc: compact ScColumn
    
    Remove ScDocument* member from ScColumn
    and re-use the one in ScAttrArray.
    
    This saves 8 bytes and makes the code more
    homogenious by using GetDoc() member everywhere.
    
    Change-Id: I16a94b7ef7c45ef3af14e812b45f255f39939a6e
    (cherry picked from commit 1168a11278ed3c2a00058e1f802f6e44cb925318)
    Reviewed-on: https://gerrit.libreoffice.org/46680
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 49626ea9e124..e6cfbab5201f 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -83,7 +83,7 @@ class ScAttrArray
 private:
     SCCOL           nCol;
     SCTAB           nTab;
-    ScDocument*     pDocument;
+    ScDocument* const     pDocument;
 
     SCSIZE          nCount;
     SCSIZE          nLimit;
@@ -109,6 +109,7 @@ public:
             ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttrArray* pNextColAttrArray = nullptr, bool bCreateEmpty = false );
             ~ScAttrArray();
 
+    ScDocument* GetDoc() { return pDocument; }
     void    SetTab(SCTAB nNewTab)   { nTab = nNewTab; }
     void    SetCol(SCCOL nNewCol)   { nCol = nNewCol; }
 #if DEBUG_SC_TESTATTRARRAY
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 569f1ec06e5c..93ed1ce94e8d 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -29,6 +29,7 @@
 #include "mtvelements.hxx"
 #include <formula/types.hxx>
 #include <svl/zforlist.hxx>
+#include "attarray.hxx"
 
 #include <set>
 #include <vector>
@@ -137,14 +138,13 @@ class ScColumn
     // Cell values.
     sc::CellStoreType maCells;
 
-    SCCOL           nCol;
-    SCTAB           nTab;
-
-    ScAttrArray*          pAttrArray;
-    ScDocument*           pDocument;
+    ScAttrArray* pAttrArray;
 
     size_t mnBlkCountFormula;
 
+    SCCOL           nCol;
+    SCTAB           nTab;
+
 friend class ScDocument;                    // for FillInfo
 friend class ScTable;
 friend class ScValueIterator;
@@ -188,8 +188,7 @@ public:
 
     void        Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, bool bEmptyAttrArray = false);
 
-    ScDocument& GetDoc() { return *pDocument;}
-    const ScDocument& GetDoc() const { return *pDocument;}
+    ScDocument* GetDoc() const { return pAttrArray->GetDoc(); }
     SCTAB GetTab() const { return nTab; }
     SCCOL GetCol() const { return nCol; }
     sc::CellStoreType& GetCellStore() { return maCells; }
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 75b7c5bbb12f..5eb57751b312 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -115,7 +115,7 @@ void commitToColumn( const ScCellValue& rCell, ScColumn& rColumn, SCROW nRow )
             rColumn.SetRawString(nRow, *rCell.mpString);
         break;
         case CELLTYPE_EDIT:
-            rColumn.SetEditText(nRow, ScEditUtil::Clone(*rCell.mpEditText, rColumn.GetDoc()));
+            rColumn.SetEditText(nRow, ScEditUtil::Clone(*rCell.mpEditText, *rColumn.GetDoc()));
         break;
         case CELLTYPE_VALUE:
             rColumn.SetValue(nRow, rCell.mfValue);
@@ -123,7 +123,7 @@ void commitToColumn( const ScCellValue& rCell, ScColumn& rColumn, SCROW nRow )
         case CELLTYPE_FORMULA:
         {
             ScAddress aDestPos(rColumn.GetCol(), nRow, rColumn.GetTab());
-            rColumn.SetFormulaCell(nRow, new ScFormulaCell(*rCell.mpFormula, rColumn.GetDoc(), aDestPos));
+            rColumn.SetFormulaCell(nRow, new ScFormulaCell(*rCell.mpFormula, *rColumn.GetDoc(), aDestPos));
         }
         break;
         default:
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 350b5b19a67f..5c9b00ee12a1 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -88,11 +88,10 @@ ScColumn::ScColumn() :
     maBroadcasters(MAXROWCOUNT),
     maCellsEvent(this),
     maCells(maCellsEvent),
-    nCol( 0 ),
-    nTab( 0 ),
     pAttrArray( nullptr ),
-    pDocument( nullptr ),
-    mnBlkCountFormula(0)
+    mnBlkCountFormula(0),
+    nCol( 0 ),
+    nTab( 0 )
 {
     maCells.resize(MAXROWCOUNT);
 }
@@ -107,11 +106,10 @@ void ScColumn::Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, bool bEmptyA
 {
     nCol = nNewCol;
     nTab = nNewTab;
-    pDocument = pDoc;
     if ( !bEmptyAttrArray )
-        pAttrArray = new ScAttrArray( nCol, nTab, pDocument, &pDocument->maTabs[nTab]->aNextColAttrArray, bEmptyAttrArray );
+        pAttrArray = new ScAttrArray( nCol, nTab, pDoc, &pDoc->maTabs[nTab]->aNextColAttrArray, bEmptyAttrArray );
     else
-        pAttrArray = new ScAttrArray( nCol, nTab, pDocument, nullptr, true );
+        pAttrArray = new ScAttrArray( nCol, nTab, pDoc, nullptr, true );
 }
 
 SCsROW ScColumn::GetNextUnprotected( SCROW nRow, bool bUp ) const
@@ -276,7 +274,7 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const
                         aCurOrigin = aOrigin;
                         const ScFormulaCell* pFCell;
                         if (pCell->GetMatrixFlag() == MM_REFERENCE)
-                            pFCell = pDocument->GetFormulaCell(aOrigin);
+                            pFCell = GetDoc()->GetFormulaCell(aOrigin);
                         else
                             pFCell = pCell;
 
@@ -388,7 +386,7 @@ const ScPatternAttr* ScColumn::GetMostUsedPattern( SCROW nStartRow, SCROW nEndRo
     const ScPatternAttr* pMaxPattern = nullptr;
     size_t nMaxCount = 0;
 
-    ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow, pDocument->GetDefPattern() );
+    ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow, GetDoc()->GetDefPattern() );
     const ScPatternAttr* pPattern;
     SCROW nAttrRow1 = 0, nAttrRow2 = 0;
 
@@ -408,6 +406,7 @@ const ScPatternAttr* ScColumn::GetMostUsedPattern( SCROW nStartRow, SCROW nEndRo
 
 sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const
 {
+    ScDocument* pDocument = GetDoc();
     SCROW nPatStartRow, nPatEndRow;
     const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nPatStartRow, nPatEndRow, nStartRow);
     sal_uInt32 nFormat = pPattern->GetNumberFormat(pDocument->GetFormatTable());
@@ -424,7 +423,7 @@ sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const
 
 sal_uInt32 ScColumn::GetNumberFormat( SCROW nRow ) const
 {
-    return pAttrArray->GetPattern( nRow )->GetNumberFormat( pDocument->GetFormatTable() );
+    return pAttrArray->GetPattern( nRow )->GetNumberFormat( GetDoc()->GetFormatTable() );
 }
 
 SCsROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray )
@@ -493,7 +492,7 @@ void ScColumn::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rM
 void ScColumn::ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr )
 {
     const SfxItemSet* pSet = &rPatAttr.GetItemSet();
-    SfxItemPoolCache aCache( pDocument->GetPool(), pSet );
+    SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet );
 
     const ScPatternAttr* pPattern = pAttrArray->GetPattern( nRow );
 
@@ -509,7 +508,7 @@ void ScColumn::ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPattern
                                  ScEditDataArray* pDataArray )
 {
     const SfxItemSet* pSet = &rPatAttr.GetItemSet();
-    SfxItemPoolCache aCache( pDocument->GetPool(), pSet );
+    SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet );
     pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache, pDataArray );
 }
 
@@ -517,8 +516,8 @@ void ScColumn::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
         const ScPatternAttr& rPattern, short nNewType )
 {
     const SfxItemSet* pSet = &rPattern.GetItemSet();
-    SfxItemPoolCache aCache( pDocument->GetPool(), pSet );
-    SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
+    SfxItemPoolCache aCache( GetDoc()->GetPool(), pSet );
+    SvNumberFormatter* pFormatter = GetDoc()->GetFormatTable();
     SCROW nEndRow = rRange.aEnd.Row();
     for ( SCROW nRow = rRange.aStart.Row(); nRow <= nEndRow; nRow++ )
     {
@@ -611,6 +610,7 @@ const ScStyleSheet* ScColumn::GetSelectionStyle( const ScMarkData& rMark, bool&
     const ScStyleSheet* pStyle = nullptr;
     const ScStyleSheet* pNewStyle;
 
+    ScDocument* pDocument = GetDoc();
     ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
     SCROW nTop;
     SCROW nBottom;
@@ -642,7 +642,7 @@ const ScStyleSheet* ScColumn::GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRo
     const ScStyleSheet* pStyle = nullptr;
     const ScStyleSheet* pNewStyle;
 
-    ScAttrIterator aAttrIter( pAttrArray, nRow1, nRow2, pDocument->GetDefPattern() );
+    ScAttrIterator aAttrIter( pAttrArray, nRow1, nRow2, GetDoc()->GetDefPattern() );
     SCROW nRow;
     SCROW nDummy;
     const ScPatternAttr* pPattern;
@@ -699,7 +699,7 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr )
     //  in order to only create a new SetItem, we don't need SfxItemPoolCache.
     //TODO: Warning: SfxItemPoolCache seems to create to many Refs for the new SetItem ??
 
-    ScDocumentPool* pDocPool = pDocument->GetPool();
+    ScDocumentPool* pDocPool = GetDoc()->GetPool();
 
     const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow );
     std::unique_ptr<ScPatternAttr> pTemp(new ScPatternAttr(*pOldPattern));
@@ -928,7 +928,7 @@ public:
                 std::vector<EditTextObject*> aCloned;
                 aCloned.reserve(nDataSize);
                 for (; it != itEnd; ++it)
-                    aCloned.push_back(ScEditUtil::Clone(**it, mrDestCol.GetDoc()));
+                    aCloned.push_back(ScEditUtil::Clone(**it, *mrDestCol.GetDoc()));
 
                 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
                     maDestPos.miCellPos, nTopRow, aCloned.begin(), aCloned.end());
@@ -947,10 +947,10 @@ public:
                 for (; it != itEnd; ++it, aDestPos.IncRow())
                 {
                     const ScFormulaCell& rOld = **it;
-                    if (rOld.GetDirty() && mrSrcCol.GetDoc().GetAutoCalc())
+                    if (rOld.GetDirty() && mrSrcCol.GetDoc()->GetAutoCalc())
                         const_cast<ScFormulaCell&>(rOld).Interpret();
 
-                    aCloned.push_back(new ScFormulaCell(rOld, mrDestCol.GetDoc(), aDestPos));
+                    aCloned.push_back(new ScFormulaCell(rOld, *mrDestCol.GetDoc(), aDestPos));
                 }
 
                 // Group the cloned formula cells.
@@ -1047,6 +1047,7 @@ void ScColumn::CopyStaticToDocument(
 
     aDestPos.miCellPos = rDestCol.maCells.begin();
 
+    ScDocument* pDocument = GetDoc();
     std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow1);
     sc::CellStoreType::const_iterator it = aPos.first;
     size_t nOffset = aPos.second;
@@ -1158,6 +1159,7 @@ void ScColumn::CopyStaticToDocument(
 
 void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol )
 {
+    ScDocument* pDocument = GetDoc();
     std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nSrcRow);
     sc::CellStoreType::const_iterator it = aPos.first;
     bool bSet = true;
@@ -1172,10 +1174,10 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes
         case sc::element_type_edittext:
         {
             EditTextObject* p = sc::edittext_block::at(*it->data, aPos.second);
-            if (pDocument == rDestCol.pDocument)
+            if (pDocument == rDestCol.GetDoc())
                 rDestCol.maCells.set(nDestRow, p->Clone());
             else
-                rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, *rDestCol.pDocument));
+                rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, *rDestCol.GetDoc()));
         }
         break;
         case sc::element_type_formula:
@@ -1186,7 +1188,7 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes
 
             ScAddress aDestPos = p->aPos;
             aDestPos.SetRow(nDestRow);
-            ScFormulaCell* pNew = new ScFormulaCell(*p, *rDestCol.pDocument, aDestPos);
+            ScFormulaCell* pNew = new ScFormulaCell(*p, *rDestCol.GetDoc(), aDestPos);
             rDestCol.SetFormulaCell(nDestRow, pNew);
         }
         break;
@@ -1204,7 +1206,7 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes
         if (pNote)
         {
             pNote = pNote->Clone(ScAddress(nCol, nSrcRow, nTab),
-                                 rDestCol.GetDoc(),
+                                 *rDestCol.GetDoc(),
                                  ScAddress(rDestCol.nCol, nDestRow, rDestCol.nTab),
                                  false);
             rDestCol.maCellNotes.set(nDestRow, pNote);
@@ -1265,7 +1267,7 @@ class CopyAsLinkHandler
 
         ScTokenArray aArr;
         aArr.AddSingleReference(aRef);
-        return new ScFormulaCell(&mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), aArr);
+        return new ScFormulaCell(mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), aArr);
     }
 
     void createRefBlock(const sc::CellStoreType::value_type& aNode, size_t nOffset, size_t nDataSize)
@@ -1338,7 +1340,7 @@ public:
                 ScAddress aSrcPos(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab());
                 for (; it != itEnd; ++it, aSrcPos.IncRow(), ++nRow)
                 {
-                    if (!canCopyValue(mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags))
+                    if (!canCopyValue(*mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags))
                         continue;
 
                     maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, createRefCell(nRow));
@@ -1422,14 +1424,14 @@ class CopyByCloneHandler
         if (bForceFormula || bCloneFormula)
         {
             // Clone as formula cell.
-            ScFormulaCell* pCell = new ScFormulaCell(rSrcCell, mrDestCol.GetDoc(), aDestPos, mnFormulaCellCloneFlags);
+            ScFormulaCell* pCell = new ScFormulaCell(rSrcCell, *mrDestCol.GetDoc(), aDestPos, mnFormulaCellCloneFlags);
             pCell->SetDirtyVar();
             mrDestCol.SetFormulaCell(maDestPos, nRow, pCell, meListenType);
             setDefaultAttrToDest(nRow);
             return;
         }
 
-        if (mrDestCol.GetDoc().IsUndo())
+        if (mrDestCol.GetDoc()->IsUndo())
             return;
 
         if (bCloneValue)
@@ -1438,7 +1440,7 @@ class CopyByCloneHandler
             if (nErr != FormulaError::NONE)
             {
                 // error codes are cloned with values
-                ScFormulaCell* pErrCell = new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos);
+                ScFormulaCell* pErrCell = new ScFormulaCell(mrDestCol.GetDoc(), aDestPos);
                 pErrCell->SetErrCode(nErr);
                 mrDestCol.SetFormulaCell(maDestPos, nRow, pErrCell, meListenType);
                 setDefaultAttrToDest(nRow);
@@ -1450,7 +1452,7 @@ class CopyByCloneHandler
         {
             if (rSrcCell.IsValue())
             {
-                if (canCopyValue(mrSrcCol.GetDoc(), ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()), mnCopyFlags))
+                if (canCopyValue(*mrSrcCol.GetDoc(), ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab()), mnCopyFlags))
                 {
                     maDestPos.miCellPos = mrDestCol.GetCellStore().set(
                         maDestPos.miCellPos, nRow, rSrcCell.GetValue());
@@ -1471,7 +1473,7 @@ class CopyByCloneHandler
             if (rSrcCell.IsMultilineResult())
             {
                 // Clone as an edit text object.
-                EditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine();
+                EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
                 rEngine.SetText(aStr.getString());
                 maDestPos.miCellPos =
                     mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject());
@@ -1557,7 +1559,7 @@ public:
                 ScAddress aSrcPos(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab());
                 for (; it != itEnd; ++it, aSrcPos.IncRow(), ++nRow)
                 {
-                    if (!canCopyValue(mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags))
+                    if (!canCopyValue(*mrSrcCol.GetDoc(), aSrcPos, mnCopyFlags))
                         continue;
 
                     maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, *it);
@@ -1618,7 +1620,7 @@ public:
                 std::vector<EditTextObject*> aCloned;
                 aCloned.reserve(nDataSize);
                 for (; it != itEnd; ++it)
-                    aCloned.push_back(ScEditUtil::Clone(**it, mrDestCol.GetDoc()));
+                    aCloned.push_back(ScEditUtil::Clone(**it, *mrDestCol.GetDoc()));
 
                 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
                     maDestPos.miCellPos, nRow, aCloned.begin(), aCloned.end());
@@ -1703,8 +1705,8 @@ void ScColumn::CopyToColumn(
             // Compare the ScDocumentPool* to determine if we are copying
             // within the same document. If not, re-intern shared strings.
             svl::SharedStringPool* pSharedStringPool =
-                (pDocument->GetPool() != rColumn.pDocument->GetPool()) ?
-                &rColumn.pDocument->GetSharedStringPool() : nullptr;
+                (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ?
+                &rColumn.GetDoc()->GetSharedStringPool() : nullptr;
             CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
                     pSharedStringPool, bGlobalNamesToLocal);
             aFunc.setStartListening(rCxt.isStartListening());
@@ -1755,6 +1757,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const
 void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol )
 {
     //  This is the scenario table, the data is copied into it
+    ScDocument* pDocument = GetDoc();
     ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, pDocument->GetDefPattern() );
     SCROW nStart = -1, nEnd = -1;
     const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd );
@@ -1783,6 +1786,7 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol )
 void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const
 {
     //  This is the scenario table, the data is copied to the other
+    ScDocument* pDocument = GetDoc();
     ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, pDocument->GetDefPattern() );
     SCROW nStart = -1, nEnd = -1;
     const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd );
@@ -1791,7 +1795,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const
         if ( static_cast<const ScMergeFlagAttr&>(pPattern->GetItem( ATTR_MERGE_FLAG )).IsScenario() )
         {
             rDestCol.DeleteArea( nStart, nEnd, InsertDeleteFlags::CONTENTS );
-            sc::CopyToDocContext aCxt(*rDestCol.pDocument);
+            sc::CopyToDocContext aCxt(*rDestCol.GetDoc());
             CopyToColumn(aCxt, nStart, nEnd, InsertDeleteFlags::CONTENTS, false, rDestCol);
 
             sc::RefUpdateContext aRefCxt(*pDocument);
@@ -1808,7 +1812,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const
 bool ScColumn::TestCopyScenarioTo( const ScColumn& rDestCol ) const
 {
     bool bOk = true;
-    ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, pDocument->GetDefPattern() );
+    ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, GetDoc()->GetDefPattern() );
     SCROW nStart = 0, nEnd = 0;
     const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd );
     while (pPattern && bOk)
@@ -1826,7 +1830,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const
 {
     ScRange aRange( nCol, 0, nTab );
 
-    ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, pDocument->GetDefPattern() );
+    ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW, GetDoc()->GetDefPattern() );
     SCROW nStart = -1, nEnd = -1;
     const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd );
     while (pPattern)
@@ -1963,6 +1967,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
     rCol.CellStorageModified();
 
     // Broadcast on moved ranges. Area-broadcast only.
+    ScDocument* pDocument = GetDoc();
     ScHint aHint(SC_HINT_DATACHANGED, ScAddress(nCol, 0, nTab));
     ScAddress& rPos = aHint.GetAddress();
     sc::SingleColumnSpanSet::SpansType::const_iterator itRange = aRanges.begin(), itRangeEnd = aRanges.end();
@@ -2391,7 +2396,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc
     if (rCxt.meMode == URM_COPY)
         return UpdateReferenceOnCopy(rCxt, pUndoDoc);
 
-    if (IsEmptyData() || pDocument->IsClipOrUndo())
+    if (IsEmptyData() || GetDoc()->IsClipOrUndo())
         // Cells in this column are all empty, or clip or undo doc. No update needed.
         return false;
 
@@ -3140,7 +3145,7 @@ bool ScColumn::IsFormulaDirty( SCROW nRow ) const
 
 void ScColumn::CheckVectorizationState()
 {
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
     CheckVectorizationHandler aFunc;
     sc::ProcessFormula(maCells, aFunc);
 }
@@ -3148,8 +3153,8 @@ void ScColumn::CheckVectorizationState()
 void ScColumn::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
 {
     // is only done documentwide, no FormulaTracking
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
-    SetDirtyHandler aFunc(*pDocument, rCxt);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
+    SetDirtyHandler aFunc(*GetDoc(), rCxt);
     sc::ProcessFormula(maCells, aFunc);
 }
 
@@ -3157,7 +3162,7 @@ void ScColumn::SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rB
 {
     // Set all formula cells in the range dirty, and pick up all non-formula
     // cells for later broadcasting.  We don't broadcast here.
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
 
     SetDirtyOnRangeHandler aHdl(*this);
     sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl, aHdl);
@@ -3203,7 +3208,7 @@ bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint )
 void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode )
 {
     // broadcasts everything within the range, with FormulaTracking
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
 
     switch (eMode)
     {
@@ -3235,7 +3240,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode )
                     // formulas via ScDocument::Broadcast(), which
                     // BroadcastBroadcastersHandler doesn't, so explicitly
                     // track them here.
-                    pDocument->TrackFormulas();
+                    GetDoc()->TrackFormulas();
                 }
             }
             break;
@@ -3244,7 +3249,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode )
 
 void ScColumn::SetTableOpDirty( const ScRange& rRange )
 {
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
 
     SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
     SetTableOpDirtyOnRangeHandler aHdl(*this);
@@ -3254,7 +3259,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange )
 
 void ScColumn::SetDirtyAfterLoad()
 {
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
     SetDirtyAfterLoadHandler aFunc;
     sc::ProcessFormula(maCells, aFunc);
 }
@@ -3281,14 +3286,14 @@ public:
 
 void ScColumn::SetDirtyIfPostponed()
 {
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
     SetDirtyIfPostponedHandler aFunc;
     sc::ProcessFormula(maCells, aFunc);
 }
 
 void ScColumn::BroadcastRecalcOnRefMove()
 {
-    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aSwitch(*GetDoc(), false);
     RecalcOnRefMoveCollector aFunc;
     sc::ProcessFormula(maCells, aFunc);
     BroadcastCells(aFunc.getDirtyRows(), SC_HINT_DATACHANGED);
@@ -3429,7 +3434,7 @@ void ScColumn::TransferListeners(
     }
 
     // Remove any broadcasters that have no listeners.
-    RemoveEmptyBroadcasterHandler aFuncRemoveEmpty(*pDocument, nCol, nTab);
+    RemoveEmptyBroadcasterHandler aFuncRemoveEmpty(*GetDoc(), nCol, nTab);
     sc::ProcessBroadcaster(maBroadcasters.begin(), maBroadcasters, nRow1, nRow2, aFuncRemoveEmpty);
     aFuncRemoveEmpty.purge();
 }
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 0e68d17ca32e..594f00a922f0 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -129,6 +129,7 @@ long ScColumn::GetNeededSize(
     }
 
     //      conditional formatting
+    ScDocument* pDocument = GetDoc();
     const SfxItemSet* pCondSet = pDocument->GetCondResult( nCol, nRow, nTab );
 
     //The pPattern may change in GetCondResult
@@ -649,6 +650,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
 
     sal_uInt16 nWidth = static_cast<sal_uInt16>(nOldWidth*nPPTX);
     bool bFound = false;
+    ScDocument* pDocument = GetDoc();
 
     if ( pParam && pParam->mbSimpleText )
     {   // all the same except for number format
@@ -787,6 +789,7 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16
 void ScColumn::GetOptimalHeight(
     sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart )
 {
+    ScDocument* pDocument = GetDoc();
     ScFlatUInt16RowSegments& rHeights = rCxt.getHeightArray();
     ScAttrIterator aIter( pAttrArray, nStartRow, nEndRow, pDocument->GetDefPattern() );
 
@@ -979,6 +982,7 @@ void ScColumn::GetOptimalHeight(
 
 bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const
 {
+    ScDocument* pDocument = GetDoc();
     bool bStop = false;
     sc::CellStoreType::const_iterator it = maCells.position(nRow).first;
     mdds::mtv::element_t eType = it->type;
@@ -1143,7 +1147,7 @@ public:
 
 void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow )
 {
-    RemoveEditAttribsHandler aFunc(maCells, pDocument);
+    RemoveEditAttribsHandler aFunc(maCells, GetDoc());
     sc::ProcessEditText(maCells.begin(), maCells, nStartRow, nEndRow, aFunc);
     aFunc.commitStrings();
 }
@@ -1419,7 +1423,7 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const
     {
         nRow++;
         SCROW nEndRow = 0;
-        bool bHidden = pDocument->RowHidden(nRow, nTab, nullptr, &nEndRow);
+        bool bHidden = GetDoc()->RowHidden(nRow, nTab, nullptr, &nEndRow);
         if(bHidden)
             return std::min<SCROW>(MAXROW, nEndRow + 1);
         else
@@ -1429,7 +1433,7 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const
     {
         nRow--;
         SCROW nStartRow = MAXROW;
-        bool bHidden = pDocument->RowHidden(nRow, nTab, &nStartRow);
+        bool bHidden = GetDoc()->RowHidden(nRow, nTab, &nStartRow);
         if(bHidden)
             return std::max<SCROW>(0, nStartRow - 1);
         else
@@ -1440,6 +1444,7 @@ SCROW ScColumn::FindNextVisibleRow(SCROW nRow, bool bForward) const
 SCROW ScColumn::FindNextVisibleRowWithContent(
     sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const
 {
+    ScDocument* pDocument = GetDoc();
     if (bForward)
     {
         do
@@ -1681,7 +1686,7 @@ struct ColumnStorageDumper : std::unary_function<sc::CellStoreType::value_type,
 void ScColumn::DumpColumnStorage() const
 {
     cout << "-- table: " << nTab << "; column: " << nCol << endl;
-    std::for_each(maCells.begin(), maCells.end(), ColumnStorageDumper(pDocument));
+    std::for_each(maCells.begin(), maCells.end(), ColumnStorageDumper(GetDoc()));
     cout << "--" << endl;
 }
 #endif
@@ -1780,9 +1785,9 @@ public:
         SCROW nDestRow = nRow + mnDestOffset;
         ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab);
         ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab);
-        miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, mrDestCol.GetDoc(), aDestPos, mbCloneCaption));
+        miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, *mrDestCol.GetDoc(), aDestPos, mbCloneCaption));
         // Notify our LOK clients also
-        ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, &mrDestCol.GetDoc(), aDestPos, p);
+        ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, mrDestCol.GetDoc(), aDestPos, p);
     }
 };
 
@@ -1795,7 +1800,7 @@ void ScColumn::CopyCellNotesToDocument(
         // The column has no cell notes to copy between specified rows.
         return;
 
-    ScDrawLayer *pDrawLayer = rDestCol.GetDoc().GetDrawLayer();
+    ScDrawLayer *pDrawLayer = rDestCol.GetDoc()->GetDrawLayer();
     bool bWasLocked = bool();
     if (pDrawLayer)
     {
@@ -1905,7 +1910,7 @@ namespace {
 void ScColumn::CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
 {
     ScAddress aAddr(nCol, 0, nTab);
-    CellNoteHandler aFunc(pDocument, aAddr, bForgetCaptionOwnership);
+    CellNoteHandler aFunc(GetDoc(), aAddr, bForgetCaptionOwnership);
     sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
 }
 
@@ -2109,8 +2114,8 @@ formula::FormulaTokenRef ScColumn::ResolveStaticReference( SCROW nRow )
         case sc::element_type_edittext:
         {
             const EditTextObject* pText = sc::edittext_block::at(*it->data, aPos.second);
-            OUString aStr = ScEditUtil::GetString(*pText, pDocument);
-            svl::SharedString aSS( pDocument->GetSharedStringPool().intern(aStr));
+            OUString aStr = ScEditUtil::GetString(*pText, GetDoc());
+            svl::SharedString aSS( GetDoc()->GetSharedStringPool().intern(aStr));
             return formula::FormulaTokenRef(new formula::FormulaStringToken(aSS));
         }
         case sc::element_type_empty:
@@ -2167,7 +2172,7 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow
     if (nRow1 > nRow2)
         return false;
 
-    ToMatrixHandler aFunc(rMat, nMatCol, nRow1, pDocument);
+    ToMatrixHandler aFunc(rMat, nMatCol, nRow1, GetDoc());
     sc::ParseAllNonEmpty(maCells.begin(), maCells, nRow1, nRow2, aFunc);
     return true;
 }
@@ -2369,7 +2374,7 @@ public:
 
 void ScColumn::FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const
 {
-    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, nCol, nTab, pDocument, pPool);
+    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, nCol, nTab, GetDoc(), pPool);
     sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
 }
 
@@ -2639,6 +2644,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
         return formula::VectorRefArray(formula::VectorRefArray::Invalid);
 
     // See if the requested range is already cached.
+    ScDocument* pDocument = GetDoc();
     sc::FormulaGroupContext& rCxt = *(pDocument->GetFormulaGroupContext());
     sc::FormulaGroupContext::ColArray* pColArray = rCxt.getCachedColArray(nTab, nCol, nRow2+1);
     if (pColArray)
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 156afa94e687..4374d47f66d2 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -72,7 +72,7 @@ using namespace formula;
 void ScColumn::Broadcast( SCROW nRow )
 {
     ScHint aHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab));
-    pDocument->Broadcast(aHint);
+    GetDoc()->Broadcast(aHint);
 }
 
 void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, sal_uInt32 nHint )
@@ -81,6 +81,7 @@ void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, sal_uInt32 nHint
         return;
 
     // Broadcast the changes.
+    ScDocument* pDocument = GetDoc();
     ScHint aHint(nHint, ScAddress(nCol, 0, nTab));
     std::vector<SCROW>::const_iterator itRow = rRows.begin(), itRowEnd = rRows.end();
     for (; itRow != itRowEnd; ++itRow)
@@ -128,7 +129,7 @@ void ScColumn::DeleteContent( SCROW nRow, bool bBroadcast )
     if (it->type == sc::element_type_formula)
     {
         ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second);
-        p->EndListeningTo(pDocument);
+        p->EndListeningTo(GetDoc());
         sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p);
     }
     maCells.set_empty(nRow, nRow);
@@ -239,7 +240,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>*
         aNonEmptySpans.scan(aBlockPos, *this, nEndRow+1, MAXROW);
     }
 
-    sc::AutoCalcSwitch aACSwitch(*pDocument, false);
+    sc::AutoCalcSwitch aACSwitch(*GetDoc(), false);
 
     // Remove the cells.
     maCells.erase(nStartRow, nEndRow);
@@ -291,9 +292,9 @@ void ScColumn::JoinNewFormulaCell(
 void ScColumn::DetachFormulaCell(
     const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell )
 {
-    if (!pDocument->IsClipOrUndo())
+    if (!GetDoc()->IsClipOrUndo())
         // Have the dying formula cell stop listening.
-        rCell.EndListeningTo(pDocument);
+        rCell.EndListeningTo(GetDoc());
 
     sc::SharedFormulaUtil::unshareFormulaCell(aPos, rCell);
 }
@@ -347,10 +348,10 @@ void ScColumn::DetachFormulaCells(
         sc::SharedFormulaUtil::splitFormulaCellGroup(aPos2, nullptr);
     }
 
-    if (pDocument->IsClipOrUndo())
+    if (GetDoc()->IsClipOrUndo())
         return;
 
-    DetachFormulaCellsHandler aFunc(pDocument, nullptr);
+    DetachFormulaCellsHandler aFunc(GetDoc(), nullptr);
     sc::ProcessFormula(aPos.first, maCells, nRow, nNextTopRow-1, aFunc);
 }
 
@@ -366,7 +367,7 @@ void ScColumn::AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1,
         sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
     }
 
-    if (pDocument->IsClipOrUndo())
+    if (GetDoc()->IsClipOrUndo())
         return;
 
     AttachFormulaCellsHandler aFunc(rCxt);
@@ -386,10 +387,10 @@ void ScColumn::DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, S
         sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, &rCxt);
     }
 
-    if (pDocument->IsClipOrUndo())
+    if (GetDoc()->IsClipOrUndo())
         return;
 
-    DetachFormulaCellsHandler aFunc(pDocument, &rCxt);
+    DetachFormulaCellsHandler aFunc(GetDoc(), &rCxt);
     sc::ProcessFormula(it, maCells, nRow1, nRow2, aFunc);
 }
 
@@ -427,6 +428,7 @@ void ScColumn::AttachNewFormulaCell(
     // we call StartListeningFromClip and BroadcastFromClip.
     // If we insert into the Clipboard/andoDoc, we do not use a Broadcast.
     // After Import we call CalcAfterLoad and in there Listening.
+    ScDocument* pDocument = GetDoc();
     if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc())
         return;
 
@@ -473,6 +475,7 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP
     pCell = sc::formula_block::at(*aPosLast.first->data, aPosLast.second);
     JoinNewFormulaCell(aPosLast, *pCell);
 
+    ScDocument* pDocument = GetDoc();
     if (!pDocument->IsClipOrUndo() && !pDocument->IsInsertingFromOtherDoc())
     {
         sc::StartListeningContext aCxt(*pDocument);
@@ -495,7 +498,7 @@ void ScColumn::BroadcastNewCell( SCROW nRow )
     // we call StartListeningFromClip and BroadcastFromClip.
     // If we insert into the Clipboard/andoDoc, we do not use a Broadcast.
     // After Import we call CalcAfterLoad and in there Listening.
-    if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc() || pDocument->IsCalcingAfterLoad())
+    if (GetDoc()->IsClipOrUndo() || GetDoc()->IsInsertingFromOtherDoc() || GetDoc()->IsCalcingAfterLoad())
         return;
 
     Broadcast(nRow);
@@ -519,6 +522,7 @@ bool ScColumn::UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, const sc::
     ScRefCellValue aCell = GetCellValue( itr2, nOffset );
     ScAddress aPos(nCol, nRow, nTab);
 
+    ScDocument* pDocument = GetDoc();
     const SfxItemSet* pCondSet = nullptr;
     ScConditionalFormatList* pCFList = pDocument->GetCondFormList(nTab);
     if (pCFList)
@@ -711,7 +715,7 @@ void ScColumn::DeleteCells(
     sc::SingleColumnSpanSet& rDeleted )
 {
     // Determine which cells to delete based on the deletion flags.
-    DeleteAreaHandler aFunc(*pDocument, nDelFlag, *this);
+    DeleteAreaHandler aFunc(*GetDoc(), nDelFlag, *this);
     sc::CellStoreType::iterator itPos = maCells.position(rBlockPos.miCellPos, nRow1).first;
     sc::ProcessBlock(itPos, maCells, aFunc, nRow1, nRow2);
     aFunc.endFormulas(); // Have the formula cells stop listening.
@@ -844,7 +848,7 @@ class CopyCellsFromClipHandler
         aArr.AddSingleReference(aRef);
 
         mrDestCol.SetFormulaCell(
-            maDestBlockPos, nDestRow, new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos, aArr));
+            maDestBlockPos, nDestRow, new ScFormulaCell(mrDestCol.GetDoc(), aDestPos, aArr));
     }
 
     void duplicateNotes(SCROW nStartRow, size_t nDataSize, bool bCloneCaption )
@@ -1000,7 +1004,7 @@ public:
                         {
                             mrDestCol.SetFormulaCell(
                                 maDestBlockPos, nSrcRow + mnRowOffset,
-                                new ScFormulaCell(rSrcCell, mrDestCol.GetDoc(), aDestPos));
+                                new ScFormulaCell(rSrcCell, *mrDestCol.GetDoc(), aDestPos));
                         }
                     }
                     else if (bNumeric || bDateTime || bString)
@@ -1018,7 +1022,7 @@ public:
                                     insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
                                 else
                                 {
-                                    ScFormulaCell* pErrCell = new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos);
+                                    ScFormulaCell* pErrCell = new ScFormulaCell(mrDestCol.GetDoc(), aDestPos);
                                     pErrCell->SetErrCode(nErr);
                                     mrDestCol.SetFormulaCell(
                                         maDestBlockPos, nSrcRow + mnRowOffset, pErrCell);
@@ -1053,7 +1057,7 @@ public:
                             else if (rSrcCell.IsMultilineResult())
                             {
                                 // Clone as an edit text object.
-                                ScFieldEditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine();
+                                ScFieldEditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
                                 rEngine.SetText(aStr.getString());
                                 mrDestCol.SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, rEngine.CreateTextObject());
                             }
@@ -1134,6 +1138,7 @@ void ScColumn::CopyFromClip(
     if ((rCxt.getInsertFlag() & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE)
         return;
 
+    ScDocument* pDocument = GetDoc();
     if (rCxt.isAsLink() && rCxt.getInsertFlag() == InsertDeleteFlags::ALL)
     {
         // We also reference empty cells for "ALL"
@@ -1168,7 +1173,7 @@ void ScColumn::CopyFromClip(
 
     // Compare the ScDocumentPool* to determine if we are copying within the
     // same document. If not, re-intern shared strings.
-    svl::SharedStringPool* pSharedStringPool = (rColumn.pDocument->GetPool() != pDocument->GetPool()) ?
+    svl::SharedStringPool* pSharedStringPool = (rColumn.GetDoc()->GetPool() != pDocument->GetPool()) ?
         &pDocument->GetSharedStringPool() : nullptr;
 
     // nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range.
@@ -1266,7 +1271,7 @@ class MixDataHandler
         {
             ScAddress aPos(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab());
 
-            ScFormulaCell* pFC = new ScFormulaCell(&mrDestColumn.GetDoc(), aPos);
+            ScFormulaCell* pFC = new ScFormulaCell(mrDestColumn.GetDoc(), aPos);
             pFC->SetErrCode(FormulaError::NoValue);
 
             miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC);
@@ -1333,7 +1338,7 @@ public:
                 miNewCellsPos = maNewCells.set(
                     miNewCellsPos, nRow-mnRowOffset,
                     new ScFormulaCell(
-                        &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
+                        mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
             }
             break;
             case sc::element_type_string:
@@ -1390,7 +1395,7 @@ public:
                 miNewCellsPos = maNewCells.set(
                     miNewCellsPos, nRow-mnRowOffset,
                     new ScFormulaCell(
-                        &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
+                        mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
             }
             break;
             case sc::element_type_formula:
@@ -1420,7 +1425,7 @@ public:
                 miNewCellsPos = maNewCells.set(
                     miNewCellsPos, nRow-mnRowOffset,
                     new ScFormulaCell(
-                        &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
+                        mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr));
             }
             break;
             case sc::element_type_string:
@@ -1430,7 +1435,7 @@ public:
                 // Destination cell is not a number. Just take the source cell.
                 ScAddress aDestPos(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab());
                 miNewCellsPos = maNewCells.set(
-                    miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell(*p, mrDestColumn.GetDoc(), aDestPos));
+                    miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell(*p, *mrDestColumn.GetDoc(), aDestPos));
             }
             break;
             default:
@@ -1500,7 +1505,7 @@ public:
                     miNewCellsPos = maNewCells.set(
                         miNewCellsPos, nDestRow-mnRowOffset,
                         new ScFormulaCell(
-                            &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), aArr));
+                            mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), aArr));
                 }
                 break;
                 default:
@@ -1622,7 +1627,7 @@ void ScColumn::MixData(
 
 ScAttrIterator* ScColumn::CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const
 {
-    return new ScAttrIterator( pAttrArray, nStartRow, nEndRow, pDocument->GetDefPattern() );
+    return new ScAttrIterator( pAttrArray, nStartRow, nEndRow, GetDoc()->GetDefPattern() );
 }
 
 namespace {
@@ -1673,7 +1678,7 @@ namespace {
 void applyTextNumFormat( ScColumn& rCol, SCROW nRow, SvNumberFormatter* pFormatter )
 {
     sal_uInt32 nFormat = pFormatter->GetStandardFormat(css::util::NumberFormat::TEXT);
-    ScPatternAttr aNewAttrs(rCol.GetDoc().GetPool());
+    ScPatternAttr aNewAttrs(rCol.GetDoc()->GetPool());
     SfxItemSet& rSet = aNewAttrs.GetItemSet();
     rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
     rCol.ApplyPattern(nRow, aNewAttrs);
@@ -1700,7 +1705,7 @@ bool ScColumn::ParseString(
     sal_uInt32 nOldIndex = 0;
     sal_Unicode cFirstChar;
     if (!aParam.mpNumFormatter)
-        aParam.mpNumFormatter = pDocument->GetFormatTable();
+        aParam.mpNumFormatter = GetDoc()->GetFormatTable();
 
     nIndex = nOldIndex = GetNumberFormat( nRow );
     if ( rString.getLength() > 1
@@ -1709,7 +1714,7 @@ bool ScColumn::ParseString(
     else
         cFirstChar = 0; // Text
 
-    svl::SharedStringPool& rPool = pDocument->GetSharedStringPool();
+    svl::SharedStringPool& rPool = GetDoc()->GetSharedStringPool();
 
     if ( cFirstChar == '=' )
     {
@@ -1726,7 +1731,7 @@ bool ScColumn::ParseString(
         else // = Formula
             rCell.set(
                 new ScFormulaCell(
-                    pDocument, ScAddress(nCol, nRow, nTabP), rString,
+                    GetDoc(), ScAddress(nCol, nRow, nTabP), rString,
                     formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_DEFAULT, eConv),
                     MM_NONE));
     }
@@ -1862,7 +1867,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const OUString& rString,
 
 void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 {
-    pEditText->NormalizeString(pDocument->GetSharedStringPool());
+    pEditText->NormalizeString(GetDoc()->GetSharedStringPool());
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     maCells.set(it, nRow, pEditText);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
@@ -1873,7 +1878,7 @@ void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 
 void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText )
 {
-    pEditText->NormalizeString(pDocument->GetSharedStringPool());
+    pEditText->NormalizeString(GetDoc()->GetSharedStringPool());
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
@@ -1886,7 +1891,7 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, Edit
 
 void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText )
 {
-    if (pDocument->GetEditPool() == rEditText.GetPool())
+    if (GetDoc()->GetEditPool() == rEditText.GetPool())
     {
         SetEditText(rBlockPos, nRow, rEditText.Clone());
         return;
@@ -1895,7 +1900,7 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, cons
     // rats, yet another "spool"
     // Sadly there is no other way to change the Pool than to
     // "spool" the Object through a corresponding Engine
-    EditEngine& rEngine = pDocument->GetEditEngine();
+    EditEngine& rEngine = GetDoc()->GetEditEngine();
     rEngine.SetText(rEditText);
     SetEditText(rBlockPos, nRow, rEngine.CreateTextObject());
     return;
@@ -1903,7 +1908,7 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, cons
 
 void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool )
 {
-    if (pEditPool && pDocument->GetEditPool() == pEditPool)
+    if (pEditPool && GetDoc()->GetEditPool() == pEditPool)
     {
         SetEditText(nRow, rEditText.Clone());
         return;
@@ -1912,7 +1917,7 @@ void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const S
     // rats, yet another "spool"
     // Sadly there is no other way to change the Pool than to
     // "spool" the Object through a corresponding Engine
-    EditEngine& rEngine = pDocument->GetEditEngine();
+    EditEngine& rEngine = GetDoc()->GetEditEngine();
     rEngine.SetText(rEditText);
     SetEditText(nRow, rEngine.CreateTextObject());
     return;
@@ -1923,7 +1928,7 @@ void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::Form
     ScAddress aPos(nCol, nRow, nTab);
 
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
-    ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, rArray, eGram);
+    ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), aPos, rArray, eGram);
     sal_uInt32 nCellFormat = GetNumberFormat(nRow);
     if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
         pCell->SetNeedNumberFormat(true);
@@ -1940,7 +1945,7 @@ void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::Formul
     ScAddress aPos(nCol, nRow, nTab);
 
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
-    ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, rFormula, eGram);
+    ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), aPos, rFormula, eGram);
     sal_uInt32 nCellFormat = GetNumberFormat(nRow);
     if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
         pCell->SetNeedNumberFormat(true);
@@ -1999,7 +2004,7 @@ bool ScColumn::SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells
     // Detach all formula cells that will be overwritten.
     DetachFormulaCells(aPos, rCells.size());
 
-    if (!pDocument->IsClipOrUndo())
+    if (!GetDoc()->IsClipOrUndo())
     {
         for (size_t i = 0, n = rCells.size(); i < n; ++i)
         {
@@ -2056,10 +2061,10 @@ class FilterEntriesHandler
 
     void processCell(SCROW nRow, ScRefCellValue& rCell)
     {
-        SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
+        SvNumberFormatter* pFormatter = mrColumn.GetDoc()->GetFormatTable();
         OUString aStr;
         sal_uLong nFormat = mrColumn.GetNumberFormat(nRow);
-        ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, &mrColumn.GetDoc());
+        ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, mrColumn.GetDoc());
 
         if (rCell.hasString())
         {
@@ -2307,8 +2312,8 @@ bool ScColumn::GetDataEntries(
     // going upward and downward directions in parallel. The start position
     // cell must be skipped.
 
-    StrCellIterator aItrUp(maCells, nStartRow, pDocument);
-    StrCellIterator aItrDown(maCells, nStartRow+1, pDocument);
+    StrCellIterator aItrUp(maCells, nStartRow, GetDoc());
+    StrCellIterator aItrDown(maCells, nStartRow+1, GetDoc());
 
     bool bMoveUp = aItrUp.valid();
     if (!bMoveUp)
@@ -2424,7 +2429,7 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow )
     FormulaToValueHandler aFunc;
     sc::CellStoreType::const_iterator itPos = maCells.begin();
 
-    ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow, pDocument->GetDefPattern() );
+    ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow, GetDoc()->GetDefPattern() );
     SCROW nTop = -1;
     SCROW nBottom = -1;
     const ScPatternAttr* pPattern = aAttrIter.Next( nTop, nBottom );
@@ -2450,7 +2455,7 @@ void ScColumn::SetError( SCROW nRow, const FormulaError nError)
     if (!ValidRow(nRow))
         return;
 
-    ScFormulaCell* pCell = new ScFormulaCell(pDocument, ScAddress(nCol, nRow, nTab));
+    ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), ScAddress(nCol, nRow, nTab));
     pCell->SetErrCode(nError);
 
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
@@ -2467,7 +2472,7 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr )
     if (!ValidRow(nRow))
         return;
 
-    svl::SharedString aSS = pDocument->GetSharedStringPool().intern(rStr);
+    svl::SharedString aSS = GetDoc()->GetSharedStringPool().intern(rStr);
     if (!aSS.getData())
         return;
 
@@ -2546,7 +2551,7 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const
 
     sal_uLong nFormat = GetNumberFormat(nRow);
     Color* pColor = nullptr;
-    ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()), pDocument);
+    ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(GetDoc()->GetFormatTable()), GetDoc());
 }
 
 double* ScColumn::GetValueCell( SCROW nRow )
@@ -2566,7 +2571,7 @@ void ScColumn::GetInputString( SCROW nRow, OUString& rString ) const
 {
     ScRefCellValue aCell = GetCellValue(nRow);
     sal_uLong nFormat = GetNumberFormat(nRow);
-    ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable()), pDocument);
+    ScCellFormat::GetInputString(aCell, nFormat, rString, *(GetDoc()->GetFormatTable()), GetDoc());
 }
 
 double ScColumn::GetValue( SCROW nRow ) const
@@ -2774,7 +2779,7 @@ class MaxStringLenHandler
         Color* pColor;
         OUString aString;
         sal_uInt32 nFormat = static_cast<const SfxUInt32Item&>(mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT)).GetValue();
-        ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, &mrColumn.GetDoc());
+        ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, mrColumn.GetDoc());
         sal_Int32 nLen = 0;
         if (mbOctetEncoding)
         {
@@ -2801,7 +2806,7 @@ public:
     MaxStringLenHandler(const ScColumn& rColumn, rtl_TextEncoding eCharSet) :
         mnMaxLen(0),
         mrColumn(rColumn),
-        mpFormatter(rColumn.GetDoc().GetFormatTable()),
+        mpFormatter(rColumn.GetDoc()->GetFormatTable()),
         meCharSet(eCharSet),
         mbOctetEncoding(rtl_isOctetTextEncoding(eCharSet))
     {
@@ -2884,7 +2889,7 @@ class MaxNumStringLenHandler
         if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET)
         {
             aSep = mpFormatter->GetFormatDecimalSep(nFormat);
-            ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter, &mrColumn.GetDoc());
+            ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter, mrColumn.GetDoc());
             const SvNumberformat* pEntry = mpFormatter->GetEntry(nFormat);
             if (pEntry)
             {
@@ -2968,7 +2973,7 @@ class MaxNumStringLenHandler
 
 public:
     MaxNumStringLenHandler(const ScColumn& rColumn, sal_uInt16 nMaxGeneralPrecision) :
-        mrColumn(rColumn), mpFormatter(rColumn.GetDoc().GetFormatTable()),
+        mrColumn(rColumn), mpFormatter(rColumn.GetDoc()->GetFormatTable()),
         mnMaxLen(0), mnPrecision(0), mnMaxGeneralPrecision(nMaxGeneralPrecision),
         mbHaveSigned(false)
     {
@@ -3000,7 +3005,7 @@ public:
 sal_Int32 ScColumn::GetMaxNumberStringLen(
     sal_uInt16& nPrecision, SCROW nRowStart, SCROW nRowEnd ) const
 {
-    sal_uInt16 nMaxGeneralPrecision = pDocument->GetDocOptions().GetStdPrecision();
+    sal_uInt16 nMaxGeneralPrecision = GetDoc()->GetDocOptions().GetStdPrecision();
     MaxNumStringLenHandler aFunc(*this, nMaxGeneralPrecision);
     sc::ParseFormulaNumeric(maCells.begin(), maCells, nRowStart, nRowEnd, aFunc);
     nPrecision = aFunc.getPrecision();
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index a50092c0ea9b..b08d0f27049c 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -112,6 +112,7 @@ void ScColumn::DeleteBeforeCopyFromClip(
         return;
 
     // Translate the clip column spans into the destination column, and repeat as needed.
+    ScDocument* pDocument = GetDoc();
     std::vector<sc::RowSpan> aDestSpans;
     SCROW nDestOffset = aRange.mnRow1 - nClipRow1;
     bool bContinue = true;
@@ -197,6 +198,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
     if (!pBlockPos)
         return;
 
+    ScDocument* pDocument = GetDoc();
     bool bSameDocPool = (rCxt.getClipDoc()->GetPool() == pDocument->GetPool());
 
     ScCellValue& rSrcCell = rCxt.getSingleCell(nColOffset);
@@ -549,6 +551,7 @@ void ScColumn::CloneFormulaCell(
                 "ScColumn::CloneFormulaCell - cloning array/matrix with not exactly one column or row as single cell");
     }
 
+    ScDocument* pDocument = GetDoc();
     std::vector<ScFormulaCell*> aFormulas;
     std::vector<sc::RowSpan>::const_iterator itSpan = rRanges.begin(), itSpanEnd = rRanges.end();
     for (; itSpan != itSpanEnd; ++itSpan)
@@ -913,7 +916,7 @@ void ScColumn::PreprocessRangeNameUpdate(
     aOps.insert(ocBad);
     aOps.insert(ocColRowName);
     aOps.insert(ocName);
-    RecompileByOpcodeHandler aFunc(pDocument, aOps, rEndListenCxt, rCompileCxt);
+    RecompileByOpcodeHandler aFunc(GetDoc(), aOps, rEndListenCxt, rCompileCxt);
     std::for_each(aGroups.begin(), aGroups.end(), aFunc);
 }
 
@@ -928,7 +931,7 @@ void ScColumn::PreprocessDBDataUpdate(
     aOps.insert(ocColRowName);
     aOps.insert(ocDBArea);
     aOps.insert(ocTableRef);
-    RecompileByOpcodeHandler aFunc(pDocument, aOps, rEndListenCxt, rCompileCxt);
+    RecompileByOpcodeHandler aFunc(GetDoc(), aOps, rEndListenCxt, rCompileCxt);
     std::for_each(aGroups.begin(), aGroups.end(), aFunc);
 }
 
@@ -938,7 +941,7 @@ void ScColumn::CompileHybridFormula(
     // Collect all formula groups.
     std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
 
-    CompileHybridFormulaHandler aFunc(pDocument, rStartListenCxt, rCompileCxt);
+    CompileHybridFormulaHandler aFunc(GetDoc(), rStartListenCxt, rCompileCxt);
     std::for_each(aGroups.begin(), aGroups.end(), aFunc);
 }
 
@@ -980,15 +983,15 @@ private:
             const ScCondFormatItem& rItem =
                 static_cast<const ScCondFormatItem&>(pPat->GetItem(ATTR_CONDITIONAL));
             const std::vector<sal_uInt32>& rData = rItem.GetCondFormatData();
-            pCondSet = mrCol.GetDoc().GetCondResult(rCell, maPos, *mpCFList, rData);
+            pCondSet = mrCol.GetDoc()->GetCondResult(rCell, maPos, *mpCFList, rData);
         }
 
         OUString aStr;
         Color* pColor;
         sal_uLong nFormat = pPat->GetNumberFormat(mpFormatter, pCondSet);
-        ScCellFormat::GetString(rCell, nFormat, aStr, &pColor, *mpFormatter, &mrCol.GetDoc());
+        ScCellFormat::GetString(rCell, nFormat, aStr, &pColor, *mpFormatter, mrCol.GetDoc());
 
-        rAttr.mnScriptType = mrCol.GetDoc().GetStringScriptType(aStr);
+        rAttr.mnScriptType = mrCol.GetDoc()->GetStringScriptType(aStr);
         mbUpdated = true;
     }
 
@@ -997,8 +1000,8 @@ public:
         mrCol(rCol),
         mrTextAttrs(rCol.GetCellAttrStore()),
         miPosAttr(mrTextAttrs.begin()),
-        mpCFList(rCol.GetDoc().GetCondFormList(rCol.GetTab())),
-        mpFormatter(rCol.GetDoc().GetFormatTable()),
+        mpCFList(rCol.GetDoc()->GetCondFormList(rCol.GetTab())),
+        mpFormatter(rCol.GetDoc()->GetFormatTable()),
         maPos(rCol.GetCol(), 0, rCol.GetTab()),
         mbUpdated(false)
     {}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index b02004948ac9..90b2aced24af 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -945,9 +945,9 @@ bool ScCellIterator::getCurrent()
         SCROW nLastRow;
         // Skip all filtered or hidden rows, depending on mSubTotalFlags
         if ( ( ( mnSubTotalFlags & SubtotalFlags::IgnoreFiltered ) &&
-               pCol->GetDoc().RowFiltered(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) ||
+               pCol->GetDoc()->RowFiltered(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) ||
              ( ( mnSubTotalFlags & SubtotalFlags::IgnoreHidden ) &&
-               pCol->GetDoc().RowHidden(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) )
+               pCol->GetDoc()->RowHidden(maCurPos.Row(), maCurPos.Tab(), nullptr, &nLastRow) ) )
         {
             setPos(nLastRow+1);
             continue;
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 81cfd9c277b0..1b2b77e42f07 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -151,7 +151,7 @@ void setSuffixCell(
     ScColumn& rColumn, SCROW nRow, sal_Int32 nValue, sal_uInt16 nDigits, const OUString& rSuffix,
     CellType eCellType, bool bIsOrdinalSuffix )
 {
-    ScDocument& rDoc = rColumn.GetDoc();
+    ScDocument& rDoc = *rColumn.GetDoc();
     OUString aValue = lcl_ValueString(nValue, nDigits);
     if (!bIsOrdinalSuffix)
     {
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index fe37938210b0..aefdbdde7af4 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2855,7 +2855,7 @@ public:
                 case CELLTYPE_STRING:
                 case CELLTYPE_EDIT:
                 {
-                    OUString aStr = aCell.getString(&mpCurCol->GetDoc());
+                    OUString aStr = aCell.getString(mpCurCol->GetDoc());
                     svl::SharedString aSS = mrStrPool.intern(aStr);
                     pTok.reset(new formula::FormulaStringToken(aSS));
                 }


More information about the Libreoffice-commits mailing list