sc/source/ui/app/inputhdl.cxx | 21 ++++++++++++++------- sc/source/ui/inc/inputhdl.hxx | 13 +++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-)
New commits: commit b4d0d96b792584891e96cb0e297ca32d58904601 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 27 21:18:32 2025 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Nov 28 11:38:03 2025 +0100 Related: tdf#169351 pass an explicit handler for input handler error message default it to the current behaviour Change-Id: Ic99f8120326002c1d1476137cb49b3cee1ef928f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194744 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 7b8a6ed5c94c..cf7b8d0c8d78 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2501,8 +2501,8 @@ void ScInputHandler::RemoveRangeFinder() DeleteRangeFinder(); // Deletes the list and the labels on the table } -bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, - ScEditEngineDefaulter* pTopEngine ) +bool ScInputHandler::StartTable(sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, + ScEditEngineDefaulter* pTopEngine, const ErrorHdl& errorHdl) { bool bNewTable = false; @@ -2554,8 +2554,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn if ( bFromCommand ) bCommandErrorShown = true; - pActiveViewSh->GetActiveWin()->GrabFocus(); - pActiveViewSh->ErrorMessage(aTester.GetMessageId()); + errorHdl(pActiveViewSh, aTester.GetMessageId()); } bStartInputMode = false; } @@ -2758,6 +2757,13 @@ IMPL_LINK_NOARG(ScInputHandler, ModifyHdl, LinkParamNone*, void) } } +//static +void ScInputHandler::ErrorMessage(ScTabViewShell* pActiveViewShell, TranslateId messageId) +{ + pActiveViewShell->GetActiveWin()->GrabFocus(); + pActiveViewShell->ErrorMessage(messageId); +} + /** * @return true means new view created */ @@ -2768,7 +2774,7 @@ bool ScInputHandler::DataChanging( sal_Unicode cTyped, bool bFromCommand ) bInOwnChange = true; // disable ModifyHdl (reset in DataChanged) if ( eMode == SC_INPUT_NONE ) - return StartTable( cTyped, bFromCommand, false, nullptr ); + return StartTable(cTyped, bFromCommand, false, nullptr, ScInputHandler::ErrorMessage); else return false; } @@ -3017,7 +3023,8 @@ void ScInputHandler::InvalidateAttribs() // --------------- public methods -------------------------------------------- -void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText, ScEditEngineDefaulter* pTopEngine ) +void ScInputHandler::SetMode(ScInputMode eNewMode, const OUString* pInitText, ScEditEngineDefaulter* pTopEngine, + const ErrorHdl& errorHdl) { if ( eMode == eNewMode ) return; @@ -3050,7 +3057,7 @@ void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText, S { if (eOldMode == SC_INPUT_NONE) // not if switching between modes { - if (StartTable(0, false, eMode == SC_INPUT_TABLE, pTopEngine)) + if (StartTable(0, false, eMode == SC_INPUT_TABLE, pTopEngine, errorHdl)) { pActiveViewSh->GetViewData().GetDocShell()->PostEditView(*mpEditEngine, aCursorPos); } diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index bd3736ba7a0b..2f3ac5c204c4 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -51,6 +51,8 @@ class VclWindowEvent; namespace vcl { class Window; } struct ReferenceMark; +typedef std::function<void(ScTabViewShell*, TranslateId)> ErrorHdl; + // ScInputHandler class ScInputHandler final @@ -142,8 +144,8 @@ private: * table EditEngine. * @return true if the new edit mode has been started. */ - bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, - ScEditEngineDefaulter* pTopEngine ); + bool StartTable(sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, + ScEditEngineDefaulter* pTopEngine, const ErrorHdl& errorHdl); void RemoveSelection(); bool StartsLikeFormula( std::u16string_view rStr ) const; void UpdateFormulaMode(); @@ -182,8 +184,9 @@ public: ScInputHandler(); ~ScInputHandler(); - void SetMode( ScInputMode eNewMode, const OUString* pInitText = nullptr, - ScEditEngineDefaulter* pTopEngine = nullptr ); + void SetMode(ScInputMode eNewMode, const OUString* pInitText = nullptr, + ScEditEngineDefaulter* pTopEngine = nullptr, + const ErrorHdl& errorHdl = ScInputHandler::ErrorMessage); void StartOrToggleEditMode(); bool IsInputMode() const { return (eMode != SC_INPUT_NONE); } bool IsEditMode() const { return (eMode != SC_INPUT_NONE && @@ -298,6 +301,8 @@ public: tools::Long nX1, tools::Long nX2, tools::Long nY1, tools::Long nY2, tools::Long nTab, const Color& rColor ); + static void ErrorMessage(ScTabViewShell* pActiveViewShell, TranslateId errorMessage); + void LOKPasteFunctionData(const OUString& rFunctionName); };
