Revert "tdf#142214: autocomplete: do not search across empty blocks"

This reverts commit ca2ec443893731093970914feb750b31ea13e47f.

Breaks user experience.

Removed ScTiledRenderingTest::testAutoInputStringBlock as well.

Change-Id: Id03bc645d78c29c0aa588b2133fc1cb96f3cceb3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121640
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index bc9259b..dc58137 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -114,7 +114,6 @@ public:
    void testSpellOnlineRenderParameter();
    void testPasteIntoWrapTextCell();
    void testSortAscendingDescending();
    void testAutoInputStringBlock();
    void testAutoInputExactMatch();
    void testMoveShapeHandle();
    void testEditCursorBounds();
@@ -168,7 +167,6 @@ public:
    CPPUNIT_TEST(testSpellOnlineRenderParameter);
    CPPUNIT_TEST(testPasteIntoWrapTextCell);
    CPPUNIT_TEST(testSortAscendingDescending);
    CPPUNIT_TEST(testAutoInputStringBlock);
    CPPUNIT_TEST(testAutoInputExactMatch);
    CPPUNIT_TEST(testMoveShapeHandle);
    CPPUNIT_TEST(testEditCursorBounds);
@@ -2652,41 +2650,6 @@ void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, ScTabV
    Scheduler::ProcessEventsToIdle();
}

void ScTiledRenderingTest::testAutoInputStringBlock()
{
    comphelper::LibreOfficeKit::setActive();

    ScModelObj* pModelObj = createDoc("empty.ods");
    CPPUNIT_ASSERT(pModelObj);
    ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
    CPPUNIT_ASSERT(pView);
    ScDocument* pDoc = pModelObj->GetDocument();

    pDoc->SetString(ScAddress(0, 3, 0), "ABC");  // A4
    pDoc->SetString(ScAddress(0, 4, 0), "BAC");  // A5
    ScFieldEditEngine& rEE = pDoc->GetEditEngine();
    rEE.SetText("XYZ");
    pDoc->SetEditText(ScAddress(0, 5, 0), rEE.CreateTextObject()); // A6
    pDoc->SetValue(ScAddress(0, 6, 0), 123);
    pDoc->SetString(ScAddress(0, 7, 0), "ZZZ");  // A8

    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));

    ScAddress aA3(0, 2, 0); // Adjacent to the string "superblock" A4:A8
    lcl_typeCharsInCell("X", aA3.Col(), aA3.Row(), pView, pModelObj); // Type 'X' in A3
    CPPUNIT_ASSERT_EQUAL_MESSAGE("A3 should autocomplete", OUString("XYZ"), pDoc->GetString(aA3));

    ScAddress aA9(0, 8, 0); // Adjacent to the string "superblock" A4:A8
    lcl_typeCharsInCell("X", aA9.Col(), aA9.Row(), pView, pModelObj); // Type 'X' in A9
    CPPUNIT_ASSERT_EQUAL_MESSAGE("A9 should autocomplete", OUString("XYZ"), pDoc->GetString(aA9));

    ScAddress aA11(0, 10, 0);
    lcl_typeCharsInCell("X", aA11.Col(), aA11.Row(), pView, pModelObj); // Type 'X' in A11
    CPPUNIT_ASSERT_EQUAL_MESSAGE("A11 should not autocomplete", OUString("X"), pDoc->GetString(aA11));
}

void ScTiledRenderingTest::testAutoInputExactMatch()
{
    comphelper::LibreOfficeKit::setActive();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 48ad569..2655ee6 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -821,22 +821,14 @@ 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 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.
    m_pDoc->GetDataEntries(0, 0, 0, aEntries); // Try at the very top.

    // Entries are supposed to be sorted in ascending order, and are all unique.
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size());
    it = aEntries.begin();
    std::vector<ScTypedStrData>::const_iterator it = aEntries.begin();
    CPPUNIT_ASSERT_EQUAL(OUString("Andy"), it->GetString());
    ++it;
    CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), it->GetString());
@@ -846,7 +838,7 @@ void Test::testDataEntries()
    CPPUNIT_ASSERT_MESSAGE("The entries should have ended here.", bool(it == aEntries.end()));

    aEntries.clear();
    m_pDoc->GetDataEntries(0, 12, 0, aEntries); // Try at A13.
    m_pDoc->GetDataEntries(0, MAXROW, 0, aEntries); // Try at the very bottom.
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size());

    // Make sure we get the same set of suggestions.
@@ -859,11 +851,6 @@ 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 def3e6a..b352eac 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2642,11 +2642,6 @@ 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())
@@ -2654,7 +2649,7 @@ public:
            // Not in a string block. Move back until we hit a string block.
            while (!has())
            {
                if (isEmpty() || maPos.first == miBeg)
                if (maPos.first == miBeg)
                    return false;

                --maPos.first; // move to the preceding block.
@@ -2680,10 +2675,6 @@ 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;
            }
@@ -2698,9 +2689,6 @@ 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;
@@ -2722,10 +2710,6 @@ public:
                    return false;

                maPos.second = 0;

                if (isEmpty())
                    return false;

                if (has())
                    break;
            }
@@ -2761,12 +2745,16 @@ bool ScColumn::GetDataEntries(
    // going upward and downward directions in parallel. The start position
    // cell must be skipped.

    StrCellIterator aItrUp(maCells, nStartRow-1, &GetDoc());
    StrCellIterator aItrUp(maCells, nStartRow, &GetDoc());
    StrCellIterator aItrDown(maCells, nStartRow+1, &GetDoc());

    bool bMoveUp = aItrUp.valid();
    if (bMoveUp && !aItrUp.has())
        bMoveUp = aItrUp.prev(); // Find the previous string cell position.
    if (!bMoveUp)
        // Current cell is invalid.
        return false;

    // Skip the start position cell.
    bMoveUp = aItrUp.prev(); // Find the previous string cell position.

    bool bMoveDown = aItrDown.valid();
    if (bMoveDown && !aItrDown.has())