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 ad07f4df8cc992df4f523e6b60540688d44431a9 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jul 22 23:48:45 2025 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Aug 8 11:01:00 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> diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index abded6a51b71..5a3b89db9af5 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 a1b24136a95f..2fcdd0ceef40 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 afc6009a03e5..c18f977b9d5c 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -655,6 +655,15 @@ void runAutoCorrectQueryAsync(const std::shared_ptr<FormulaProcessingContext>& c } // end anonymous namespace +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,