sc/source/ui/formdlg/formdata.cxx |    4 ++--
 sc/source/ui/formdlg/formula.cxx  |    9 ++++-----
 sc/source/ui/inc/formdata.hxx     |    7 +++----
 sc/source/ui/inc/formula.hxx      |    2 +-
 sc/source/ui/inc/tabvwsh.hxx      |    2 +-
 sc/source/ui/view/tabvwshc.cxx    |    4 ++--
 6 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit ed36fc7e3f248a36e2fcce8324e10176a73fdd7f
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue May 27 10:12:56 2025 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue May 27 11:21:37 2025 +0200

    ScFormEditData: pass ScDocShell by ref
    
    Change-Id: I49c116f2aacb34e49b92d53b7e9c43dc3a531581
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185886
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/source/ui/formdlg/formdata.cxx 
b/sc/source/ui/formdlg/formdata.cxx
index aabce7653b6d..d20e342c821d 100644
--- a/sc/source/ui/formdlg/formdata.cxx
+++ b/sc/source/ui/formdlg/formdata.cxx
@@ -19,9 +19,9 @@
 
 #include <formdata.hxx>
 
-ScFormEditData::ScFormEditData()
+ScFormEditData::ScFormEditData(ScDocShell& rShell)
     : pInputHandler(nullptr)
-    , pScDocShell(nullptr)
+    , rDocShell(rShell)
 {
     Reset();
 }
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index f1cf093e36b2..a79d501fa5ea 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -120,10 +120,9 @@ ScFormulaDlg::ScFormulaDlg(SfxBindings* pB, 
SfxChildWindow* pCW,
     SCTAB nTab = rViewData.GetTabNo();
     m_CursorPos = ScAddress( nCol, nRow, nTab );
 
-    m_pViewShell->InitFormEditData();                             // create new
+    m_pViewShell->InitFormEditData(rViewData.GetDocShell()); // create new
     pData = m_pViewShell->GetFormEditData();
     pData->SetInputHandler(pInputHdl);
-    pData->SetDocShell(&rViewData.GetDocShell());
 
     OSL_ENSURE(pData,"FormEditData not available");
 
@@ -264,11 +263,11 @@ bool ScFormulaDlg::IsInputHdl(const ScInputHandler* pHdl)
 
 }
 
-ScInputHandler* ScFormulaDlg::GetNextInputHandler(const ScDocShell* pDocShell, 
ScTabViewShell** ppViewSh)
+ScInputHandler* ScFormulaDlg::GetNextInputHandler(const ScDocShell& rDocShell, 
ScTabViewShell** ppViewSh)
 {
     ScInputHandler* pHdl=nullptr;
 
-    SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+    SfxViewFrame* pFrame = SfxViewFrame::GetFirst( &rDocShell );
     while( pFrame && pHdl==nullptr)
     {
         SfxViewShell* p = pFrame->GetViewShell();
@@ -278,7 +277,7 @@ ScInputHandler* ScFormulaDlg::GetNextInputHandler(const 
ScDocShell* pDocShell, S
             pHdl=pViewSh->GetInputHandler();
             if(ppViewSh!=nullptr) *ppViewSh=pViewSh;
         }
-        pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+        pFrame = SfxViewFrame::GetNext( *pFrame, &rDocShell );
     }
 
     return pHdl;
diff --git a/sc/source/ui/inc/formdata.hxx b/sc/source/ui/inc/formdata.hxx
index a2cecbffafe9..0877e328e542 100644
--- a/sc/source/ui/inc/formdata.hxx
+++ b/sc/source/ui/inc/formdata.hxx
@@ -26,14 +26,13 @@ class ScDocShell;
 class ScFormEditData : public formula::FormEditData
 {
 public:
-                        ScFormEditData();
+                        ScFormEditData(ScDocShell& rShell);
                         virtual ~ScFormEditData() override;
 
     ScInputHandler*     GetInputHandler()   { return pInputHandler;}
-    ScDocShell*         GetDocShell()       { return pScDocShell;}
+    ScDocShell&         GetDocShell()       { return rDocShell;}
 
     void                SetInputHandler(ScInputHandler* pHdl)   { 
pInputHandler=pHdl;}
-    void                SetDocShell(ScDocShell* pSds)           { 
pScDocShell=pSds;}
 
     virtual void            SaveValues() override;
 
@@ -42,7 +41,7 @@ private:
     void operator =(ScFormEditData const &) = delete;
 
     ScInputHandler*     pInputHandler;
-    ScDocShell*         pScDocShell;
+    ScDocShell&         rDocShell;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index db6ef49f6b45..cd94f2a26d56 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -99,7 +99,7 @@ private:
     static void  SaveLRUEntry(const ScFuncDesc* pFuncDesc);
 
     static bool  IsInputHdl(const ScInputHandler* pHdl);
-    static ScInputHandler* GetNextInputHandler(const ScDocShell* pDocShell, 
ScTabViewShell** ppViewSh);
+    static ScInputHandler* GetNextInputHandler(const ScDocShell& rDocShell, 
ScTabViewShell** ppViewSh);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index a1bc6e6b95f7..1da1020a005a 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -452,7 +452,7 @@ public:
     css::uno::Reference<css::drawing::XShapes> getSelectedXShapes();
     SC_DLLPUBLIC static css::uno::Reference<css::datatransfer::XTransferable2> 
GetClipData(vcl::Window* pWin);
 
-    void InitFormEditData();
+    void InitFormEditData(ScDocShell& rShell);
     void ClearFormEditData();
     ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
 
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 2ce3f1826a83..8aceaab2f36b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -766,9 +766,9 @@ OUString ScTabViewShell::DoAutoSum(bool& rRangeFinder, 
bool& rSubTotal, const Op
     return aFormula;
 }
 
-void ScTabViewShell::InitFormEditData()
+void ScTabViewShell::InitFormEditData(ScDocShell& rShell)
 {
-    mpFormEditData.reset(new ScFormEditData);
+    mpFormEditData.reset(new ScFormEditData(rShell));
 }
 
 void ScTabViewShell::ClearFormEditData()

Reply via email to