sc/source/ui/view/gridwin.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 0e87e8a810b93a740beff63ceb1e40d2e5271acf
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat Sep 30 07:02:08 2023 -0400
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 5 11:35:10 2023 +0200

    tdf#157038 sc: avoid spell-check dialog from outside selection
    
    Fixes 7.4 regression from cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd
    
    To avoid the HIGHLY LIKELY risk of losing the selection
    because of the LOW POTENTIAL of the right click
    being over a misspelling (that overflowed from outside the selection),
    simply don't even attempt to spell-check in that case.
    
    The opposite was already true (and is even worse).
    If the misspelling originates in the selected cells,
    but has overflowed into an unselected area,
    right clicking on the misspelling is deliberately ignored
    by SelectForContextMenu().
    
    Change-Id: I7dfc5b190036f1705d848cb621e527cbff37e425
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157430
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit 4cf4516bac88fb8f58743e6ae68eab0393059d7f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157328
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>
    (cherry picked from commit d23b589a9c4fd38e714e23ff91e623a33909a739)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157469

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d1f8dead3a7c..e86f97f33ed4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3153,9 +3153,22 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
             if (aPos.Col() >= 0 && (aSpellCheckCell.getType() == 
CELLTYPE_STRING || aSpellCheckCell.getType() == CELLTYPE_EDIT))
                 nColSpellError = aPos.Col();
 
-            // Is there a misspelled word somewhere in the cell?
+            // Is there possibly a misspelled word somewhere in the cell?
             // A "yes" does not mean that the word under the mouse pointer is 
wrong though.
             bSpellError = (mpSpellCheckCxt->isMisspelled(nColSpellError, 
nCellY));
+            // Avoid situations where selecting the cell-with-wrong-spelling 
would be bad
+            if (bSpellError)
+            {
+                // When the mouse is over an empty cell, text with spelling 
errors
+                // potentially could have overflowed underneath the mouse 
pointer
+                if (nColSpellError != nCellX)
+                {
+                    // If the mouse is over a selected cell, only consider 
spell-checking
+                    // if the cell with the misspelling is also selected. 
tdf#157038
+                    if (mrViewData.GetMarkData().IsCellMarked(nCellX, nCellY))
+                        bSpellError = 
mrViewData.GetMarkData().IsCellMarked(nColSpellError, nCellY);
+                }
+            }
         }
 
         //  #i18735# First select the item under the mouse pointer.

Reply via email to