sc/source/ui/inc/viewfunc.hxx  |    2 ++
 sc/source/ui/view/cellsh3.cxx  |   22 +++++++++-------------
 sc/source/ui/view/viewfunc.cxx |    9 +++++++++
 3 files changed, 20 insertions(+), 13 deletions(-)

New commits:
commit 1df6763795c16d3c3ec45a088431e5b3b4457042
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Jul 22 23:48:45 2025 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Aug 19 08:36:06 2025 +0200

    sc: Add EnterDataToCurrentCell, to use current cell as input
    
    Just makes the code a bit easier to read.
    
    Change-Id: I518c46198a8ade3b34e5186d29dc70dc6286cf3b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188191
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit ad07f4df8cc992df4f523e6b60540688d44431a9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189325
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index fa2d1214f5b9..fbae8071aea8 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -90,6 +90,8 @@ public:
     bool            AutoSum( const ScRange& rRange, bool bSubTotal, bool 
bSetCursor, bool bContinue, const OpCode eCode );
     OUString        GetAutoSumFormula( const ScRangeList& rRangeList, bool 
bSubTotal, const ScAddress& rAddr, const OpCode eCode );
 
+    SC_DLLPUBLIC void EnterDataToCurrentCell(const OUString& rString, const 
EditTextObject* pData = nullptr, bool bMatrixExpand = false);
+
     SC_DLLPUBLIC void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const 
OUString& rString,
                                 const EditTextObject* pData = nullptr, bool 
bMatrixExpand = false);
     void            EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 74e7169e4f98..5e757f0d6f0e 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -278,35 +278,31 @@ void ScCellShell::Execute( SfxRequest& rReq )
                         rBindings.Invalidate(SID_DOC_MODIFIED);
                     }
 
-                    OUString aStr( pReqArgs->Get( SID_ENTER_STRING 
).GetValue() );
+                    OUString aInputString = 
pReqArgs->Get(SID_ENTER_STRING).GetValue();
                     const SfxPoolItem* pDontCommitItem;
                     bool bCommit = true;
                     if (pReqArgs->HasItem(FN_PARAM_1, &pDontCommitItem))
                         bCommit = !(static_cast<const 
SfxBoolItem*>(pDontCommitItem)->GetValue());
 
-                    ScInputHandler* pHdl = pScMod->GetInputHdl(pTabViewShell);
+                    ScInputHandler* pInputHandler = 
pScMod->GetInputHdl(pTabViewShell);
                     if (bCommit)
                     {
-                        pTabViewShell->EnterData( GetViewData().GetCurX(),
-                                                  GetViewData().GetCurY(),
-                                                  GetViewData().GetTabNo(),
-                                                  aStr, nullptr,
-                                                  true /*bMatrixExpand*/);
+                        pTabViewShell->EnterDataToCurrentCell(aInputString, 
nullptr, true /*bMatrixExpand*/);
                     }
-                    else if (pHdl)
+                    else if (pInputHandler)
                     {
                         pScMod->SetInputMode(SC_INPUT_TABLE);
 
-                        EditView* pTableView = pHdl->GetActiveView();
-                        pHdl->DataChanging();
+                        EditView* pTableView = pInputHandler->GetActiveView();
+                        pInputHandler->DataChanging();
                         if (pTableView)
-                            pTableView->getEditEngine().SetText(aStr);
-                        pHdl->DataChanged();
+                            pTableView->getEditEngine().SetText(aInputString);
+                        pInputHandler->DataChanged();
 
                         pScMod->SetInputMode(SC_INPUT_NONE);
                     }
 
-                    if ( !pHdl || !pHdl->IsInEnterHandler() )
+                    if (!pInputHandler || !pInputHandler->IsInEnterHandler())
                     {
                         //  UpdateInputHandler is needed after the cell content
                         //  has changed, but if called from EnterHandler, 
UpdateInputHandler
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 21b79f0ccdc2..b0b463e8dd2e 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -656,6 +656,15 @@ namespace
 
 //      actual functions
 
+void ScViewFunc::EnterDataToCurrentCell(const OUString& rString, const 
EditTextObject* pData, bool bMatrixExpand)
+{
+    SCCOL nCol = GetViewData().GetCurX();
+    SCROW nRow = GetViewData().GetCurY();
+    SCTAB nTab = GetViewData().GetTabNo();
+
+    EnterData(nCol, nRow, nTab, rString, pData, bMatrixExpand);
+}
+
 //  input - undo OK
 void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
                             const OUString& rString,

Reply via email to