sc/inc/cellformtmpl.hxx                                |    2 
 sc/inc/cellvalue.hxx                                   |   11 -
 sc/inc/chgtrack.hxx                                    |   28 ++--
 sc/inc/dbdata.hxx                                      |    2 
 sc/inc/editutil.hxx                                    |   18 +-
 sc/inc/filter.hxx                                      |   12 -
 sc/inc/global.hxx                                      |    4 
 sc/inc/rangecache.hxx                                  |    4 
 sc/inc/spellcheckcontext.hxx                           |    4 
 sc/qa/unit/subsequent_filters_test4.cxx                |   23 ++-
 sc/qa/unit/ucalc.cxx                                   |    4 
 sc/source/core/data/cellvalue.cxx                      |   16 +-
 sc/source/core/data/column.cxx                         |    2 
 sc/source/core/data/column2.cxx                        |   52 +++----
 sc/source/core/data/column3.cxx                        |   14 +-
 sc/source/core/data/conditio.cxx                       |    2 
 sc/source/core/data/dociter.cxx                        |    4 
 sc/source/core/data/documen2.cxx                       |    2 
 sc/source/core/data/document.cxx                       |    2 
 sc/source/core/data/global.cxx                         |   14 --
 sc/source/core/data/queryiter.cxx                      |    2 
 sc/source/core/data/table4.cxx                         |   12 -
 sc/source/core/data/validat.cxx                        |    2 
 sc/source/core/tool/cellform.cxx                       |    4 
 sc/source/core/tool/chgtrack.cxx                       |  115 ++++++++---------
 sc/source/core/tool/dbdata.cxx                         |   10 -
 sc/source/core/tool/editutil.cxx                       |   59 +++-----
 sc/source/core/tool/interpr3.cxx                       |    4 
 sc/source/core/tool/interpr4.cxx                       |   12 -
 sc/source/core/tool/interpr5.cxx                       |    2 
 sc/source/core/tool/rangecache.cxx                     |   22 +--
 sc/source/core/tool/rangeseq.cxx                       |    2 
 sc/source/filter/dif/difexp.cxx                        |   22 +--
 sc/source/filter/excel/excel.cxx                       |    2 
 sc/source/filter/html/htmlimp.cxx                      |   42 +++---
 sc/source/filter/html/htmlpars.cxx                     |   51 +++----
 sc/source/filter/inc/eeimport.hxx                      |    4 
 sc/source/filter/inc/ftools.hxx                        |   12 -
 sc/source/filter/inc/htmlimp.hxx                       |    2 
 sc/source/filter/inc/htmlpars.hxx                      |   12 -
 sc/source/filter/inc/rtfimp.hxx                        |    2 
 sc/source/filter/oox/worksheethelper.cxx               |    2 
 sc/source/filter/rtf/eeimpars.cxx                      |   76 +++++------
 sc/source/filter/rtf/rtfimp.cxx                        |   12 -
 sc/source/filter/xcl97/XclExpChangeTrack.cxx           |    4 
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx |    8 -
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx |   10 -
 sc/source/filter/xml/xmlexprt.cxx                      |   10 -
 sc/source/ui/app/transobj.cxx                          |    2 
 sc/source/ui/docshell/docsh.cxx                        |    6 
 sc/source/ui/docshell/docsh3.cxx                       |    8 -
 sc/source/ui/docshell/externalrefmgr.cxx               |    4 
 sc/source/ui/docshell/impex.cxx                        |    6 
 sc/source/ui/miscdlgs/acredlin.cxx                     |    4 
 sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx          |    4 
 sc/source/ui/undo/undoblk.cxx                          |    8 -
 sc/source/ui/undo/undoblk3.cxx                         |    6 
 sc/source/ui/unoobj/cellsuno.cxx                       |    2 
 sc/source/ui/view/cellsh1.cxx                          |    2 
 sc/source/ui/view/output2.cxx                          |    6 
 sc/source/ui/view/spellcheckcontext.cxx                |   17 +-
 sc/source/ui/view/tabview.cxx                          |    2 
 sc/source/ui/view/viewdata.cxx                         |    8 -
 sc/source/ui/view/viewfun2.cxx                         |    2 
 sc/source/ui/view/viewfun4.cxx                         |    2 
 sc/source/ui/view/viewfunc.cxx                         |    2 
 66 files changed, 397 insertions(+), 431 deletions(-)

New commits:
commit ae5220b761f131126641e11ab691d39d22e1bc74
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu May 15 13:47:45 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri May 16 21:57:28 2025 +0200

    ScEditUtil::GetString: pass ScDocument by ref
    
    allowing to drop ScGlobal::GetStaticFieldEditEngine();
    It was added in
    
    commit 1ecdc7aaf661e97a33cf521f553481d79cd26de2
    Author: Eike Rathke <er...@redhat.com>
    Date:   Thu Jul 25 15:33:49 2013 +0200
    
        resolved fdo#67249 use ScFieldEditEngine to resolve field content
    
    Also adapt the testRichTextContentODS unittest
    
    Change-Id: I06eb1b2b4fcc35867531c645098d854dd9907bc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185406
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/inc/cellformtmpl.hxx b/sc/inc/cellformtmpl.hxx
index a36ba17a8bbb..7526f29c321c 100644
--- a/sc/inc/cellformtmpl.hxx
+++ b/sc/inc/cellformtmpl.hxx
@@ -41,7 +41,7 @@ auto ScCellFormat::visitInputSharedString(const 
ScRefCellValue& rCell, sal_uInt3
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            return rOper(rCell.getSharedString(&rDoc, rStrPool));
+            return rOper(rCell.getSharedString(rDoc, rStrPool));
         case CELLTYPE_VALUE:
             return rOper(rStrPool.intern(rContext.NFGetInputLineString(
                 rCell.getDouble(), nFormat, bFiltering, bForceSystemLocale)));
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index bfbe228a8575..b618efa31a4d 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -169,15 +169,12 @@ public:
      *
      *  Note that this method is NOT thread-safe.
      *
-     *  @param  pDoc
+     *  @param  rDoc
      *          Needed to resolve EditCells' field contents, obtain a
-     *          ScFieldEditEngine from that document. May be NULL if there is
-     *          no ScDocument in the calling context but then the document
-     *          specific fields can not be resolved. See
-     *          ScEditUtil::GetString().
+     *          ScFieldEditEngine from that document.
      */
-    SC_DLLPUBLIC OUString getString( const ScDocument* pDoc ) const;
-    SC_DLLPUBLIC svl::SharedString getSharedString( const ScDocument* pDoc, 
svl::SharedStringPool& rStrPool ) const;
+    SC_DLLPUBLIC OUString getString( const ScDocument& rDoc ) const;
+    SC_DLLPUBLIC svl::SharedString getSharedString( const ScDocument& rDoc, 
svl::SharedStringPool& rStrPool ) const;
 
     /**
      * Retrieve a string value without modifying the states of any objects in
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 5b781f98d64c..259d79b786e1 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -631,10 +631,10 @@ class SAL_DLLPUBLIC_RTTI ScChangeActionContent final : 
public ScChangeAction
     void ClearTrack();
 
     static OUString GetStringOfCell(
-        const ScCellValue& rCell, const ScDocument* pDoc, const ScAddress& 
rPos );
+        const ScCellValue& rCell, const ScDocument& rDoc, const ScAddress& 
rPos );
 
     static OUString GetStringOfCell(
-        const ScCellValue& rCell, const ScDocument* pDoc, sal_uLong nFormat );
+        const ScCellValue& rCell, const ScDocument& rDoc, sal_uLong nFormat );
 
     static void SetValue( OUString& rStr, ScCellValue& rCell, const ScAddress& 
rPos,
                           const ScCellValue& rOrgCell, const ScDocument* 
pFromDoc,
@@ -644,14 +644,14 @@ class SAL_DLLPUBLIC_RTTI ScChangeActionContent final : 
public ScChangeAction
                           const ScCellValue& rOrgCell, const ScDocument* 
pFromDoc,
                           ScDocument* pToDoc );
 
-    static void SetCell( OUString& rStr, const ScCellValue& rCell, sal_uLong 
nFormat, const ScDocument* pDoc );
+    static void SetCell( OUString& rStr, const ScCellValue& rCell, sal_uLong 
nFormat, const ScDocument& rDoc );
 
     static bool NeedsNumberFormat( const ScCellValue& rVal );
 
     void SetValueString( OUString& rValue, ScCellValue& rCell, const OUString& 
rStr, ScDocument* pDoc );
 
     OUString GetValueString( const OUString& rValue, const ScCellValue& rCell,
-                             const ScDocument* pDoc ) const;
+                             const ScDocument& rDoc ) const;
 
     OUString GetFormulaString( const ScFormulaCell* pCell ) const;
 
@@ -685,11 +685,11 @@ public:
         const sal_uLong nRejectingNumber, const ScBigRange& aBigRange,
         const OUString& aUser, const DateTime& aDateTime,
         const OUString &sComment, ScCellValue aOldCell,
-        const ScDocument* pDoc, const OUString& sOldValue ); // to use for XML 
Import
+        const ScDocument& rDoc, const OUString& sOldValue ); // to use for XML 
Import
 
     ScChangeActionContent(
         const sal_uLong nActionNumber, ScCellValue aNewCell,
-        const ScBigRange& aBigRange, const ScDocument* pDoc,
+        const ScBigRange& aBigRange, const ScDocument& rDoc,
         const OUString& sNewValue ); // to use for XML Import of Generated 
Actions
 
     virtual ~ScChangeActionContent() override;
@@ -716,12 +716,12 @@ public:
     // Used in import filter AppendContentOnTheFly,
     void SetOldNewCells(
         const ScCellValue& rOldCell, sal_uLong nOldFormat,
-        const ScCellValue& rNewCell, sal_uLong nNewFormat, const ScDocument* 
pDoc );
+        const ScCellValue& rNewCell, sal_uLong nNewFormat, const ScDocument& 
rDoc );
 
     // Use this only in the XML import,
     // takes ownership of cell.
     void SetNewCell(
-        const ScCellValue& rCell, const ScDocument* pDoc, const OUString& 
rFormatted );
+        const ScCellValue& rCell, const ScDocument& rDoc, const OUString& 
rFormatted );
 
                         // These functions should be protected but for
                         // the XML import they are public.
@@ -734,8 +734,8 @@ public:
     // assigns string / creates formula cell
     void SetOldValue( const OUString& rOld, ScDocument* pDoc );
 
-    OUString GetOldString( const ScDocument* pDoc ) const;
-    OUString GetNewString( const ScDocument* pDoc ) const;
+    OUString GetOldString( const ScDocument& rDoc ) const;
+    OUString GetNewString( const ScDocument& rDoc ) const;
     const ScCellValue& GetOldCell() const { return maOldCell;}
     const ScCellValue& GetNewCell() const { return maNewCell;}
     virtual OUString GetDescription(
@@ -886,7 +886,7 @@ class SAL_DLLPUBLIC_RTTI ScChangeTrack final : public 
utl::ConfigurationListener
     void                SetLastMerge( sal_uLong nVal ) { nLastMerge = nVal; }
     sal_uLong               GetLastMerge() const { return nLastMerge; }
 
-    void                SetLastCutMoveRange( const ScRange&, ScDocument* );
+    void                SetLastCutMoveRange( const ScRange&, ScDocument& );
 
                         // create block of ModifyMsg
     void                StartBlockModify( ScChangeTrackMsgType,
@@ -1000,11 +1000,11 @@ public:
                         // after new value was set in the document,
                         // old value from RefDoc/UndoDoc
     void                AppendContent( const ScAddress& rPos,
-                            const ScDocument* pRefDoc );
+                            const ScDocument& rRefDoc );
                         // after new values were set in the document,
                         // old values from RefDoc/UndoDoc
     void                AppendContentRange( const ScRange& rRange,
-                            ScDocument* pRefDoc,
+                            ScDocument& rRefDoc,
                             sal_uLong& nStartAction, sal_uLong& nEndAction,
                             ScChangeActionClipMode eMode = SC_CACM_NONE );
                         // after new value was set in the document,
@@ -1132,7 +1132,7 @@ public:
     bool IsTimeNanoSeconds() const { return bTimeNanoSeconds; }
 
     void AppendCloned( ScChangeAction* pAppend );
-    SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument* pDocument ) const;
+    SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument& rDocument ) const;
     static void MergeActionState( ScChangeAction* pAct, const ScChangeAction* 
pOtherAct );
     /// Get info about all ScChangeAction elements.
     void GetChangeTrackInfo(tools::JsonWriter&);
diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 11cc5465f91f..5a587c982b19 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -162,7 +162,7 @@ public:
 
     /** Refresh/update the column names with the header row's cell contents
         within the given range. */
-    void RefreshTableColumnNames( ScDocument* pDoc, const ScRange& rRange );
+    void RefreshTableColumnNames( ScDocument& rDoc, const ScRange& rRange );
 
     /** Finds the column named rName and returns the corresponding offset
         within the table.
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 7bd593d34a5a..368690019913 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -35,7 +35,7 @@ class ScEditEngineDefaulter;
 
 class ScEditUtil
 {
-    ScDocument*     pDoc;
+    ScDocument&     rDoc;
     SCCOL           nCol;
     SCROW           nRow;
     SCTAB           nTab;
@@ -54,17 +54,15 @@ public:
     static OUString GetSpaceDelimitedString( const EditEngine& rEngine );
 
     /// Retrieves string with paragraphs delimited by new lines ('
').
-    static OUString GetMultilineString( const EditEngine& rEngine );
+    SC_DLLPUBLIC static OUString GetMultilineString( const EditEngine& rEngine 
);
     static OUString GetMultilineString( const EditTextObject& rEdit );
 
     /** Retrieves string with paragraphs delimited by new lines ('
').
 
-        @param pDoc
-               If not NULL, use pDoc->GetEditEngine() to retrieve field 
content.
-               If NULL, a static mutex-guarded ScFieldEditEngine is used that
-               is not capable of resolving document specific fields; avoid.
+        @param rDoc
+               use rDoc.GetEditEngine() to retrieve field content.
      */
-    SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, 
const ScDocument* pDoc );
+    SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, 
const ScDocument& rDoc );
 
     static std::unique_ptr<EditTextObject> CreateURLObjectFromURL(
         ScDocument& rDoc, const OUString& rURL, const OUString& rText );
