sc/source/ui/view/gridwin.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit d098e027cb9899e31ae3ff7ba245b78a009681fb
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Dec 14 11:52:17 2021 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Feb 1 00:03:14 2022 +0100

    tdf#120896 sc: commit change after PopupSpelling
    
    Although PopupSpelling visually has changed the screen,
    the underlying document still contained the
    old cached string or spelling status.
    Thus spell-check still thought it was spelled wrong,
    and right-clicking got very confused.
    
    Steps to reproduce:
    1.) type aaa and hit enter.  (spelling error noted)
    2.) right-click on "aaa" and chose various options.
    2a.) --- replace with a suggestion
    2b.) --- ignore word
    2c.) --- add to dictionary
    2d.) --- change language
    2d.) --- autocorrect
    (note we are still in editing mode)
    3.) right-click again on the new or approved word
    (no pop-up at all.)
    
    The fix is to stop editing, so the changes are
    applied to the various caches.
    
    Steps that should NOT stop editing the cell
    2e.) --- press ESC (or anything that cancels the pop-up)
    2f.) --- choose Autocorrect Options
    
    Change-Id: I9965ede6f6a5c31a811ff89abb687497306d6d1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126802
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1bc40626c81a..80cbf4e3728a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -489,6 +489,13 @@ IMPL_LINK( ScGridWindow, PopupSpellingHdl, 
SpellCallbackInfo&, rInfo, void )
         mrViewData.GetDispatcher().Execute( SID_SPELL_DIALOG, 
SfxCallMode::ASYNCHRON );
     else if (rInfo.nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
         mrViewData.GetDispatcher().Execute( SID_AUTO_CORRECT_DLG, 
SfxCallMode::ASYNCHRON );
+    else //IGNOREWORD, ADDTODICTIONARY, WORDLANGUAGE, PARALANGUAGE
+    {
+        // The spelling status of the word has changed. Close the cell to 
reset the caches
+        ScInputHandler* pHdl = 
SC_MOD()->GetInputHdl(mrViewData.GetViewShell());
+        if (pHdl)
+            pHdl->EnterHandler();
+    }
 }
 
 namespace {
@@ -3294,9 +3301,14 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
             if (pHdl)
                 pHdl->SetModified();
 
+            const OUString sOldText = pHdl ? pHdl->GetEditString() : "";
+
             Link<SpellCallbackInfo&,void> aLink = LINK( this, ScGridWindow, 
PopupSpellingHdl );
             pEditView->ExecuteSpellPopup(aMenuPos, aLink);
 
+            if (pHdl && pHdl->GetEditString() != sOldText)
+                pHdl->EnterHandler();
+
             bDone = true;
         }
     }

Reply via email to