sc/inc/scmod.hxx | 2 +- sc/source/ui/app/inputhdl.cxx | 12 +++++++++++- sc/source/ui/app/scmod.cxx | 4 ++-- sc/source/ui/inc/inputhdl.hxx | 2 +- sc/source/ui/view/tabvwsha.cxx | 11 +++++++++-- 5 files changed, 24 insertions(+), 7 deletions(-)
New commits: commit 08d3d0bcfd6a0540b19252730b2090da0b5da2d4 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Fri Apr 1 14:50:42 2022 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Fri Apr 8 09:15:30 2022 +0200 lok: avoid validation-dialog yield when saving Disable error dialog box when about to save in lok mode as this ultimately invokes SvpSalInstance::DoYield() when we want to save immediately without committing any erroneous input in possibly a cell with validation rules. After save is complete the user can continue editing. Conflicts: sc/source/ui/app/inputhdl.cxx Change-Id: Iffa0766ad594db75f57158986c4e1d2646f71da4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132410 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> (cherry picked from commit e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132654 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index a0a6e17e8423..919f4c22056d 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -197,7 +197,7 @@ public: bool IsInputMode(); // also for SC_INPUT_TYPE void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr ); bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false ); - SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL ); + SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false ); void InputCancelHandler(); void InputSelection( const EditView* pView ); void InputChanged( const EditView* pView ); diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index abd1190475fb..f7a41b13d084 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2993,7 +2993,7 @@ static void lcl_SelectionToEnd( EditView* pView ) } } -void ScInputHandler::EnterHandler( ScEnterMode nBlockMode ) +void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInLOK ) { if (!mbDocumentDisposing && comphelper::LibreOfficeKit::isActive() && pActiveViewSh != SfxViewShell::Current()) @@ -3073,6 +3073,16 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode ) pSelEngine->ReleaseMouse(); } + if (bBeforeSavingInLOK) + { + // Invalid entry but not applied to the document model. + // Exit to complete the "save", leaving the edit view as it is + // for the user to continue after save. + bInOwnChange = false; + bInEnterHandler = false; + return; + } + if (pData->DoError(pActiveViewSh->GetFrameWeld(), aString, aCursorPos)) bForget = true; // Do not take over input } diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index c4c0584eb6a9..97a5461956ca 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -1405,13 +1405,13 @@ bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit ) return pHdl && pHdl->KeyInput( rKEvt, bStartEdit ); } -void ScModule::InputEnterHandler( ScEnterMode nBlockMode ) +void ScModule::InputEnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInLOK ) { if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program { ScInputHandler* pHdl = GetInputHdl(); if (pHdl) - pHdl->EnterHandler( nBlockMode ); + pHdl->EnterHandler( nBlockMode, bBeforeSavingInLOK ); } } diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index 0bc24bcd51db..625d2f7ca1f8 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -196,7 +196,7 @@ public: void MergeLanguageAttributes( ScEditEngineDefaulter& rDestEngine ) const; bool KeyInput( const KeyEvent& rKEvt, bool bStartEdit ); - void EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL ); + void EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false ); void CancelHandler(); void SetReference( const ScRange& rRef, const ScDocument& rDoc ); void AddRefEntry(); diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 734ccd915941..393a59cc4d42 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -760,9 +760,16 @@ void ScTabViewShell::ExecuteSave( SfxRequest& rReq ) // Finish entering unless 'DontTerminateEdit' is specified, even if a formula is being processed if (bCommitChanges) { - SC_MOD()->InputEnterHandler(); + bool bLOKActive = comphelper::LibreOfficeKit::isActive(); - if (comphelper::LibreOfficeKit::isActive()) + // Disable error dialog box when about to save in lok mode as + // this ultimately invokes SvpSalInstance::DoYield() when we want + // to save immediately without committing any erroneous input in possibly + // a cell with validation rules. After save is complete the user + // can continue editing. + SC_MOD()->InputEnterHandler(ScEnterMode::NORMAL, bLOKActive /* bBeforeSavingInLOK */); + + if (bLOKActive) { // Normally this isn't needed, but in Calc when editing a cell formula // and manually saving (without changing cells or hitting enter), while