[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/qa sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Wed May 12 09:28:26 UTC 2021


 sc/qa/unit/tiledrendering/tiledrendering.cxx |    8 +++----
 sc/qa/unit/ucalc.cxx                         |   19 +++++++++++++++---
 sc/source/core/data/column3.cxx              |   28 +++++++++++++++++++--------
 3 files changed, 40 insertions(+), 15 deletions(-)

New commits:
commit 4484ebc77acd3396c6ea7e261d8f583dbbbe4438
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Fri May 7 16:32:52 2021 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Wed May 12 11:27:54 2021 +0200

    autocomplete: do not search across empty blocks
    
    Change-Id: Ia5b0be1eed2bf645fa1e53d71abc7b2e67dfaa0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115344
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index f131766d4bd3..a058d7257bbc 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2455,9 +2455,9 @@ void ScTiledRenderingTest::testAutoInputStringBlock()
     pDoc->SetEditText(ScAddress(0, 5, 0), rEE.CreateTextObject()); // A6
     pDoc->SetString(ScAddress(0, 6, 0), "ZZZ");  // A7
 
-    /*ScAddress aA1(0, 0, 0);
+    ScAddress aA1(0, 0, 0);
     lcl_typeCharsInCell("X", aA1.Col(), aA1.Row(), pView, pModelObj); // Type 'X' in A1
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("A1 should not autocomplete", OUString("X"), pDoc->GetString(aA1));*/
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("A1 should not autocomplete", OUString("X"), pDoc->GetString(aA1));
 
     ScAddress aA3(0, 2, 0); // Adjacent to the string "superblock" A4:A7
     lcl_typeCharsInCell("X", aA3.Col(), aA3.Row(), pView, pModelObj); // Type 'X' in A3
@@ -2467,9 +2467,9 @@ void ScTiledRenderingTest::testAutoInputStringBlock()
     lcl_typeCharsInCell("X", aA7.Col(), aA7.Row(), pView, pModelObj); // Type 'X' in A7
     CPPUNIT_ASSERT_EQUAL_MESSAGE("A7 should autocomplete", OUString("XYZ"), pDoc->GetString(aA7));
 
-    /*ScAddress aA10(0, 9, 0);
+    ScAddress aA10(0, 9, 0);
     lcl_typeCharsInCell("X", aA10.Col(), aA10.Row(), pView, pModelObj); // Type 'X' in A10
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("A10 should not autocomplete", OUString("X"), pDoc->GetString(aA10));*/
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("A10 should not autocomplete", OUString("X"), pDoc->GetString(aA10));
 }
 
 void ScTiledRenderingTest::testAutoInputExactMatch()
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ae28aadeae31..3c21c990cf44 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -534,14 +534,22 @@ void Test::testDataEntries()
     m_pDoc->SetString(ScAddress(0,5,0), "Andy");
     m_pDoc->SetString(ScAddress(0,6,0), "Bruce");
     m_pDoc->SetString(ScAddress(0,7,0), "Charlie");
+    m_pDoc->SetValue(ScAddress(0,8,0), 100);
+    m_pDoc->SetValue(ScAddress(0,9,0), 200);
     m_pDoc->SetString(ScAddress(0,10,0), "Andy");
+    m_pDoc->SetValue(ScAddress(0,11,0), 1000);
 
     std::vector<ScTypedStrData> aEntries;
-    m_pDoc->GetDataEntries(0, 0, 0, aEntries); // Try at the very top.
+    m_pDoc->GetDataEntries(0, 0, 0, aEntries); // Try at the top.
+    std::vector<ScTypedStrData>::const_iterator it = aEntries.begin();
+    CPPUNIT_ASSERT_MESSAGE("The entries should be empty.", bool(it == aEntries.end()));
+
+    aEntries.clear();
+    m_pDoc->GetDataEntries(0, 4, 0, aEntries); // Try at A5.
 
     // Entries are supposed to be sorted in ascending order, and are all unique.
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size());
-    std::vector<ScTypedStrData>::const_iterator it = aEntries.begin();
+    it = aEntries.begin();
     CPPUNIT_ASSERT_EQUAL(OUString("Andy"), it->GetString());
     ++it;
     CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), it->GetString());
@@ -551,7 +559,7 @@ void Test::testDataEntries()
     CPPUNIT_ASSERT_MESSAGE("The entries should have ended here.", bool(it == aEntries.end()));
 
     aEntries.clear();
-    m_pDoc->GetDataEntries(0, MAXROW, 0, aEntries); // Try at the very bottom.
+    m_pDoc->GetDataEntries(0, 12, 0, aEntries); // Try at A13.
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size());
 
     // Make sure we get the same set of suggestions.
@@ -564,6 +572,11 @@ void Test::testDataEntries()
     ++it;
     CPPUNIT_ASSERT_MESSAGE("The entries should have ended here.", bool(it == aEntries.end()));
 
+    aEntries.clear();
+    m_pDoc->GetDataEntries(0, MAXROW, 0, aEntries); // Try at the bottom.
+    it = aEntries.begin();
+    CPPUNIT_ASSERT_MESSAGE("The entries should be empty.", bool(it == aEntries.end()));
+
     m_pDoc->DeleteTab(0);
 }
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 90a0dcec43aa..0f7ccf19a187 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2548,6 +2548,11 @@ public:
         return (maPos.first->type == sc::element_type_string || maPos.first->type == sc::element_type_edittext);
     }
 
+    bool isEmpty() const
+    {
+        return maPos.first->type == sc::element_type_empty;
+    }
+
     bool prev()
     {
         if (!has())
@@ -2555,7 +2560,7 @@ public:
             // Not in a string block. Move back until we hit a string block.
             while (!has())
             {
-                if (maPos.first == miBeg)
+                if (isEmpty() || maPos.first == miBeg)
                     return false;
 
                 --maPos.first; // move to the preceding block.
@@ -2581,6 +2586,10 @@ public:
                 // Move to the last cell of the previous block.
                 --maPos.first;
                 maPos.second = maPos.first->size - 1;
+
+                if (isEmpty())
+                    return false;
+
                 if (has())
                     break;
             }
@@ -2595,6 +2604,9 @@ public:
             // Not in a string block. Move forward until we hit a string block.
             while (!has())
             {
+                if (isEmpty())
+                    return false;
+
                 ++maPos.first;
                 if (maPos.first == miEnd)
                     return false;
@@ -2616,6 +2628,10 @@ public:
                     return false;
 
                 maPos.second = 0;
+
+                if (isEmpty())
+                    return false;
+
                 if (has())
                     break;
             }
@@ -2657,16 +2673,12 @@ bool ScColumn::GetDataEntries(
     // going upward and downward directions in parallel. The start position
     // cell must be skipped.
 
-    StrCellIterator aItrUp(maCells, nStartRow, GetDoc());
+    StrCellIterator aItrUp(maCells, nStartRow-1, GetDoc());
     StrCellIterator aItrDown(maCells, nStartRow+1, GetDoc());
 
     bool bMoveUp = aItrUp.valid();
-    if (!bMoveUp)
-        // Current cell is invalid.
-        return false;
-
-    // Skip the start position cell.
-    bMoveUp = aItrUp.prev(); // Find the previous string cell position.
+    if (bMoveUp && !aItrUp.has())
+        bMoveUp = aItrUp.prev(); // Find the previous string cell position.
 
     bool bMoveDown = aItrDown.valid();
     if (bMoveDown && !aItrDown.has())


More information about the Libreoffice-commits mailing list