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 e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Fri Apr 1 14:50:42 2022 +0530
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Wed Apr 6 11:37:38 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.
    
    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>

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index c139afe9244c..6c0cfbb8b393 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -199,7 +199,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 c04e0db4aa86..c459c3438ca9 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2934,7 +2934,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())
@@ -3016,6 +3016,16 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode )
                     }
                 }
 
+                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;
+                }
+
                 vcl::Window* pParent = nullptr;
                 if (pActiveViewSh)
                     pParent = &pActiveViewSh->GetViewFrame()->GetWindow();
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 4163094bd390..d7619d23a156 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1407,13 +1407,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 ddd3f4f49e8b..a57905d05597 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 4a6062fddff5..446854246c89 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -759,9 +759,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

Reply via email to