@@ -77,7 +75,7 @@ public:
         const SvxFieldData& rFieldData, const ScDocument* pDoc, 
std::optional<Color>* ppTextColor, std::optional<FontLineStyle>* ppFldLineStyle 
);
 
 public:
-                ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB 
nZ,
+                ScEditUtil( ScDocument& rDocument, SCCOL nX, SCROW nY, SCTAB 
nZ,
                             const Point& rCellPos,
                             OutputDevice* pDevice, double nScaleX, double 
nScaleY,
                             const Fraction& rX, const Fraction& rY, bool 
bPrintTwips = false );
@@ -195,9 +193,9 @@ class SC_DLLPUBLIC ScTabEditEngine final : public 
ScFieldEditEngine
 private:
     void    Init(const ScPatternAttr& rPattern);
 public:
-    ScTabEditEngine( ScDocument* pDoc );            // Default
+    ScTabEditEngine( ScDocument& rDoc );            // Default
     ScTabEditEngine(const ScPatternAttr& rPattern,
-                    SfxItemPool *pEngineItemPool, ScDocument *pDoc,
+                    SfxItemPool *pEngineItemPool, ScDocument& rDoc,
                     SfxItemPool* pTextObjectPool = nullptr );
 };
 
diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx
index 6bceb74b69d0..e6a4c85d1b66 100644
--- a/sc/inc/filter.hxx
+++ b/sc/inc/filter.hxx
@@ -66,20 +66,20 @@ class SAL_DLLPUBLIC_RTTI ScFormatFilterPlugin {
         // eFormat == EIF_BIFF_LE4 -> only non storage files _might_ be read 
successfully
     virtual ErrCode ScImportDif( SvStream&, ScDocument*, const ScAddress& 
rInsPos,
                  const rtl_TextEncoding eSrc ) = 0;
-    virtual ErrCode ScImportRTF( SvStream&, const OUString& rBaseURL, 
ScDocument*, ScRange& rRange ) = 0;
-    virtual ErrCode ScImportHTML( SvStream&, const OUString& rBaseURL, 
ScDocument*, ScRange& rRange, double nOutputFactor,
+    virtual ErrCode ScImportRTF( SvStream&, const OUString& rBaseURL, 
ScDocument&, ScRange& rRange ) = 0;
+    virtual ErrCode ScImportHTML( SvStream&, const OUString& rBaseURL, 
ScDocument&, ScRange& rRange, double nOutputFactor,
                                    bool bCalcWidthHeight, SvNumberFormatter* 
pFormatter, bool bConvertDate,
                                    bool bConvertScientific ) = 0;
 
     // various import helpers
-    virtual std::unique_ptr<ScEEAbsImport> CreateRTFImport( ScDocument* pDoc, 
const ScRange& rRange ) = 0;
-    virtual std::unique_ptr<ScEEAbsImport> CreateHTMLImport( ScDocument* 
pDocP, const OUString& rBaseURL, const ScRange& rRange ) = 0;
+    virtual std::unique_ptr<ScEEAbsImport> CreateRTFImport( ScDocument& rDoc, 
const ScRange& rRange ) = 0;
+    virtual std::unique_ptr<ScEEAbsImport> CreateHTMLImport( ScDocument& rDoc, 
const OUString& rBaseURL, const ScRange& rRange ) = 0;
     virtual OUString       GetHTMLRangeNameList( ScDocument& rDoc, const 
OUString& rOrigName ) = 0;
 
     // various export filters
     virtual ErrCode ScExportExcel5( SfxMedium&, ScDocument*, ExportFormatExcel 
eFormat, rtl_TextEncoding eDest ) = 0;
-    virtual void ScExportDif( SvStream&, ScDocument*, const ScAddress& 
rOutPos, const rtl_TextEncoding eDest ) = 0;
-    virtual void ScExportDif( SvStream&, ScDocument*, const ScRange& rRange, 
const rtl_TextEncoding eDest ) = 0;
+    virtual void ScExportDif( SvStream&, ScDocument&, const ScAddress& 
rOutPos, const rtl_TextEncoding eDest ) = 0;
+    virtual void ScExportDif( SvStream&, ScDocument&, const ScRange& rRange, 
const rtl_TextEncoding eDest ) = 0;
     virtual void ScExportHTML( SvStream&, const OUString& rBaseURL, 
ScDocument*, const ScRange& rRange, const rtl_TextEncoding eDest, bool bAll,
                   const OUString& rStreamPath, OUString& rNonConvertibleChars, 
const OUString& rFilterOptions ) = 0;
     virtual void ScExportRTF( SvStream&, ScDocument*, const ScRange& rRange, 
const rtl_TextEncoding eDest ) = 0;
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index ca35a1c968e1..7a29f97eb7b6 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -698,10 +698,6 @@ public:
     /** Obtain the ordinal suffix for a number according to the system locale 
*/
     static OUString         GetOrdinalSuffix( sal_Int32 nNumber);
 
-    /** A static instance of ScFieldEditEngine not capable of resolving
-        document specific fields, to be used only by ScEditUtil::GetString(). 
*/
-    static ScFieldEditEngine&   GetStaticFieldEditEngine();
-
     static sc::SharedStringPoolPurge& GetSharedStringPoolPurge();
 
     /** Replaces the first occurrence of rPlaceholder in rString with
diff --git a/sc/inc/rangecache.hxx b/sc/inc/rangecache.hxx
index 0e04d47c4ad9..c9920c22126d 100644
--- a/sc/inc/rangecache.hxx
+++ b/sc/inc/rangecache.hxx
@@ -44,7 +44,7 @@ class ScSortedRangeCache final : public SvtListener
 {
 public:
     /// MUST be new'd because Notify() deletes.
-    ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, const 
ScQueryParam& param,
+    ScSortedRangeCache(ScDocument& rDoc, const ScRange& rRange, const 
ScQueryParam& param,
                        ScInterpreterContext* context, bool invalid = false,
                        bool bNewSearchFunction = false, sal_uInt8 
nSortedBinarySearch = 0x00);
 
@@ -117,7 +117,7 @@ private:
     std::vector<size_t> mRowToIndex; // indexed by 'SCROW - 
maRange.aStart.Row()'
     std::vector<size_t> mColToIndex; // indexed by 'SCCOL - 
maRange.aStart.Col()'
     ScRange maRange;
-    ScDocument* mpDoc;
+    ScDocument& mrDoc;
     bool mValid;
     bool mRowSearch;
     ValueType mValueType;
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
index dc5f09449039..9d69c44c1e7b 100644
--- a/sc/inc/spellcheckcontext.hxx
+++ b/sc/inc/spellcheckcontext.hxx
@@ -55,14 +55,14 @@ class SpellCheckContext
 
     std::unique_ptr<SpellCheckCache> mpCache;
     std::unique_ptr<SpellCheckResult> mpResult;
-    ScDocument* pDoc;
+    ScDocument& rDoc;
     std::unique_ptr<ScTabEditEngine> mpEngine;
     std::unique_ptr<SpellCheckStatus> mpStatus;
     SCTAB mnTab;
     LanguageType meLanguage;
 
 public:
-    SpellCheckContext(ScDocument* pDocument, SCTAB nTab);
+    SpellCheckContext(ScDocument& rDocument, SCTAB nTab);
     ~SpellCheckContext();
     void dispose();
 
diff --git a/sc/qa/unit/subsequent_filters_test4.cxx 
b/sc/qa/unit/subsequent_filters_test4.cxx
index d8f11d5a3493..94b9bec45d2a 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -515,8 +515,11 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, 
testRichTextContentODS)
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.startsWith("Sheet 
name is "));
     CPPUNIT_ASSERT_MESSAGE("Sheet name field item not found.",
                            pEditText->HasField(text::textfield::Type::TABLE));
-    CPPUNIT_ASSERT_EQUAL(u"Sheet name is Test."_ustr, 
ScEditUtil::GetString(*pEditText, pDoc));
-    CPPUNIT_ASSERT_EQUAL(u"Sheet name is ?."_ustr, 
ScEditUtil::GetString(*pEditText, nullptr));
+    CPPUNIT_ASSERT_EQUAL(u"Sheet name is Test."_ustr, 
ScEditUtil::GetString(*pEditText, *pDoc));
+
+    ScFieldEditEngine* pEE = new ScFieldEditEngine(nullptr, nullptr);
+    pEE->SetText(*pEditText);
+    CPPUNIT_ASSERT_EQUAL(u"Sheet name is ?."_ustr, 
ScEditUtil::GetMultilineString(*pEE));
 
     // Cell with URL field item.
     aPos.IncRow();
@@ -529,9 +532,9 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRichTextContentODS)
     CPPUNIT_ASSERT_MESSAGE("URL field item not found.",
                            pEditText->HasField(text::textfield::Type::URL));
     CPPUNIT_ASSERT_EQUAL(u"URL: http://libreoffice.org"_ustr,
-                         ScEditUtil::GetString(*pEditText, pDoc));
-    CPPUNIT_ASSERT_EQUAL(u"URL: http://libreoffice.org"_ustr,
-                         ScEditUtil::GetString(*pEditText, nullptr));
+                         ScEditUtil::GetString(*pEditText, *pDoc));
+    pEE->SetText(*pEditText);
+    CPPUNIT_ASSERT_EQUAL(u"URL: http://libreoffice.org"_ustr, 
ScEditUtil::GetMultilineString(*pEE));
 
     // Cell with Date field item.
     aPos.IncRow();
@@ -544,9 +547,10 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, 
testRichTextContentODS)
     CPPUNIT_ASSERT_MESSAGE("Date field item not found.",
                            pEditText->HasField(text::textfield::Type::DATE));
     CPPUNIT_ASSERT_MESSAGE("Date field not resolved with pDoc->",
-                           ScEditUtil::GetString(*pEditText, 
pDoc).indexOf("/20") > 0);
+                           ScEditUtil::GetString(*pEditText, 
*pDoc).indexOf("/20") > 0);
+    pEE->SetText(*pEditText);
     CPPUNIT_ASSERT_MESSAGE("Date field not resolved with NULL.",
-                           ScEditUtil::GetString(*pEditText, 
nullptr).indexOf("/20") > 0);
+                           ScEditUtil::GetMultilineString(*pEE).indexOf("/20") 
> 0);
 
     // Cell with DocInfo title field item.
     aPos.IncRow();
@@ -558,8 +562,9 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRichTextContentODS)
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.startsWith("Title: 
"));
     CPPUNIT_ASSERT_MESSAGE("DocInfo title field item not found.",
                            
pEditText->HasField(text::textfield::Type::DOCINFO_TITLE));
-    CPPUNIT_ASSERT_EQUAL(u"Title: Test Document"_ustr, 
ScEditUtil::GetString(*pEditText, pDoc));
-    CPPUNIT_ASSERT_EQUAL(u"Title: ?"_ustr, ScEditUtil::GetString(*pEditText, 
nullptr));
+    CPPUNIT_ASSERT_EQUAL(u"Title: Test Document"_ustr, 
ScEditUtil::GetString(*pEditText, *pDoc));
+    pEE->SetText(*pEditText);
+    CPPUNIT_ASSERT_EQUAL(u"Title: ?"_ustr, 
ScEditUtil::GetMultilineString(*pEE));
 
     // Cell with sentence with both bold and italic sequences.
     aPos.IncRow();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5d54396872b7..71025aabcaf8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1182,10 +1182,10 @@ bool Test::checkHorizontalIterator(ScDocument& rDoc, 
const std::vector<std::vect
             return false;
         }
 
-        if (OUString::createFromAscii(pChecks[i].pVal) != 
pCell->getString(&rDoc))
+        if (OUString::createFromAscii(pChecks[i].pVal) != 
pCell->getString(rDoc))
         {
             cerr << "String mismatch " << pChecks[i].pVal << " vs. " <<
-                pCell->getString(&rDoc) << endl;
+                pCell->getString(rDoc) << endl;
             return false;
         }
     }
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index 0f972fc534e3..b637158f39da 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -187,7 +187,7 @@ bool hasNumericImpl( CellType eType, ScFormulaCell* 
pFormula )
 }
 
 template <typename T>
-OUString getStringImpl( const T& rCell, const ScDocument* pDoc )
+OUString getStringImpl( const T& rCell, const ScDocument& rDoc )
 {
     switch (rCell.getType())
     {
@@ -197,7 +197,7 @@ OUString getStringImpl( const T& rCell, const ScDocument* 
pDoc )
             return rCell.getSharedString()->getString();
         case CELLTYPE_EDIT:
             if (rCell.getEditText())
-                return ScEditUtil::GetString(*rCell.getEditText(), pDoc);
+                return ScEditUtil::GetString(*rCell.getEditText(), rDoc);
         break;
         case CELLTYPE_FORMULA:
             return rCell.getFormula()->GetString().getString();
@@ -218,7 +218,7 @@ OUString getRawStringImpl( const CellT& rCell, const 
ScDocument& rDoc )
             return rCell.getSharedString()->getString();
         case CELLTYPE_EDIT:
             if (rCell.getEditText())
-                return ScEditUtil::GetString(*rCell.getEditText(), &rDoc);
+                return ScEditUtil::GetString(*rCell.getEditText(), rDoc);
         break;
         case CELLTYPE_FORMULA:
             return rCell.getFormula()->GetRawString().getString();
@@ -514,7 +514,7 @@ void ScCellValue::release( ScColumn& rColumn, SCROW nRow, 
sc::StartListeningType
 
 OUString ScCellValue::getString( const ScDocument& rDoc ) const
 {
-    return getStringImpl(*this, &rDoc);
+    return getStringImpl(*this, rDoc);
 }
 
 bool ScCellValue::isEmpty() const
@@ -655,12 +655,12 @@ double ScRefCellValue::getRawValue() const
     return 0.0;
 }
 
-OUString ScRefCellValue::getString( const ScDocument* pDoc ) const
+OUString ScRefCellValue::getString( const ScDocument& rDoc ) const
 {
-    return getStringImpl(*this, pDoc);
+    return getStringImpl(*this, rDoc);
 }
 
-svl::SharedString ScRefCellValue::getSharedString( const ScDocument* pDoc, 
svl::SharedStringPool& rStrPool ) const
+svl::SharedString ScRefCellValue::getSharedString( const ScDocument& rDoc, 
svl::SharedStringPool& rStrPool ) const
 {
     switch (getType())
     {
@@ -670,7 +670,7 @@ svl::SharedString ScRefCellValue::getSharedString( const 
ScDocument* pDoc, svl::
             return *getSharedString();
         case CELLTYPE_EDIT:
             if (auto pEditText = getEditText())
-                return rStrPool.intern(ScEditUtil::GetString(*pEditText, 
pDoc));
+                return rStrPool.intern(ScEditUtil::GetString(*pEditText, 
rDoc));
             break;
         case CELLTYPE_FORMULA:
             return getFormula()->GetString();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 15060d98c1b3..5efe9da8a1af 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -957,7 +957,7 @@ void ScColumn::CopyStaticToDocument(
                 for (; itData != itDataEnd; ++itData)
                 {
                     const EditTextObject& rObj = **itData;
-                    svl::SharedString aSS = 
rDocument.GetSharedStringPool().intern(ScEditUtil::GetString(rObj, &rDocument));
+                    svl::SharedString aSS = 
rDocument.GetSharedStringPool().intern(ScEditUtil::GetString(rObj, rDocument));
                     aConverted.push_back(aSS);
                 }
                 aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, 
nCurRow, aConverted.begin(), aConverted.end());
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index b32e48b14e9d..b2aa37dd78e5 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1179,14 +1179,14 @@ protected:
     };
 
     std::vector<StrEntry> maStrEntries;
-    ScDocument* mpDoc;
+    ScDocument& mrDoc;
 
-    StrEntries(sc::CellStoreType& rCells, ScDocument* pDoc) : mrCells(rCells), 
mpDoc(pDoc) {}
+    StrEntries(sc::CellStoreType& rCells, ScDocument& rDoc) : mrCells(rCells), 
mrDoc(rDoc) {}
 
 public:
     void commitStrings()
     {
-        svl::SharedStringPool& rPool = mpDoc->GetSharedStringPool();
+        svl::SharedStringPool& rPool = mrDoc.GetSharedStringPool();
         sc::CellStoreType::iterator it = mrCells.begin();
         for (const auto& rStrEntry : maStrEntries)
             it = mrCells.set(it, rStrEntry.mnRow, 
rPool.intern(rStrEntry.maStr));
@@ -1198,7 +1198,7 @@ class RemoveEditAttribsHandler : public StrEntries
     std::unique_ptr<ScFieldEditEngine> mpEngine;
 
 public:
-    RemoveEditAttribsHandler(sc::CellStoreType& rCells, ScDocument* pDoc) : 
StrEntries(rCells, pDoc) {}
+    RemoveEditAttribsHandler(sc::CellStoreType& rCells, ScDocument& rDoc) : 
StrEntries(rCells, rDoc) {}
 
     void operator() (size_t nRow, EditTextObject*& pObj)
     {
@@ -1210,10 +1210,10 @@ public:
         //  test for attributes
         if (!mpEngine)
         {
-            mpEngine.reset(new ScFieldEditEngine(mpDoc, mpDoc->GetEditPool()));
+            mpEngine.reset(new ScFieldEditEngine(&mrDoc, mrDoc.GetEditPool()));
             //  EEControlBits::ONLINESPELLING if there are errors already
             mpEngine->SetControlWord(mpEngine->GetControlWord() | 
EEControlBits::ONLINESPELLING);
-            mpDoc->ApplyAsianEditSettings(*mpEngine);
+            mrDoc.ApplyAsianEditSettings(*mpEngine);
         }
         mpEngine->SetTextCurrentDefaults(*pObj);
         sal_Int32 nParCount = mpEngine->GetParagraphCount();
@@ -1274,7 +1274,7 @@ public:
 
 void ScColumn::RemoveEditAttribs( sc::ColumnBlockPosition& rBlockPos, SCROW 
nStartRow, SCROW nEndRow )
 {
-    RemoveEditAttribsHandler aFunc(maCells, &GetDoc());
+    RemoveEditAttribsHandler aFunc(maCells, GetDoc());
 
     rBlockPos.miCellPos = sc::ProcessEditText(
         rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc);
@@ -2444,7 +2444,7 @@ 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, &GetDoc());
+            OUString aStr = ScEditUtil::GetString(*pText, GetDoc());
             svl::SharedString aSS( 
GetDoc().GetSharedStringPool().intern(aStr));
             return formula::FormulaTokenRef(new 
formula::FormulaStringToken(std::move(aSS)));
         }
@@ -2462,12 +2462,12 @@ class ToMatrixHandler
     ScMatrix& mrMat;
     SCCOL mnMatCol;
     SCROW mnTopRow;
-    ScDocument* mpDoc;
+    ScDocument& mrDoc;
     svl::SharedStringPool& mrStrPool;
 public:
-    ToMatrixHandler(ScMatrix& rMat, SCCOL nMatCol, SCROW nTopRow, ScDocument* 
pDoc) :
+    ToMatrixHandler(ScMatrix& rMat, SCCOL nMatCol, SCROW nTopRow, ScDocument& 
rDoc) :
         mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow),
-        mpDoc(pDoc), mrStrPool(pDoc->GetSharedStringPool()) {}
+        mrDoc(rDoc), mrStrPool(rDoc.GetSharedStringPool()) {}
 
     void operator() (size_t nRow, double fVal)
     {
@@ -2491,7 +2491,7 @@ public:
 
     void operator() (size_t nRow, const EditTextObject* pStr)
     {
-        mrMat.PutString(mrStrPool.intern(ScEditUtil::GetString(*pStr, mpDoc)), 
mnMatCol, nRow - mnTopRow);
+        mrMat.PutString(mrStrPool.intern(ScEditUtil::GetString(*pStr, mrDoc)), 
mnMatCol, nRow - mnTopRow);
     }
 };
 
@@ -2502,7 +2502,7 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, 
SCCOL nMatCol, SCROW nRow
     if (nRow1 > nRow2)
         return false;
 
-    ToMatrixHandler aFunc(rMat, nMatCol, nRow1, &GetDoc());
+    ToMatrixHandler aFunc(rMat, nMatCol, nRow1, GetDoc());
     sc::ParseAllNonEmpty(maCells.begin(), maCells, nRow1, nRow2, aFunc);
     return true;
 }
@@ -2556,14 +2556,14 @@ class FillMatrixHandler
     size_t mnMatCol;
     size_t mnTopRow;
 
-    ScDocument* mpDoc;
+    ScDocument& mrDoc;
     svl::SharedStringPool& mrPool;
     svl::SharedStringPool* mpPool; // if matrix is not in the same document
 
 public:
-    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, 
ScDocument* pDoc, svl::SharedStringPool* pPool) :
+    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, 
ScDocument& rDoc, svl::SharedStringPool* pPool) :
         mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow),
-        mpDoc(pDoc), mrPool(pDoc->GetSharedStringPool()), mpPool(pPool) {}
+        mrDoc(rDoc), mrPool(rDoc.GetSharedStringPool()), mpPool(pPool) {}
 
     void operator() (const sc::CellStoreType::value_type& node, size_t 
nOffset, size_t nDataSize)
     {
@@ -2607,7 +2607,7 @@ public:
                 std::advance(itEnd, nDataSize);
                 for (; it != itEnd; ++it)
                 {
-                    OUString aStr = ScEditUtil::GetString(**it, mpDoc);
+                    OUString aStr = ScEditUtil::GetString(**it, mrDoc);
                     if (!mpPool)
                         aSSs.push_back(mrPool.intern(aStr));
                     else
@@ -2700,7 +2700,7 @@ public:
 
 void ScColumn::FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW 
nRow2, svl::SharedStringPool* pPool ) const
 {
-    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, &GetDoc(), pPool);
+    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, GetDoc(), pPool);
     sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
 }
 
@@ -2727,10 +2727,10 @@ void getBlockIterators(
 }
 
 bool appendToBlock(
-    ScDocument* pDoc, sc::FormulaGroupContext& rCxt, 
sc::FormulaGroupContext::ColArray& rColArray,
+    ScDocument& rDoc, sc::FormulaGroupContext& rCxt, 
sc::FormulaGroupContext::ColArray& rColArray,
     size_t nPos, size_t nArrayLen, const sc::CellStoreType::iterator& _it, 
const sc::CellStoreType::iterator& itEnd )
 {
-    svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
+    svl::SharedStringPool& rPool = rDoc.GetSharedStringPool();
     size_t nLenRemain = nArrayLen - nPos;
 
     for (sc::CellStoreType::iterator it = _it; it != itEnd; ++it)
@@ -2755,7 +2755,7 @@ bool appendToBlock(
 
                 for (; itData != itDataEnd; ++itData, ++nPos)
                 {
-                    OUString aStr = ScEditUtil::GetString(**itData, pDoc);
+                    OUString aStr = ScEditUtil::GetString(**itData, rDoc);
                     (*rColArray.mpStrArray)[nPos] = 
rPool.intern(aStr).getData();
                 }
             }
@@ -2870,7 +2870,7 @@ void copyFirstStringBlock(
             for (; it != itEnd; ++it, ++itArray)
             {
                 EditTextObject* pText = *it;
-                OUString aStr = ScEditUtil::GetString(*pText, &rDoc);
+                OUString aStr = ScEditUtil::GetString(*pText, rDoc);
                 *itArray = rPool.intern(aStr).getData();
             }
         }
@@ -3027,7 +3027,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( 
SCROW nRow1, SCROW nRow2
             // Fill the remaining array with values from the following blocks.
             size_t nPos = itBlk->size;
             ++itBlk;
-            if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
+            if (!appendToBlock(rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
             {
                 rCxt.discardCachedColArray(nTab, nCol);
                 return 
formula::VectorRefArray(formula::VectorRefArray::Invalid);
@@ -3063,7 +3063,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( 
SCROW nRow1, SCROW nRow2
             // Fill the remaining array with values from the following blocks.
             size_t nPos = itBlk->size;
             ++itBlk;
-            if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
+            if (!appendToBlock(rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
             {
                 rCxt.discardCachedColArray(nTab, nCol);
                 return 
formula::VectorRefArray(formula::VectorRefArray::Invalid);
@@ -3111,7 +3111,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( 
SCROW nRow1, SCROW nRow2
 
             size_t nPos = itBlk->size;
             ++itBlk;
-            if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
+            if (!appendToBlock(rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
             {
                 rCxt.discardCachedColArray(nTab, nCol);
                 return 
formula::VectorRefArray(formula::VectorRefArray::Invalid);
@@ -3145,7 +3145,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( 
SCROW nRow1, SCROW nRow2
             // Fill the remaining array with values from the following blocks.
             size_t nPos = itBlk->size;
             ++itBlk;
-            if (!appendToBlock(&rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
+            if (!appendToBlock(rDocument, rCxt, *pColArray, nPos, nRow2+1, 
itBlk, maCells.end()))
             {
                 rCxt.discardCachedColArray(nTab, nCol);
                 return 
formula::VectorRefArray(formula::VectorRefArray::Invalid);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 973bdaeb7c09..05a97dd02930 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2829,12 +2829,12 @@ class StrCellIterator
     PosType maPos;
     sc::CellStoreType::const_iterator miBeg;
     sc::CellStoreType::const_iterator miEnd;
-    const ScDocument* mpDoc;
+    const ScDocument& mrDoc;
 public:
-    StrCellIterator(const sc::CellStoreType& rCells, SCROW nStart, const 
ScDocument* pDoc) :
-        miBeg(rCells.begin()), miEnd(rCells.end()), mpDoc(pDoc)
+    StrCellIterator(const sc::CellStoreType& rCells, SCROW nStart, const 
ScDocument& rDoc) :
+        miBeg(rCells.begin()), miEnd(rCells.end()), mrDoc(rDoc)
     {
-        if (pDoc->ValidRow(nStart))
+        if (rDoc.ValidRow(nStart))
             maPos = rCells.position(nStart);
         else
             // Make this iterator invalid.
@@ -2932,7 +2932,7 @@ public:
             case sc::element_type_edittext:
             {
                 const EditTextObject* p = 
sc::edittext_block::at(*maPos.first->data, maPos.second);
-                return ScEditUtil::GetString(*p, mpDoc);
+                return ScEditUtil::GetString(*p, mrDoc);
             }
             default:
                 ;
@@ -2951,8 +2951,8 @@ bool ScColumn::GetDataEntries(
     // going upward and downward directions in parallel. The start position
     // cell must be skipped.
 
-    StrCellIterator aItrUp(maCells, nStartRow, &GetDoc());
-    StrCellIterator aItrDown(maCells, nStartRow+1, &GetDoc());
+    StrCellIterator aItrUp(maCells, nStartRow, GetDoc());
+    StrCellIterator aItrDown(maCells, nStartRow+1, GetDoc());
 
     bool bMoveUp = aItrUp.valid();
     if (!bMoveUp)
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 4882dcbc63ee..36aa0f853cc5 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -784,7 +784,7 @@ static bool lcl_GetCellContent( const ScRefCellValue& 
rCell, bool bIsStr1, doubl
             if (rCell.getType() == CELLTYPE_STRING)
                 rArgStr = rCell.getSharedString()->getString();
             else if (rCell.getEditText())
-                rArgStr = ScEditUtil::GetString(*rCell.getEditText(), &rDoc);
+                rArgStr = ScEditUtil::GetString(*rCell.getEditText(), rDoc);
         break;
         default:
             ;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6b90faf2b06e..fa72e915010a 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -452,7 +452,7 @@ bool 
ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
                         incPos();
                     else
                     {
-                        rValue.maString = aCell.getString(&mrDoc);
+                        rValue.maString = aCell.getString(mrDoc);
                         rValue.mfValue = 0.0;
                         rValue.mnError = FormulaError::NONE;
                         rValue.mbIsNumber = false;
@@ -981,7 +981,7 @@ bool ScCellIterator::getCurrent()
 
 OUString ScCellIterator::getString() const
 {
-    return maCurCell.getString(&mrDoc);
+    return maCurCell.getString(mrDoc);
 }
 
 ScCellValue ScCellIterator::getCellValue() const
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 2fb75cb6e777..4dd8638b83fb 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1283,7 +1283,7 @@ ScSortedRangeCache& ScDocument::GetSortedRangeCache( 
const ScRange & rRange, con
     auto [findIt, bInserted] = mxScSortedRangeCache->aCacheMap.emplace(key, 
nullptr);
     if (bInserted)
     {
-        findIt->second = std::make_unique<ScSortedRangeCache>(this, rRange, 
param, pContext, invalid, bNewSearchFunction, nSortedBinarySearch);
+        findIt->second = std::make_unique<ScSortedRangeCache>(*this, rRange, 
param, pContext, invalid, bNewSearchFunction, nSortedBinarySearch);
         StartListeningArea(rRange, false, findIt->second.get());
     }
     return *findIt->second;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 029d53e0f393..d183b996339e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3634,7 +3634,7 @@ FormulaError ScDocument::GetStringForFormula( const 
ScAddress& rPos, OUString& r
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            aStr = aCell.getString(this);
+            aStr = aCell.getString(*this);
         break;
         case CELLTYPE_FORMULA:
         {
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index ad62505d2f54..bc00dff5b131 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -1153,20 +1153,6 @@ css::lang::Locale& ScGlobal::GetLocale()
         []() { return new css::lang::Locale( 
Application::GetSettings().GetLanguageTag().getLocale()); });
 }
 
-ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine()
-{
-    assert(!bThreadedGroupCalcInProgress);
-    if (!xFieldEditEngine)
-    {
-        // Creating a ScFieldEditEngine with pDocument=NULL leads to document
-        // specific fields not being resolvable! See
-        // ScFieldEditEngine::CalcFieldValue(). pEnginePool=NULL lets
-        // EditEngine internally create and delete a default pool.
-        xFieldEditEngine.reset(new ScFieldEditEngine( nullptr, nullptr));
-    }
-    return *xFieldEditEngine;
-}
-
 sc::SharedStringPoolPurge& ScGlobal::GetSharedStringPoolPurge()
 {
     return *comphelper::doubleCheckedInit( pSharedStringPoolPurge,
diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index 6ef734720575..0334dbab42d4 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -219,7 +219,7 @@ void ScQueryCellIteratorBase< accessType, queryType 
>::PerformQuery()
                             if (bNumSearch)
                                 rItemTmp.mfVal = aBFCell.getValue();
                             else if (bStringSearch)
-                                rItemTmp.maString = 
svl::SharedString(aBFCell.getString(&rDoc));
+                                rItemTmp.maString = 
svl::SharedString(aBFCell.getString(rDoc));
 
                             ScQueryEvaluator queryEvaluatorTmp(rDoc, 
*rDoc.maTabs[nTab], aParamTmp, &mrContext, nullptr, bNewSearchFunction);
                             if (queryEvaluatorTmp.ValidQuery(nRow, (nCol == 
static_cast<SCCOL>(nFirstQueryField) ? &aCell : nullptr)))
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 9f33d0dc6d24..edbcbe5e2543 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -496,7 +496,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
                         CellType eType = aCell.getType();
                         if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT)
                         {
-                            aStr2 = aCell.getString(&rDocument);
+                            aStr2 = aCell.getString(rDocument);
                             nFlag2 = lcl_DecompValueString(aStr2, nVal2, 
&rMinDigits);
                             if (nFlag1 == nFlag2 && aStr == aStr2)
                             {
@@ -740,7 +740,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
                         CellType eType = aCell.getType();
                         if ( eType == CELLTYPE_STRING || eType == 
CELLTYPE_EDIT )
                         {
-                            aStr = aCell.getString(&rDocument);
+                            aStr = aCell.getString(rDocument);
                             nFlag2 = lcl_DecompValueString( aStr, nVal2, 
&rMinDigits );
                             if ( nFlag1 == nFlag2 )
                             {
@@ -1467,7 +1467,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
                     case CELLTYPE_STRING:
                     case CELLTYPE_EDIT:
                     {
-                        aValue = aCell.getString(&rDocument);
+                        aValue = aCell.getString(rDocument);
 
                         if ( !(nScFillModeMouseModifier & KEY_MOD1) )
                         {
@@ -1547,7 +1547,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
                     case CELLTYPE_STRING:
                     case CELLTYPE_EDIT:
                     {
-                        aValue = aCell.getString(&rDocument);
+                        aValue = aCell.getString(rDocument);
                         nHeadNoneTail = lcl_DecompValueString( aValue, nVal );
                         if ( nHeadNoneTail )
                             nStart = static_cast<double>(nVal);
@@ -1991,7 +1991,7 @@ void ScTable::FillAutoSimple(
                             if (aSrcCell.getType() == CELLTYPE_STRING)
                                 aValue = 
aSrcCell.getSharedString()->getString();
                             else
-                                aValue = 
ScEditUtil::GetString(*aSrcCell.getEditText(), &rDocument);
+                                aValue = 
ScEditUtil::GetString(*aSrcCell.getEditText(), rDocument);
                             if ( !(nScFillModeMouseModifier & KEY_MOD1) && 
!bHasFiltered )
                             {
                                 nCellDigits = 0;    // look at each source 
cell individually
@@ -2544,7 +2544,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
                 if (eCellType == CELLTYPE_STRING)
                     aValue = aSrcCell.getSharedString()->getString();
                 else
-                    aValue = ScEditUtil::GetString(*aSrcCell.getEditText(), 
&rDocument);
+                    aValue = ScEditUtil::GetString(*aSrcCell.getEditText(), 
rDocument);
                 sal_Int32 nStringValue;
                 sal_uInt16 nMinDigits = nArgMinDigits;
                 short nHeadNoneTail = lcl_DecompValueString( aValue, 
nStringValue, &nMinDigits );
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 54104849740b..9c044ed697f6 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -620,7 +620,7 @@ bool ScValidationData::IsDataValid( const ScRefCellValue& 
rCell, const ScAddress
         break;
         case CELLTYPE_EDIT:
             if (rCell.getEditText())
-                aString = ScEditUtil::GetString(*rCell.getEditText(), 
&GetDocument());
+                aString = ScEditUtil::GetString(*rCell.getEditText(), 
GetDocument());
             bIsVal = false;
         break;
         case CELLTYPE_FORMULA:
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index d2933814ce8d..c598d0dad509 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -49,7 +49,7 @@ OUString ScCellFormat::GetString( const ScRefCellValue& 
rCell, sal_uInt32 nForma
         case CELLTYPE_EDIT:
         {
             OUString str;
-            rContext.NFGetOutputString(rCell.getString(&rDoc), nFormat, str, 
ppColor );
+            rContext.NFGetOutputString(rCell.getString(rDoc), nFormat, str, 
ppColor );
             return str;
         }
         case CELLTYPE_VALUE:
@@ -140,7 +140,7 @@ OUString ScCellFormat::GetInputString(
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            return rCell.getString(&rDoc);
+            return rCell.getString(rDoc);
         case CELLTYPE_VALUE:
             return rContext.NFGetInputLineString(rCell.getDouble(), nFormat, 
bFiltering, bForceSystemLocale);
         break;
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index e054d3e91004..fadd12a536af 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1245,7 +1245,7 @@ ScChangeActionContent::ScChangeActionContent( const 
sal_uLong nActionNumber,
             const ScChangeActionState eStateP, const sal_uLong 
nRejectingNumber,
             const ScBigRange& aBigRangeP, const OUString& aUserP,
             const DateTime& aDateTimeP, const OUString& sComment,
-            ScCellValue aOldCell, const ScDocument* pDoc, const OUString& 
sOldValue ) :
+            ScCellValue aOldCell, const ScDocument& rDoc, const OUString& 
sOldValue ) :
     ScChangeAction(SC_CAT_CONTENT, aBigRangeP, nActionNumber, 
nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment),
     maOldCell(std::move(aOldCell)),
     maOldValue(sOldValue),
@@ -1255,7 +1255,7 @@ ScChangeActionContent::ScChangeActionContent( const 
sal_uLong nActionNumber,
     ppPrevInSlot(nullptr)
 {
     if (!maOldCell.isEmpty())
-        SetCell(maOldValue, maOldCell, 0, pDoc);
+        SetCell(maOldValue, maOldCell, 0, rDoc);
 
     if (!sOldValue.isEmpty()) // #i40704# don't overwrite SetCell result with 
empty string
         maOldValue = sOldValue; // set again, because SetCell removes it
@@ -1263,7 +1263,7 @@ ScChangeActionContent::ScChangeActionContent( const 
sal_uLong nActionNumber,
 
 ScChangeActionContent::ScChangeActionContent( const sal_uLong nActionNumber,
             ScCellValue aNewCell, const ScBigRange& aBigRangeP,
-            const ScDocument* pDoc, const OUString& sNewValue ) :
+            const ScDocument& rDoc, const OUString& sNewValue ) :
     ScChangeAction(SC_CAT_CONTENT, aBigRangeP, nActionNumber),
     maNewCell(std::move(aNewCell)),
     maNewValue(sNewValue),
@@ -1273,7 +1273,7 @@ ScChangeActionContent::ScChangeActionContent( const 
sal_uLong nActionNumber,
     ppPrevInSlot(nullptr)
 {
     if (!maNewCell.isEmpty())
-        SetCell(maNewValue, maNewCell, 0, pDoc);
+        SetCell(maNewValue, maNewCell, 0, rDoc);
 
     if (!sNewValue.isEmpty()) // #i40704# don't overwrite SetCell result with 
empty string
         maNewValue = sNewValue; // set again, because SetCell removes it
@@ -1338,19 +1338,19 @@ void ScChangeActionContent::SetNewValue( const 
ScCellValue& rCell, ScDocument* p
 
 void ScChangeActionContent::SetOldNewCells(
     const ScCellValue& rOldCell, sal_uLong nOldFormat, const ScCellValue& 
rNewCell,
-    sal_uLong nNewFormat, const ScDocument* pDoc )
+    sal_uLong nNewFormat, const ScDocument& rDoc )
 {
     maOldCell = rOldCell;
     maNewCell = rNewCell;
-    SetCell(maOldValue, maOldCell, nOldFormat, pDoc);
-    SetCell(maNewValue, maNewCell, nNewFormat, pDoc);
+    SetCell(maOldValue, maOldCell, nOldFormat, rDoc);
+    SetCell(maNewValue, maNewCell, nNewFormat, rDoc);
 }
 
 void ScChangeActionContent::SetNewCell(
-    const ScCellValue& rCell, const ScDocument* pDoc, const OUString& 
rFormatted )
+    const ScCellValue& rCell, const ScDocument& rDoc, const OUString& 
rFormatted )
 {
     maNewCell = rCell;
-    SetCell(maNewValue, maNewCell, 0, pDoc);
+    SetCell(maNewValue, maNewCell, 0, rDoc);
 
     // #i40704# allow to set formatted text here - don't call SetNewValue with 
string from XML filter
     if (!rFormatted.isEmpty())
@@ -1378,14 +1378,14 @@ void ScChangeActionContent::SetOldValue( const 
OUString& rOld, ScDocument* pDoc
     SetValueString(maOldValue, maOldCell, rOld, pDoc);
 }
 
-OUString ScChangeActionContent::GetOldString( const ScDocument* pDoc ) const
+OUString ScChangeActionContent::GetOldString( const ScDocument& rDoc ) const
 {
-    return GetValueString(maOldValue, maOldCell, pDoc);
+    return GetValueString(maOldValue, maOldCell, rDoc);
 }
 
-OUString ScChangeActionContent::GetNewString( const ScDocument* pDoc ) const
+OUString ScChangeActionContent::GetNewString( const ScDocument& rDoc ) const
 {
-    return GetValueString(maNewValue, maNewCell, pDoc);
+    return GetValueString(maNewValue, maNewCell, rDoc);
 }
 
 OUString ScChangeActionContent::GetDescription(
@@ -1404,7 +1404,7 @@ OUString ScChangeActionContent::GetDescription(
         nPos += aTmpStr.getLength();
     }
 
-    aTmpStr = GetOldString( &rDoc );
+    aTmpStr = GetOldString( rDoc );
     if (aTmpStr.isEmpty())
         aTmpStr = ScResId( STR_CHANGED_BLANK );
 
@@ -1415,7 +1415,7 @@ OUString ScChangeActionContent::GetDescription(
         nPos += aTmpStr.getLength();
     }
 
-    aTmpStr = GetNewString( &rDoc );
+    aTmpStr = GetNewString( rDoc );
     if (aTmpStr.isEmpty())
         aTmpStr = ScResId( STR_CHANGED_BLANK );
 
@@ -1540,16 +1540,16 @@ bool ScChangeActionContent::Select( ScDocument& rDoc, 
ScChangeTrack* pTrack,
 }
 
 OUString ScChangeActionContent::GetStringOfCell(
-    const ScCellValue& rCell, const ScDocument* pDoc, const ScAddress& rPos )
+    const ScCellValue& rCell, const ScDocument& rDoc, const ScAddress& rPos )
 {
     if (NeedsNumberFormat(rCell))
-        return GetStringOfCell(rCell, pDoc, 
pDoc->GetNumberFormat(ScRange(rPos)));
+        return GetStringOfCell(rCell, rDoc, 
rDoc.GetNumberFormat(ScRange(rPos)));
     else
-        return GetStringOfCell(rCell, pDoc, 0);
+        return GetStringOfCell(rCell, rDoc, 0);
 }
 
 OUString ScChangeActionContent::GetStringOfCell(
-    const ScCellValue& rCell, const ScDocument* pDoc, sal_uLong nFormat )
+    const ScCellValue& rCell, const ScDocument& rDoc, sal_uLong nFormat )
 {
     if (!GetContentCellType(rCell))
         return OUString();
@@ -1557,12 +1557,12 @@ OUString ScChangeActionContent::GetStringOfCell(
     switch (rCell.getType())
     {
         case CELLTYPE_VALUE:
-            return 
pDoc->GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat);
+            return 
rDoc.GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat);
         case CELLTYPE_STRING:
             return rCell.getSharedString()->getString();
         case CELLTYPE_EDIT:
             if (rCell.getEditText())
-                return ScEditUtil::GetString(*rCell.getEditText(), pDoc);
+                return ScEditUtil::GetString(*rCell.getEditText(), rDoc);
             return OUString();
         case CELLTYPE_FORMULA:
             return rCell.getFormula()->GetFormula();
@@ -1667,7 +1667,7 @@ void ScChangeActionContent::SetValue(
         rCell.clear();
 }
 
-void ScChangeActionContent::SetCell( OUString& rStr, const ScCellValue& rCell, 
sal_uLong nFormat, const ScDocument* pDoc )
+void ScChangeActionContent::SetCell( OUString& rStr, const ScCellValue& rCell, 
sal_uLong nFormat, const ScDocument& rDoc )
 {
     rStr.clear();
     if (rCell.isEmpty())
@@ -1677,7 +1677,7 @@ void ScChangeActionContent::SetCell( OUString& rStr, 
const ScCellValue& rCell, s
     {
         case CELLTYPE_VALUE :
             // e.g. remember date as date string
-            rStr = 
pDoc->GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat);
+            rStr = 
rDoc.GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat);
         break;
         case CELLTYPE_FORMULA :
             rCell.getFormula()->SetInChangeTrack(true);
@@ -1690,7 +1690,7 @@ void ScChangeActionContent::SetCell( OUString& rStr, 
const ScCellValue& rCell, s
 }
 
 OUString ScChangeActionContent::GetValueString(
-    const OUString& rValue, const ScCellValue& rCell, const ScDocument* pDoc ) 
const
+    const OUString& rValue, const ScCellValue& rCell, const ScDocument& rDoc ) 
const
 {
     if (!rValue.isEmpty())
     {
@@ -1703,7 +1703,7 @@ OUString ScChangeActionContent::GetValueString(
             return rCell.getSharedString()->getString();
         case CELLTYPE_EDIT :
             if (rCell.getEditText())
-                return ScEditUtil::GetString(*rCell.getEditText(), pDoc);
+                return ScEditUtil::GetString(*rCell.getEditText(), rDoc);
             return OUString();
         case CELLTYPE_VALUE : // Is always in rValue
             return rValue;
@@ -2560,11 +2560,11 @@ void ScChangeTrack::AppendContent(
     if ( !pRefDoc )
         pRefDoc = &rDoc;
 
-    OUString aOldValue = ScChangeActionContent::GetStringOfCell(rOldCell, 
pRefDoc, nOldFormat);
+    OUString aOldValue = ScChangeActionContent::GetStringOfCell(rOldCell, 
*pRefDoc, nOldFormat);
 
     ScCellValue aNewCell;
     aNewCell.assign(rDoc, rPos);
-    OUString aNewValue = ScChangeActionContent::GetStringOfCell(aNewCell, 
&rDoc, rPos);
+    OUString aNewValue = ScChangeActionContent::GetStringOfCell(aNewCell, 
rDoc, rPos);
 
     if (aOldValue != aNewValue || IsMatrixFormulaRangeDifferent(rOldCell, 
aNewCell))
     {   // Only track real changes
@@ -2577,21 +2577,21 @@ void ScChangeTrack::AppendContent(
 }
 
 void ScChangeTrack::AppendContent( const ScAddress& rPos,
-        const ScDocument* pRefDoc )
+        const ScDocument& rRefDoc )
 {
     ScCellValue aOldCell;
-    aOldCell.assign(*pRefDoc, rPos);
-    OUString aOldValue = ScChangeActionContent::GetStringOfCell(aOldCell, 
pRefDoc, rPos);
+    aOldCell.assign(rRefDoc, rPos);
+    OUString aOldValue = ScChangeActionContent::GetStringOfCell(aOldCell, 
rRefDoc, rPos);
 
     ScCellValue aNewCell;
     aNewCell.assign(rDoc, rPos);
-    OUString aNewValue = ScChangeActionContent::GetStringOfCell(aNewCell, 
&rDoc, rPos);
+    OUString aNewValue = ScChangeActionContent::GetStringOfCell(aNewCell, 
rDoc, rPos);
 
     if (aOldValue != aNewValue || IsMatrixFormulaRangeDifferent(aOldCell, 
aNewCell))
     {   // Only track real changes
         ScRange aRange( rPos );
         ScChangeActionContent* pAct = new ScChangeActionContent( aRange );
-        pAct->SetOldValue(aOldCell, pRefDoc, &rDoc);
+        pAct->SetOldValue(aOldCell, &rRefDoc, &rDoc);
         pAct->SetNewValue(aNewCell, &rDoc);
         Append( pAct );
     }
@@ -2606,7 +2606,7 @@ void ScChangeTrack::AppendContent( const ScAddress& rPos, 
const ScCellValue& rOl
 }
 
 void ScChangeTrack::SetLastCutMoveRange( const ScRange& rRange,
-        ScDocument* pRefDoc )
+        ScDocument& rRefDoc )
 {
     if ( !pLastCutMove )
         return;
@@ -2622,18 +2622,18 @@ void ScChangeTrack::SetLastCutMoveRange( const ScRange& 
rRange,
     r.aStart.SetRow( -1 - (rRange.aEnd.Row() - rRange.aStart.Row()) );
     r.aStart.SetTab( -1 - (rRange.aEnd.Tab() - rRange.aStart.Tab()) );
     // Contents in FromRange we should overwrite
-    LookUpContents( rRange, pRefDoc, 0, 0, 0 );
+    LookUpContents( rRange, &rRefDoc, 0, 0, 0 );
 }
 
 void ScChangeTrack::AppendContentRange( const ScRange& rRange,
-        ScDocument* pRefDoc, sal_uLong& nStartAction, sal_uLong& nEndAction,
+        ScDocument& rRefDoc, sal_uLong& nStartAction, sal_uLong& nEndAction,
         ScChangeActionClipMode eClipMode )
 {
     if ( eClipMode == SC_CACM_CUT )
     {
         ResetLastCut();
         pLastCutMove.reset(new ScChangeActionMove( rRange, rRange, this ));
-        SetLastCutMoveRange( rRange, pRefDoc );
+        SetLastCutMoveRange( rRange, rRefDoc );
     }
     SCCOL nCol1;
     SCROW nRow1;
@@ -2677,7 +2677,7 @@ void ScChangeTrack::AppendContentRange( const ScRange& 
rRange,
         nStartAction = GetActionMax() + 1;
         StartBlockModify( ScChangeTrackMsgType::Append, nStartAction );
         // Contents to overwrite in ToRange
-        LookUpContents( aRange, pRefDoc, 0, 0, 0 );
+        LookUpContents( aRange, &rRefDoc, 0, 0, 0 );
         pLastCutMove->SetStartLastCut( nStartLastCut );
         pLastCutMove->SetEndLastCut( nEndLastCut );
         Append( pLastCutMove.release() );
@@ -2697,17 +2697,17 @@ void ScChangeTrack::AppendContentRange( const ScRange& 
rRange,
         {
             aPos.SetTab( nTab );
             // AppendContent() is a no-op if both cells are empty.
-            SCCOL lastCol = std::max( pRefDoc->ClampToAllocatedColumns( nTab, 
nCol2 ),
-                                      rDoc.ClampToAllocatedColumns( nTab, 
nCol2 ));
+            SCCOL lastCol = std::max( rRefDoc.ClampToAllocatedColumns( nTab, 
nCol2 ),
+                                      rRefDoc.ClampToAllocatedColumns( nTab, 
nCol2 ));
             for ( SCCOL nCol = nCol1; nCol <= lastCol; nCol++ )
             {
                 aPos.SetCol( nCol );
-                SCROW lastRow = std::max( pRefDoc->GetLastDataRow( nTab, nCol, 
nCol, nRow2 ),
-                                          rDoc.GetLastDataRow( nTab, nCol, 
nCol, nRow2 ));
+                SCROW lastRow = std::max( rRefDoc.GetLastDataRow( nTab, nCol, 
nCol, nRow2 ),
+                                          rRefDoc.GetLastDataRow( nTab, nCol, 
nCol, nRow2 ));
                 for ( SCROW nRow = nRow1; nRow <= lastRow; nRow++ )
                 {
                     aPos.SetRow( nRow );
-                    AppendContent( aPos, pRefDoc );
+                    AppendContent( aPos, rRefDoc );
                 }
             }
         }
@@ -2752,7 +2752,7 @@ ScChangeActionContent* 
ScChangeTrack::AppendContentOnTheFly(
 {
     ScRange aRange( rPos );
     ScChangeActionContent* pAct = new ScChangeActionContent( aRange );
-    pAct->SetOldNewCells(rOldCell, nOldFormat, rNewCell, nNewFormat, &rDoc);
+    pAct->SetOldNewCells(rOldCell, nOldFormat, rNewCell, nNewFormat, rDoc);
     Append( pAct );
     return pAct;
 }
@@ -3112,7 +3112,7 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, 
sal_uLong nEndAction, bool bMe
                     nEndLastCut = nEnd;
                     pLastCutMove.reset(pMove);
                     SetLastCutMoveRange(
-                        pMove->GetFromRange().MakeRange( rDoc ), &rDoc );
+                        pMove->GetFromRange().MakeRange( rDoc ), rDoc );
                 }
                 else
                     delete pMove;
@@ -4333,7 +4333,7 @@ bool ScChangeTrack::IsLastAction( sal_uLong nNum ) const
 sal_uLong ScChangeTrack::AddLoadedGenerated(
     const ScCellValue& rNewCell, const ScBigRange& aBigRange, const OUString& 
sNewValue )
 {
-    ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, 
rNewCell, aBigRange, &rDoc, sNewValue );
+    ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, 
rNewCell, aBigRange, rDoc, sNewValue );
     if ( pFirstGeneratedDelContent )
         pFirstGeneratedDelContent->pPrev = pAct;
     pAct->pNext = pFirstGeneratedDelContent;
@@ -4355,14 +4355,9 @@ void ScChangeTrack::AppendCloned( ScChangeAction* 
pAppend )
     }
 }
 
-ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
+ScChangeTrack* ScChangeTrack::Clone( ScDocument& rDocument ) const
 {
-    if ( !pDocument )
-    {
-        return nullptr;
-    }
-
-    std::unique_ptr<ScChangeTrack> pClonedTrack(new ScChangeTrack( *pDocument 
));
+    std::unique_ptr<ScChangeTrack> pClonedTrack(new ScChangeTrack( rDocument 
));
     pClonedTrack->SetTimeNanoSeconds( IsTimeNanoSeconds() );
 
     // clone generated actions
@@ -4382,8 +4377,8 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* 
pDocument ) const
         if (!rNewCell.isEmpty())
         {
             ScCellValue aClonedNewCell;
-            aClonedNewCell.assign(rNewCell, *pDocument);
-            OUString aNewValue = rContent.GetNewString( pDocument );
+            aClonedNewCell.assign(rNewCell, rDocument);
+            OUString aNewValue = rContent.GetNewString( rDocument );
             pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1;
             pClonedTrack->AddLoadedGenerated(aClonedNewCell, 
pGenerated->GetBigRange(), aNewValue);
         }
@@ -4466,8 +4461,8 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* 
pDocument ) const
                     const ScChangeActionContent& rContent = dynamic_cast<const 
ScChangeActionContent&>(*pAction);
                     const ScCellValue& rOldCell = rContent.GetOldCell();
                     ScCellValue aClonedOldCell;
-                    aClonedOldCell.assign(rOldCell, *pDocument);
-                    OUString aOldValue = rContent.GetOldString( pDocument );
+                    aClonedOldCell.assign(rOldCell, rDocument);
+                    OUString aOldValue = rContent.GetOldString( rDocument );
 
                     ScChangeActionContent* pClonedContent = new 
ScChangeActionContent(
                         pAction->GetActionNumber(),
@@ -4478,15 +4473,15 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* 
pDocument ) const
                         pAction->GetDateTimeUTC(),
                         pAction->GetComment(),
                         std::move(aClonedOldCell),
-                        pDocument,
+                        rDocument,
                         aOldValue );
 
                     const ScCellValue& rNewCell = rContent.GetNewCell();
                     if (!rNewCell.isEmpty())
                     {
                         ScCellValue aClonedNewCell;
-                        aClonedNewCell.assign(rNewCell, *pDocument);
-                        pClonedContent->SetNewValue(aClonedNewCell, pDocument);
+                        aClonedNewCell.assign(rNewCell, rDocument);
+                        pClonedContent->SetNewValue(aClonedNewCell, 
&rDocument);
                     }
 
                     pClonedAction = pClonedContent;
@@ -4611,7 +4606,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* 
pDocument ) const
     }
 
     auto tmp = pClonedTrack.get();
-    pDocument->SetChangeTrack( std::move(pClonedTrack) );
+    rDocument.SetChangeTrack( std::move(pClonedTrack) );
 
     return tmp;
 }
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index a52b4523be5d..333a4a12ddb0 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -838,7 +838,7 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc )
         {
             if (pCell->hasString())
             {
-                const OUString aStr = pCell->getString( pDoc);
+                const OUString aStr = pCell->getString(*pDoc);
                 if (aStr.isEmpty())
                     bHaveEmpty = true;
                 else
@@ -890,12 +890,12 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc )
     mbTableColumnNamesDirty = false;
 }
 
-void ScDBData::RefreshTableColumnNames( ScDocument* pDoc, const ScRange& 
rRange )
+void ScDBData::RefreshTableColumnNames( ScDocument& rDoc, const ScRange& 
rRange )
 {
     // Header-less tables get names generated, completely empty a full refresh.
     if (mbTableColumnNamesDirty && (!HasHeader() || 
maTableColumnNames.empty()))
     {
-        RefreshTableColumnNames( pDoc);
+        RefreshTableColumnNames( &rDoc);
         return;
     }
 
@@ -908,7 +908,7 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc, 
const ScRange& rRange
     // listener if multiple cells were affected. We don't know if there were
     // more. Also, we need the full check anyway in case a duplicated name was
     // entered.
-    RefreshTableColumnNames( pDoc);
+    RefreshTableColumnNames( &rDoc);
 }
 
 sal_Int32 ScDBData::GetColumnNameOffset( const OUString& rName ) const
@@ -1505,7 +1505,7 @@ void ScDBCollection::RefreshDirtyTableColumnNames()
         for (auto const& it : maNamedDBs)
         {
             if (it->AreTableColumnNamesDirty())
-                it->RefreshTableColumnNames( &maNamedDBs.mrDoc, rRange);
+                it->RefreshTableColumnNames( maNamedDBs.mrDoc, rRange);
         }
     }
     maNamedDBs.maDirtyTableColumnNames.RemoveAll();
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 45972774b836..97b9048413cd 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -54,11 +54,11 @@ using namespace com::sun::star;
 
 //  delimiters additionally to EditEngine default:
 
-ScEditUtil::ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
+ScEditUtil::ScEditUtil( ScDocument& rDocument, SCCOL nX, SCROW nY, SCTAB nZ,
                             const Point& rCellPos,
                             OutputDevice* pDevice, double nScaleX, double 
nScaleY,
                             const Fraction& rX, const Fraction& rY, bool 
bPrintTwips ) :
-                    pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ),
+                    rDoc(rDocument),nCol(nX),nRow(nY),nTab(nZ),
                     aCellPos(rCellPos),pDev(pDevice),
                     nPPTX(nScaleX),nPPTY(nScaleY),aZoomX(rX),aZoomY(rY),
                     bInPrintTwips(bPrintTwips) {}
@@ -119,7 +119,7 @@ OUString ScEditUtil::GetMultilineString( const 
EditTextObject& rEdit )
     return lcl_GetDelimitedString(rEdit, '
');
 }
 
-OUString ScEditUtil::GetString( const EditTextObject& rEditText, const 
ScDocument* pDoc )
+OUString ScEditUtil::GetString( const EditTextObject& rEditText, const 
ScDocument& rDoc )
 {
     if( !rEditText.HasField())
         return GetMultilineString( rEditText );
@@ -127,21 +127,12 @@ OUString ScEditUtil::GetString( const EditTextObject& 
rEditText, const ScDocumen
     static std::mutex aMutex;
     std::scoped_lock aGuard( aMutex);
     // ScFieldEditEngine is needed to resolve field contents.
-    if (pDoc)
-    {
-        /* TODO: make ScDocument::GetEditEngine() const? Most likely it's only
-         * not const because of the pointer assignment, make that mutable, and
-         * then remove the ugly const_cast here. */
-        EditEngine& rEE = const_cast<ScDocument*>(pDoc)->GetEditEngine();
-        rEE.SetText( rEditText);
-        return GetMultilineString( rEE);
-    }
-    else
-    {
-        EditEngine& rEE = ScGlobal::GetStaticFieldEditEngine();
-        rEE.SetText( rEditText);
-        return GetMultilineString( rEE);
-    }
+    /* TODO: make ScDocument::GetEditEngine() const? Most likely it's only
+     * not const because of the pointer assignment, make that mutable, and
+     * then remove the ugly const_cast here. */
+    EditEngine& rEE = const_cast<ScDocument&>(rDoc).GetEditEngine();
+    rEE.SetText( rEditText);
+    return GetMultilineString( rEE);
 }
 
 std::unique_ptr<EditTextObject> ScEditUtil::CreateURLObjectFromURL( 
ScDocument& rDoc, const OUString& rURL, const OUString& rText )
@@ -311,7 +302,7 @@ OUString ScEditUtil::GetCellFieldValue(
 tools::Long ScEditUtil::GetIndent(const ScPatternAttr* pPattern) const
 {
     if (!pPattern)
-        pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+        pPattern = rDoc.GetPattern( nCol, nRow, nTab );
 
     if ( pPattern->GetItem(ATTR_HOR_JUSTIFY).GetValue() ==
                 SvxCellHorJustify::Left )
@@ -329,7 +320,7 @@ void ScEditUtil::GetMargins(const ScPatternAttr* pPattern, 
tools::Long& nLeftMar
                             tools::Long& nRightMargin, tools::Long& 
nBottomMargin) const
 {
     if (!pPattern)
-        pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+        pPattern = rDoc.GetPattern( nCol, nRow, nTab );
 
     const SvxMarginItem* pMargin = &pPattern->GetItem(ATTR_MARGIN);
     if (!pMargin)
@@ -347,16 +338,16 @@ tools::Rectangle ScEditUtil::GetEditArea( const 
ScPatternAttr* pPattern, bool bF
     // (sal_False for querying URLs etc.)
 
     if (!pPattern)
-        pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+        pPattern = rDoc.GetPattern( nCol, nRow, nTab );
 
     Point aStartPos = aCellPos;
     bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
 
-    bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+    bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
     tools::Long nLayoutSign = (bLayoutRTL && !bIsTiledRendering) ? -1 : 1;
 
     const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE);
-    tools::Long nCellX = pDoc->GetColWidth(nCol,nTab);
+    tools::Long nCellX = rDoc.GetColWidth(nCol,nTab);
     if (!bInPrintTwips)
         nCellX = static_cast<tools::Long>( nCellX * nPPTX );
     if ( pMerge->GetColMerge() > 1 )
@@ -364,20 +355,20 @@ tools::Rectangle ScEditUtil::GetEditArea( const 
ScPatternAttr* pPattern, bool bF
         SCCOL nCountX = pMerge->GetColMerge();
         for (SCCOL i=1; i<nCountX; i++)
         {
-            tools::Long nColWidth = pDoc->GetColWidth(nCol+i,nTab);
+            tools::Long nColWidth = rDoc.GetColWidth(nCol+i,nTab);
             nCellX += (bInPrintTwips ? nColWidth : static_cast<tools::Long>( 
nColWidth * nPPTX ));
         }
     }
-    tools::Long nCellY = pDoc->GetRowHeight(nRow,nTab);
+    tools::Long nCellY = rDoc.GetRowHeight(nRow,nTab);
     if (!bInPrintTwips)
         nCellY = static_cast<tools::Long>( nCellY * nPPTY );
     if ( pMerge->GetRowMerge() > 1 )
     {
         SCROW nCountY = pMerge->GetRowMerge();
         if (bInPrintTwips)
-            nCellY += pDoc->GetRowHeight(nRow + 1, nRow + nCountY - 1, nTab);
+            nCellY += rDoc.GetRowHeight(nRow + 1, nRow + nCountY - 1, nTab);
         else
-            nCellY += pDoc->GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, 
nPPTY);
+            nCellY += rDoc.GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, 
nPPTY);
     }
 
     tools::Long nRightMargin = 0;
@@ -424,7 +415,7 @@ tools::Rectangle ScEditUtil::GetEditArea( const 
ScPatternAttr* pPattern, bool bF
         MapMode aMode = pDev->GetMapMode();
         pDev->SetMapMode(MapMode(bInPrintTwips ? MapUnit::MapTwip : 
MapUnit::MapPixel));
 
-        tools::Long nTextHeight = pDoc->GetNeededSize( nCol, nRow, nTab,
+        tools::Long nTextHeight = rDoc.GetNeededSize( nCol, nRow, nTab,
                                                 pDev, nPPTX, nPPTY, aZoomX, 
aZoomY, false /* bWidth */,
                                                 false /* bTotalSize */, 
bInPrintTwips );
         if (!nTextHeight)
@@ -738,17 +729,17 @@ void ScEditEngineDefaulter::RemoveParaAttribs()
         SetUpdateLayout( true );
 }
 
-ScTabEditEngine::ScTabEditEngine( ScDocument* pDoc )
-        : ScFieldEditEngine( pDoc, pDoc->GetEnginePool() )
+ScTabEditEngine::ScTabEditEngine( ScDocument& rDoc )
+        : ScFieldEditEngine( &rDoc, rDoc.GetEnginePool() )
 {
-    SetEditTextObjectPool( pDoc->GetEditPool() );
-    const ScPatternAttr& 
rScPatternAttr(pDoc->getCellAttributeHelper().getDefaultCellAttribute());
+    SetEditTextObjectPool( rDoc.GetEditPool() );
+    const ScPatternAttr& 
rScPatternAttr(rDoc.getCellAttributeHelper().getDefaultCellAttribute());
     Init(rScPatternAttr);
 }
 
 ScTabEditEngine::ScTabEditEngine( const ScPatternAttr& rPattern,
-            SfxItemPool* pEngineItemPool, ScDocument* pDoc, SfxItemPool* 
pTextObjectPool )
-        : ScFieldEditEngine( pDoc, pEngineItemPool, pTextObjectPool )
+            SfxItemPool* pEngineItemPool, ScDocument& rDoc, SfxItemPool* 
pTextObjectPool )
+        : ScFieldEditEngine( &rDoc, pEngineItemPool, pTextObjectPool )
 {
     if ( pTextObjectPool )
         SetEditTextObjectPool( pTextObjectPool );
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 2b10e0f1a9e4..505f551d73db 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -4457,12 +4457,12 @@ short ScInterpreter::CompareCell( sal_uInt16 nSort,
                 if (eType1 == CELLTYPE_STRING)
                     aStr1 = rCell1.getSharedString()->getString();
                 else
-                    aStr1 = rCell1.getString(&mrDoc);
+                    aStr1 = rCell1.getString(mrDoc);
 
                 if (eType2 == CELLTYPE_STRING)
                     aStr2 = rCell2.getSharedString()->getString();
                 else
-                    aStr2 = rCell2.getString(&mrDoc);
+                    aStr2 = rCell2.getString(mrDoc);
 
                 CollatorWrapper& rSortCollator = 
ScGlobal::GetCollator(aSortParam.bCaseSens);
                 nRes = static_cast<short>( rSortCollator.compareString( aStr1, 
aStr2 ) );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index fd48ba4aebe0..d72f645afba1 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -233,7 +233,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& 
rPos, const ScRefCell
         {
             // SUM(A1:A2) differs from A1+A2. No good. But people insist on
             // it ... #i5658#
-            OUString aStr = rCell.getString(&mrDoc);
+            OUString aStr = rCell.getString(mrDoc);
             fValue = ConvertStringToValue( aStr );
         }
         break;
@@ -253,7 +253,7 @@ void ScInterpreter::GetCellString( svl::SharedString& rStr, 
const ScRefCellValue
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            rStr = rCell.getSharedString(&mrDoc, mrStrPool);
+            rStr = rCell.getSharedString(mrDoc, mrStrPool);
         break;
         case CELLTYPE_FORMULA:
         {
@@ -404,7 +404,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW 
nRow1, SCTAB nTab1,
                     {
                         case CELLTYPE_STRING:
                         case CELLTYPE_EDIT:
-                            aStr = aCell.getString(&mrDoc);
+                            aStr = aCell.getString(mrDoc);
                             break;
                         case CELLTYPE_FORMULA:
                             if (!aCell.getFormula()->IsValue())
@@ -508,7 +508,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, 
SCTAB nTab1,
                     {
                         case CELLTYPE_STRING :
                         case CELLTYPE_EDIT :
-                            aStr = aCell.getString(&mrDoc);
+                            aStr = aCell.getString(mrDoc);
                             nType = 1;
                             break;
                         case CELLTYPE_VALUE :
@@ -1419,7 +1419,7 @@ void ScInterpreter::PopRefListPushMatrixOrRef()
                         else if (aCell.hasEmptyValue())
                             xMat->PutEmpty( 0, i);
                         else if (aCell.hasString())
-                            xMat->PutString( mrStrPool.intern( 
aCell.getString(&mrDoc)), 0, i);
+                            xMat->PutString( mrStrPool.intern( 
aCell.getString(mrDoc)), 0, i);
                         else
                             xMat->PutDouble( aCell.getValue(), 0, i);
                     }
@@ -3562,7 +3562,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, 
const ScAddress& rPos )
             break;
             case CELLTYPE_STRING :
             case CELLTYPE_EDIT :
-                pVar->PutString(aCell.getString(&mrDoc));
+                pVar->PutString(aCell.getString(mrDoc));
             break;
             case CELLTYPE_FORMULA :
                 nErr = aCell.getFormula()->GetErrCode();
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index ba5592a935a0..6443737d2dcf 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -431,7 +431,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
             }
             else if (aCell.hasString())
             {
-                pMat->PutString( mrStrPool.intern( aCell.getString(&mrDoc)), 
nMatCol, nMatRow);
+                pMat->PutString( mrStrPool.intern( aCell.getString(mrDoc)), 
nMatCol, nMatRow);
             }
             else
             {
diff --git a/sc/source/core/tool/rangecache.cxx 
b/sc/source/core/tool/rangecache.cxx
index f5e98343455b..a6437fb819de 100644
--- a/sc/source/core/tool/rangecache.cxx
+++ b/sc/source/core/tool/rangecache.cxx
@@ -49,12 +49,12 @@ static ScSortedRangeCache::ValueType toValueType(const 
ScQueryParam& param)
                            : 
ScSortedRangeCache::ValueType::StringsCaseInsensitive;
 }
 
-ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange,
+ScSortedRangeCache::ScSortedRangeCache(ScDocument& rDoc, const ScRange& rRange,
                                        const ScQueryParam& param, 
ScInterpreterContext* context,
                                        bool invalid, bool bNewSearchFunction,
                                        sal_uInt8 nSortedBinarySearch)
     : maRange(rRange)
-    , mpDoc(pDoc)
+    , mrDoc(rDoc)
     , mValid(false)
     , mRowSearch(param.bByRow)
     , mValueType(toValueType(param))
@@ -80,7 +80,7 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, 
const ScRange& rRange,
     SCCOL startCol = maRange.aStart.Col();
     SCCOL endCol = maRange.aEnd.Col();
     if (!item.mbMatchEmpty)
-        if (!pDoc->ShrinkToDataArea(nTab, startCol, startRow, endCol, endRow))
+        if (!rDoc.ShrinkToDataArea(nTab, startCol, startRow, endCol, endRow))
             return; // no data cells, no need for a cache
 
     if (mValueType == ValueType::Values)
@@ -96,7 +96,7 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, 
const ScRange& rRange,
         {
             for (SCROW nRow = startRow; nRow <= endRow; ++nRow)
             {
-                ScRefCellValue cell(pDoc->GetRefCellValue(ScAddress(nCol, 
nRow, nTab)));
+                ScRefCellValue cell(rDoc.GetRefCellValue(ScAddress(nCol, nRow, 
nTab)));
                 if (ScQueryEvaluator::isQueryByValue(mQueryOp, mQueryType, 
cell))
                     colrowData.push_back(ColRowData{ mRowSearch ? nRow : nCol, 
cell.getValue() });
                 else if (ScQueryEvaluator::isQueryByString(mQueryOp, 
mQueryType, cell))
@@ -112,11 +112,11 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, 
const ScRange& rRange,
                     // the whole column which includes a textual header). But 
if it can possibly
                     // match, then bail out and leave it to the unoptimized 
case.
                     // TODO Maybe it would actually work to use the numeric 
value obtained here?
-                    if (!bNewSearchFunction && 
!ScQueryEvaluator::isMatchWholeCell(*pDoc, mQueryOp))
+                    if (!bNewSearchFunction && 
!ScQueryEvaluator::isMatchWholeCell(rDoc, mQueryOp))
                         return; // substring matching cannot be sorted, but 
new search functions are sorted
                     sal_uInt32 format = 0;
                     double value;
-                    if (context->NFIsNumberFormat(cell.getString(pDoc), 
format, value))
+                    if (context->NFIsNumberFormat(cell.getString(rDoc), 
format, value))
                         return;
                 }
             }
@@ -169,14 +169,14 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, 
const ScRange& rRange,
         std::vector<ColRowData> colrowData;
         // Try to reuse as much ScQueryEvaluator code as possible, this should
         // basically do the same comparisons.
-        assert(pDoc->FetchTable(nTab) != nullptr);
-        ScQueryEvaluator evaluator(*pDoc, *pDoc->FetchTable(nTab), param, 
context, nullptr,
+        assert(rDoc.FetchTable(nTab) != nullptr);
+        ScQueryEvaluator evaluator(rDoc, *rDoc.FetchTable(nTab), param, 
context, nullptr,
                                    bNewSearchFunction);
         for (SCCOL nCol = startCol; nCol <= endCol; ++nCol)
         {
             for (SCROW nRow = startRow; nRow <= endRow; ++nRow)
             {
-                ScRefCellValue cell(pDoc->GetRefCellValue(ScAddress(nCol, 
nRow, nTab)));
+                ScRefCellValue cell(rDoc.GetRefCellValue(ScAddress(nCol, nRow, 
nTab)));
                 // This should be used only with ScQueryEntry::ByString, and 
that
                 // means that ScQueryEvaluator::isQueryByString() should be 
the only
                 // possibility in the generic handling in 
ScQueryEvaluator::processEntry()
@@ -250,11 +250,11 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, 
const ScRange& rRange,
 
 void ScSortedRangeCache::Notify(const SfxHint& rHint)
 {
-    if (!mpDoc->IsInDtorClear())
+    if (!mrDoc.IsInDtorClear())
     {
         if (rHint.GetId() == SfxHintId::ScDataChanged || rHint.GetId() == 
SfxHintId::ScAreaChanged)
         {
-            mpDoc->RemoveSortedRangeCache(*this);
+            mrDoc.RemoveSortedRangeCache(*this);
             // this ScSortedRangeCache is deleted by RemoveSortedRangeCache
         }
     }
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 9549a78c1952..47f81e7bfe46 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -274,7 +274,7 @@ bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, 
ScDocument& rDoc, const
             else if (aCell.hasNumeric())
                 rElement <<= aCell.getValue();
             else
-                rElement <<= aCell.getString(&rDoc);
+                rElement <<= aCell.getString(rDoc);
         }
         pRowAry[nRow] = std::move(aColSeq);
     }
diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx
index 3d769e5138f7..94f77aef829d 100644
--- a/sc/source/filter/dif/difexp.cxx
+++ b/sc/source/filter/dif/difexp.cxx
@@ -33,21 +33,21 @@
 #include <formula/errorcodes.hxx>
 #include <tools/stream.hxx>
 
-void ScFormatFilterPluginImpl::ScExportDif( SvStream& rStream, ScDocument* 
pDoc,
+void ScFormatFilterPluginImpl::ScExportDif( SvStream& rStream, ScDocument& 
rDoc,
     const ScAddress& rOutPos, const rtl_TextEncoding eNach )
 {
     SCCOL       nEndCol;
     SCROW       nEndRow;
-    pDoc->GetTableArea( rOutPos.Tab(), nEndCol, nEndRow );
+    rDoc.GetTableArea( rOutPos.Tab(), nEndCol, nEndRow );
     ScAddress   aEnd( nEndCol, nEndRow, rOutPos.Tab() );
     ScAddress   aStart( rOutPos );
 
     aStart.PutInOrder( aEnd );
 
-    ScExportDif( rStream, pDoc, ScRange( aStart, aEnd ), eNach );
+    ScExportDif( rStream, rDoc, ScRange( aStart, aEnd ), eNach );
 }
 
-void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc,
+void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument& rDoc,
     const ScRange&rRange, const rtl_TextEncoding eCharSet )
 {
     OSL_ENSURE( rRange.aStart <= rRange.aEnd, "*ScExportDif(): Range not 
sorted!" );
@@ -99,14 +99,14 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, 
ScDocument* pDoc,
     SCROW               nNumRows = nEndRow - rRange.aStart.Row() + 1;
     SCTAB               nTab = rRange.aStart.Tab();
 
-    ScProgress          aPrgrsBar( pDoc->GetDocumentShell(), ScResId( 
STR_LOAD_DOC ), nNumRows, true );
+    ScProgress          aPrgrsBar( rDoc.GetDocumentShell(), ScResId( 
STR_LOAD_DOC ), nNumRows, true );
 
     aPrgrsBar.SetState( 0 );
 
     // TABLE
-    OSL_ENSURE( pDoc->HasTable( nTab ), "*ScExportDif(): Table not existent!" 
);
+    OSL_ENSURE( rDoc.HasTable( nTab ), "*ScExportDif(): Table not existent!" );
 
-    pDoc->GetName( nTab, aString );
+    rDoc.GetName( nTab, aString );
     aOS.append(OUString::Concat(pKeyTABLE)
         + "
0,1
\""
         + aString
@@ -154,7 +154,7 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, 
ScDocument* pDoc,
         {
             assert( aOS.isEmpty() && "aOS should be empty");
             bool bWriteStringData = false;
-            ScRefCellValue aCell(*pDoc, ScAddress(nColCnt, nRowCnt, nTab));
+            ScRefCellValue aCell(rDoc, ScAddress(nColCnt, nRowCnt, nTab));
 
             switch (aCell.getType())
             {
@@ -162,12 +162,12 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& 
rOut, ScDocument* pDoc,
                     aOS.append(pEmptyData);
                 break;
                 case CELLTYPE_VALUE:
-                    aString = pDoc->GetInputString( nColCnt, nRowCnt, nTab );
+                    aString = rDoc.GetInputString( nColCnt, nRowCnt, nTab );
                     aOS.append(pNumData + aString + "
V
");
                 break;
                 case CELLTYPE_EDIT:
                 case CELLTYPE_STRING:
-                    aString = aCell.getString(pDoc);
+                    aString = aCell.getString(rDoc);
                     bWriteStringData = true;
                 break;
                 case CELLTYPE_FORMULA:
@@ -175,7 +175,7 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, 
ScDocument* pDoc,
                         aOS.append(pNumDataERROR);
                     else if (aCell.getFormula()->IsValue())
                     {
-                        aString = pDoc->GetInputString( nColCnt, nRowCnt, nTab 
);
+                        aString = rDoc.GetInputString( nColCnt, nRowCnt, nTab 
);
                         aOS.append(pNumData + aString + "
V
");
                     }
                     else
diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index aae72134bf0d..a5db5b37f887 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -442,7 +442,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool 
TestImportCalcRTF(SvStream &rStream)
 
     try
     {
-        bRet = ScFormatFilter::Get().ScImportRTF(rStream, OUString(), 
&aDocument, aRange) == ERRCODE_NONE;
+        bRet = ScFormatFilter::Get().ScImportRTF(rStream, OUString(), 
aDocument, aRange) == ERRCODE_NONE;
     }
     catch (const std::range_error&)
     {
diff --git a/sc/source/filter/html/htmlimp.cxx 
b/sc/source/filter/html/htmlimp.cxx
index d0dbefc3f2f3..1b8845cebd5c 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -43,11 +43,11 @@
 #include <ftools.hxx>
 #include <tokenarray.hxx>
 
-ErrCode ScFormatFilterPluginImpl::ScImportHTML( SvStream &rStream, const 
OUString& rBaseURL, ScDocument *pDoc,
+ErrCode ScFormatFilterPluginImpl::ScImportHTML( SvStream &rStream, const 
OUString& rBaseURL, ScDocument& rDoc,
         ScRange& rRange, double nOutputFactor, bool bCalcWidthHeight, 
SvNumberFormatter* pFormatter,
         bool bConvertDate, bool bConvertScientific )
 {
-    ScHTMLImport aImp( pDoc, rBaseURL, rRange, bCalcWidthHeight );
+    ScHTMLImport aImp( rDoc, rBaseURL, rRange, bCalcWidthHeight );
     ErrCode nErr = aImp.Read( rStream, rBaseURL );
     ScRange aR = aImp.GetRange();
     rRange.aEnd = aR.aEnd;
@@ -55,18 +55,18 @@ ErrCode ScFormatFilterPluginImpl::ScImportHTML( SvStream 
&rStream, const OUStrin
     return nErr;
 }
 
-std::unique_ptr<ScEEAbsImport> ScFormatFilterPluginImpl::CreateHTMLImport( 
ScDocument* pDocP, const OUString& rBaseURL, const ScRange& rRange )
+std::unique_ptr<ScEEAbsImport> ScFormatFilterPluginImpl::CreateHTMLImport( 
ScDocument& rDoc, const OUString& rBaseURL, const ScRange& rRange )
 {
-    return std::make_unique<ScHTMLImport>( pDocP, rBaseURL, rRange, 
true/*bCalcWidthHeight*/ );
+    return std::make_unique<ScHTMLImport>( rDoc, rBaseURL, rRange, 
true/*bCalcWidthHeight*/ );
 }
 
-ScHTMLImport::ScHTMLImport( ScDocument* pDocP, const OUString& rBaseURL, const 
ScRange& rRange, bool bCalcWidthHeight ) :
-    ScEEImport( pDocP, rRange )
+ScHTMLImport::ScHTMLImport( ScDocument& rDoc, const OUString& rBaseURL, const 
ScRange& rRange, bool bCalcWidthHeight ) :
+    ScEEImport( rDoc, rRange )
 {
     Size aPageSize;
     OutputDevice* pDefaultDev = Application::GetDefaultDevice();
-    const OUString aPageStyle = mpDoc->GetPageStyle( rRange.aStart.Tab() );
-    ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(mpDoc->
+    const OUString aPageStyle = mrDoc.GetPageStyle( rRange.aStart.Tab() );
+    ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(mrDoc.
         GetStyleSheetPool()->Find( aPageStyle, SfxStyleFamily::Page ));
     if ( pStyleSheet )
     {
@@ -94,9 +94,9 @@ ScHTMLImport::ScHTMLImport( ScDocument* pDocP, const 
OUString& rBaseURL, const S
             SvxPaperInfo::GetPaperSize( PAPER_A4 ), MapMode( MapUnit::MapTwip 
) );
     }
     if( bCalcWidthHeight )
-        mpParser.reset( new ScHTMLLayoutParser( mpEngine.get(), rBaseURL, 
aPageSize, pDocP ));
+        mpParser.reset( new ScHTMLLayoutParser( mpEngine.get(), rBaseURL, 
aPageSize, rDoc ));
     else
-        mpParser.reset( new ScHTMLQueryParser( mpEngine.get(), pDocP ));
+        mpParser.reset( new ScHTMLQueryParser( mpEngine.get(), rDoc ));
 }
 
 void ScHTMLImport::InsertRangeName( ScDocument& rDoc, const OUString& rName, 
const ScRange& rRange )
@@ -123,7 +123,7 @@ void ScHTMLImport::WriteToDocument(
         return;
 
     // set cell borders for HTML table cells
-    pGlobTable->ApplyCellBorders( mpDoc, maRange.aStart );
+    pGlobTable->ApplyCellBorders( mrDoc, maRange.aStart );
 
     // correct cell borders for merged cells
     for ( size_t i = 0, n = pParser->ListSize(); i < n; ++i )
@@ -132,27 +132,27 @@ void ScHTMLImport::WriteToDocument(
         if( (pEntry->nColOverlap > 1) || (pEntry->nRowOverlap > 1) )
         {
             SCTAB nTab = maRange.aStart.Tab();
-            const ScMergeAttr* pItem = mpDoc->GetAttr( pEntry->nCol, 
pEntry->nRow, nTab, ATTR_MERGE );
+            const ScMergeAttr* pItem = mrDoc.GetAttr( pEntry->nCol, 
pEntry->nRow, nTab, ATTR_MERGE );
             if( pItem->IsMerged() )
             {
                 SCCOL nColMerge = pItem->GetColMerge();
                 SCROW nRowMerge = pItem->GetRowMerge();
 
-                const SvxBoxItem* pToItem = mpDoc->GetAttr( pEntry->nCol, 
pEntry->nRow, nTab, ATTR_BORDER );
+                const SvxBoxItem* pToItem = mrDoc.GetAttr( pEntry->nCol, 
pEntry->nRow, nTab, ATTR_BORDER );
                 SvxBoxItem aNewItem( *pToItem );
                 if( nColMerge > 1 )
                 {
                     const SvxBoxItem* pFromItem =
-                        mpDoc->GetAttr( pEntry->nCol + nColMerge - 1, 
pEntry->nRow, nTab, ATTR_BORDER );
+                        mrDoc.GetAttr( pEntry->nCol + nColMerge - 1, 
pEntry->nRow, nTab, ATTR_BORDER );
                     aNewItem.SetLine( pFromItem->GetLine( 
SvxBoxItemLine::RIGHT ), SvxBoxItemLine::RIGHT );
                 }
                 if( nRowMerge > 1 )
                 {
                     const SvxBoxItem* pFromItem =
-                        mpDoc->GetAttr( pEntry->nCol, pEntry->nRow + nRowMerge 
- 1, nTab, ATTR_BORDER );
+                        mrDoc.GetAttr( pEntry->nCol, pEntry->nRow + nRowMerge 
- 1, nTab, ATTR_BORDER );
                     aNewItem.SetLine( pFromItem->GetLine( 
SvxBoxItemLine::BOTTOM ), SvxBoxItemLine::BOTTOM );
                 }
-                mpDoc->ApplyAttr( pEntry->nCol, pEntry->nRow, nTab, aNewItem );
+                mrDoc.ApplyAttr( pEntry->nCol, pEntry->nRow, nTab, aNewItem );
             }
         }
     }
@@ -162,10 +162,10 @@ void ScHTMLImport::WriteToDocument(
     ScRange aNewRange( maRange.aStart );
     aNewRange.aEnd.IncCol( static_cast<SCCOL>(pGlobTable->GetDocSize( tdCol )) 
- 1 );
     aNewRange.aEnd.IncRow( pGlobTable->GetDocSize( tdRow ) - 1 );
-    InsertRangeName( *mpDoc, ScfTools::GetHTMLDocName(), aNewRange );
+    InsertRangeName( mrDoc, ScfTools::GetHTMLDocName(), aNewRange );
 
     // 2 - all tables
-    InsertRangeName( *mpDoc, ScfTools::GetHTMLTablesName(), ScRange( 
maRange.aStart ) );
+    InsertRangeName( mrDoc, ScfTools::GetHTMLTablesName(), ScRange( 
maRange.aStart ) );
 
     // 3 - single tables
     SCCOL nColDiff = maRange.aStart.Col();
@@ -178,7 +178,7 @@ void ScHTMLImport::WriteToDocument(
     while( (pTable = pGlobTable->FindNestedTable( ++nTableId )) != nullptr )
     {
         pTable->GetDocRange( aNewRange );
-        if (!aNewRange.Move( nColDiff, nRowDiff, nTabDiff, aErrorRange, *mpDoc 
))
+        if (!aNewRange.Move( nColDiff, nRowDiff, nTabDiff, aErrorRange, mrDoc 
))
         {
             assert(!"can't move");
         }
@@ -191,8 +191,8 @@ void ScHTMLImport::WriteToDocument(
         if (!pTable->GetTableCaption().isEmpty())
             aName.append(" - " + pTable->GetTableCaption());
         const OUString sName(aName.makeStringAndClear());
-        if 
(!mpDoc->GetRangeName()->findByUpperName(ScGlobal::getCharClass().uppercase(sName)))
-            InsertRangeName(*mpDoc, sName, aNewRange);
+        if 
(!mrDoc.GetRangeName()->findByUpperName(ScGlobal::getCharClass().uppercase(sName)))
+            InsertRangeName(mrDoc, sName, aNewRange);
     }
 }
 
diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index a4e0f7069a1f..bc4f128d8277 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -289,9 +289,9 @@ void ScHTMLStyles::insertProp(
 
 // BASE class for HTML parser classes
 
-ScHTMLParser::ScHTMLParser( EditEngine* pEditEngine, ScDocument* pDoc ) :
+ScHTMLParser::ScHTMLParser( EditEngine* pEditEngine, ScDocument& rDoc ) :
     ScEEParser( pEditEngine ),
-    mpDoc( pDoc )
+    mrDoc( rDoc )
 {
     maFontHeights[0] = 
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get() * 20;
     maFontHeights[1] = 
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get() * 20;
@@ -308,8 +308,8 @@ ScHTMLParser::~ScHTMLParser()
 
 ScHTMLLayoutParser::ScHTMLLayoutParser(
     EditEngine* pEditP, OUString _aBaseURL, const Size& aPageSizeP,
-    ScDocument* pDocP ) :
-        ScHTMLParser( pEditP, pDocP ),
+    ScDocument& rDoc ) :
+        ScHTMLParser( pEditP, rDoc ),
         aPageSize( aPageSizeP ),
         aBaseURL(std::move( _aBaseURL )),
         xLockedList( new ScRangeList ),
@@ -351,7 +351,7 @@ ErrCode ScHTMLLayoutParser::Read( SvStream& rStream, const 
OUString& rBaseURL )
     Link<HtmlImportInfo&,void> aOldLink = pEdit->GetHtmlImportHdl();
     pEdit->SetHtmlImportHdl( LINK( this, ScHTMLLayoutParser, HTMLImportHdl ) );
 
-    ScDocShell* pObjSh = mpDoc->GetDocumentShell();
+    ScDocShell* pObjSh = mrDoc.GetDocumentShell();
     bool bLoading = pObjSh && pObjSh->IsLoading();
 
     SvKeyValueIteratorRef xValues;
@@ -537,7 +537,7 @@ void ScHTMLLayoutParser::ModifyOffset( ScHTMLColOffset* 
pOffset, sal_uInt16& nOl
 
 void ScHTMLLayoutParser::SkipLocked( ScEEParseEntry* pE, bool bJoin )
 {
-    if ( !mpDoc->ValidCol(pE->nCol) )
+    if ( !mrDoc.ValidCol(pE->nCol) )
         return;
 
 // Or else this would create a wrong value at ScAddress (chance for an 
infinite loop)!
@@ -549,7 +549,7 @@ void ScHTMLLayoutParser::SkipLocked( ScEEParseEntry* pE, 
bool bJoin )
     bool bFail = o3tl::checked_add<SCCOL>(pE->nCol, pE->nColOverlap - 1, 
nEndCol) ||
                  o3tl::checked_add<SCROW>(pE->nRow, pE->nRowOverlap - 1, 
nEndRow);
 
-    if (bFail || nEndRow > mpDoc->MaxRow())
+    if (bFail || nEndRow > mrDoc.MaxRow())
     {
         SAL_WARN("sc", "invalid range: " << pE->nCol << " " << pE->nColOverlap 
<<
                                      " " << pE->nRow << " " << 
pE->nRowOverlap);
@@ -568,7 +568,7 @@ void ScHTMLLayoutParser::SkipLocked( ScEEParseEntry* pE, 
bool bJoin )
                 SCCOL nTmp(0);
                 bFail = o3tl::checked_add<SCCOL>(rR.aEnd.Col(), 1, pE->nCol) ||
                         o3tl::checked_add<SCCOL>(pE->nCol, pE->nRowOverlap - 
1, nTmp);
-                if ( bFail || pE->nCol > mpDoc->MaxCol() || nTmp > 
mpDoc->MaxCol() )
+                if ( bFail || pE->nCol > mrDoc.MaxCol() || nTmp > 
mrDoc.MaxCol() )
                     bBadCol = true;
                 else
                 {
@@ -1069,7 +1069,7 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
             case HtmlOptionId::COLSPAN:
             {
                 sal_Int32 nColOverlap = rOption.GetString().toInt32();
-                if (nColOverlap >= 0 && nColOverlap <= mpDoc->MaxCol())
+                if (nColOverlap >= 0 && nColOverlap <= mrDoc.MaxCol())
                     mxActEntry->nColOverlap = static_cast<SCCOL>(nColOverlap);
                 else
                     SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
colspan: " << nColOverlap);
@@ -1078,7 +1078,7 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
             case HtmlOptionId::ROWSPAN:
             {
                 sal_Int32 nRowOverlap = rOption.GetString().toInt32();
-                if (nRowOverlap >= 0 && nRowOverlap <= mpDoc->MaxRow())
+                if (nRowOverlap >= 0 && nRowOverlap <= mrDoc.MaxRow())
                     mxActEntry->nRowOverlap = static_cast<SCROW>(nRowOverlap);
                 else
                     SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
rowspan: " << nRowOverlap);
@@ -1645,7 +1645,7 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo 
)
     switch ( pInfo->nToken )
     {
         case HtmlTokenId::META:
-        if (ScDocShell* pDocSh = mpDoc->GetDocumentShell())
+        if (ScDocShell* pDocSh = mrDoc.GetDocumentShell())
         {
             HTMLParser* pParser = static_cast<HTMLParser*>(pInfo->pParser);
             uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
@@ -1663,7 +1663,7 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo 
)
         break;
         case HtmlTokenId::TITLE_OFF:
         {
-            ScDocShell* pDocSh = mpDoc->GetDocumentShell();
+            ScDocShell* pDocSh = mrDoc.GetDocumentShell();
             if ( bInTitle && !aString.isEmpty() && pDocSh )
             {
                 // Remove blanks from line breaks
@@ -2432,10 +2432,9 @@ void ScHTMLTable::GetDocRange( ScRange& rRange ) const
     }
 }
 
-void ScHTMLTable::ApplyCellBorders( ScDocument* pDoc, const ScAddress& 
rFirstPos ) const
+void ScHTMLTable::ApplyCellBorders( ScDocument& rDoc, const ScAddress& 
rFirstPos ) const
 {
-    OSL_ENSURE( pDoc, "ScHTMLTable::ApplyCellBorders - no document" );
-    if( pDoc && mbBorderOn )
+    if( mbBorderOn )
     {
         const SCCOL nLastCol = maSize.mnCols - 1;
         const SCROW nLastRow = maSize.mnRows - 1;
@@ -2465,7 +2464,7 @@ void ScHTMLTable::ApplyCellBorders( ScDocument* pDoc, 
const ScAddress& rFirstPos
                     {
                         aBorderItem.SetLine( (nCellRow == nCellRow1) ? 
pTopLine : nullptr, SvxBoxItemLine::TOP );
                         aBorderItem.SetLine( (nCellRow == nCellRow2) ? 
pBottomLine : nullptr, SvxBoxItemLine::BOTTOM );
-                        pDoc->ApplyAttr( nCellCol, nCellRow, rFirstPos.Tab(), 
aBorderItem );
+                        rDoc.ApplyAttr( nCellCol, nCellRow, rFirstPos.Tab(), 
aBorderItem );
                     }
                 }
             }
@@ -2473,7 +2472,7 @@ void ScHTMLTable::ApplyCellBorders( ScDocument* pDoc, 
const ScAddress& rFirstPos
     }
 
     for( ScHTMLTableIterator aIter( mxNestedTables.get() ); aIter.is(); 
++aIter )
-        aIter->ApplyCellBorders( pDoc, rFirstPos );
+        aIter->ApplyCellBorders( rDoc, rFirstPos );
 }
 
 SvNumberFormatter* ScHTMLTable::GetFormatTable()
@@ -2964,13 +2963,13 @@ void ScHTMLGlobalTable::Recalc()
     RecalcDocPos( GetDocPos() );
 }
 
-e 
... etc. - the rest is truncated

Reply via email to