sc/source/core/data/column2.cxx |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 94960bb3357bc443453e4cea2329f34cc7e80196
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Sun Mar 6 15:55:10 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sun Mar 6 19:42:35 2022 +0100

    don't try to spellcheck after last data cell (tdf#122827)
    
    Change-Id: I728e7f19a521f5f3583b4963d84c7d36527c8842
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131076
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index a7858ab47361..bf1b43d10f39 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1069,7 +1069,6 @@ void ScColumn::GetOptimalHeight(
 bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& 
rData) const
 {
     ScDocument& rDocument = GetDoc();
-    bool bStop = false;
     sc::CellStoreType::const_iterator it = maCells.position(nRow).first;
     mdds::mtv::element_t eType = it->type;
     if (!bInSel && it != maCells.end() && eType != sc::element_type_empty)
@@ -1079,15 +1078,16 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool 
bInSel, const ScMarkData& r
                rDocument.IsTabProtected(nTab)) )
             return true;
     }
-    while (!bStop)
+    if (bInSel)
     {
-        if (bInSel)
+        SCROW lastDataPos = GetLastDataPos();
+        for (;;)
         {
             nRow = rData.GetNextMarked(nCol, nRow, false);
-            if (!rDocument.ValidRow(nRow))
+            if (!rDocument.ValidRow(nRow) || nRow > lastDataPos )
             {
                 nRow = GetDoc().MaxRow()+1;
-                bStop = true;
+                return false;
             }
             else
             {
@@ -1101,7 +1101,10 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool 
bInSel, const ScMarkData& r
                     nRow++;
             }
         }
-        else if (GetNextDataPos(nRow))
+    }
+    else
+    {
+        while (GetNextDataPos(nRow))
         {
             it = maCells.position(it, nRow).first;
             eType = it->type;
@@ -1112,13 +1115,9 @@ bool ScColumn::GetNextSpellingCell(SCROW& nRow, bool 
bInSel, const ScMarkData& r
             else
                 nRow++;
         }
-        else
-        {
-            nRow = GetDoc().MaxRow()+1;
-            bStop = true;
-        }
+        nRow = GetDoc().MaxRow()+1;
+        return false;
     }
-    return false;
 }
 
 namespace {

Reply via email to