summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2022-04-01 14:50:42 +0530
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2022-04-12 20:28:25 +0200
commitc45ab05455486323763851d6c3b6a168ae1abba6 (patch)
treebd121b737537cf090d8b604d785bd76d1a1f5aac
parentd19c99d10764531279e59959aa84f832afee14a6 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132656 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/source/ui/app/inputhdl.cxx12
-rw-r--r--sc/source/ui/app/scmod.cxx4
-rw-r--r--sc/source/ui/inc/inputhdl.hxx2
-rw-r--r--sc/source/ui/view/tabvwsha.cxx11
5 files changed, 24 insertions, 7 deletions
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 4a89fd3424cd..70170984d0dc 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -198,7 +198,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 d844401a8807..30f18a075c7c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3002,7 +3002,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())
@@ -3082,6 +3082,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 dee33b48a509..3534ecdb69e3 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1356,13 +1356,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 fb3880e97a69..f66688a257ca 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -198,7 +198,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 414a293d854d..209f935a729f 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -757,9 +757,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