Skip to content

Commit

Permalink
Revert "tdf#142214: autocomplete: do not search across empty blocks"
Browse files Browse the repository at this point in the history
This reverts commit ca2ec44.

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>
(cherry picked from commit 223f3a6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121570
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
  • Loading branch information
ilmari-lauhakangas authored and Xisco Fauli committed Sep 6, 2021
1 parent c9c9ed3 commit 4ac35a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 73 deletions.
37 changes: 0 additions & 37 deletions sc/qa/unit/tiledrendering/tiledrendering.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::Macr
void testSpellOnlineRenderParameter();
void testPasteIntoWrapTextCell();
void testSortAscendingDescending();
void testAutoInputStringBlock();
void testAutoInputExactMatch();
void testMoveShapeHandle();
void testEditCursorBounds();
Expand Down Expand Up @@ -167,7 +166,6 @@ class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::Macr
CPPUNIT_TEST(testSpellOnlineRenderParameter);
CPPUNIT_TEST(testPasteIntoWrapTextCell);
CPPUNIT_TEST(testSortAscendingDescending);
CPPUNIT_TEST(testAutoInputStringBlock);
CPPUNIT_TEST(testAutoInputExactMatch);
CPPUNIT_TEST(testMoveShapeHandle);
CPPUNIT_TEST(testEditCursorBounds);
Expand Down Expand Up @@ -2650,41 +2648,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();
Expand Down
19 changes: 3 additions & 16 deletions sc/qa/unit/ucalc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -816,22 +816,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());
Expand All @@ -841,7 +833,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.
Expand All @@ -854,11 +846,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);
}

Expand Down
28 changes: 8 additions & 20 deletions sc/source/core/data/column3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2592,19 +2592,14 @@ class StrCellIterator
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())
{
// 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.
Expand All @@ -2630,10 +2625,6 @@ class StrCellIterator
// Move to the last cell of the previous block.
--maPos.first;
maPos.second = maPos.first->size - 1;

if (isEmpty())
return false;

if (has())
break;
}
Expand All @@ -2648,9 +2639,6 @@ class StrCellIterator
// 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;
Expand All @@ -2672,10 +2660,6 @@ class StrCellIterator
return false;

maPos.second = 0;

if (isEmpty())
return false;

if (has())
break;
}
Expand Down Expand Up @@ -2711,12 +2695,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())
Expand Down

0 comments on commit 4ac35a8

Please sign in to comment.