summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-06-20 23:58:46 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-06-24 16:51:38 -0400
commit91f7e9e02e72b46c881656a6b493fac276a6822b (patch)
tree6fa603b42987de1552642b560a5713f4da2506d6 /sc
parent8a39b8ce354bd42325ff61c07cfdc7a150d2925a (diff)
Fix a bug in "find all" search, and a test to catch it in the future.
Change-Id: I296d2dff65da55cc86e10a78eb9c768a924fcddd
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_ucalc.mk1
-rw-r--r--sc/qa/unit/ucalc.cxx38
-rw-r--r--sc/source/core/data/column2.cxx3
3 files changed, 42 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk
index 68d6cb5d3bf0..b6e5e3e73343 100644
--- a/sc/CppunitTest_sc_ucalc.mk
+++ b/sc/CppunitTest_sc_ucalc.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_ucalc,\
fileaccess/source/fileacc \
framework/util/fwk \
i18npool/util/i18npool \
+ i18npool/source/search/i18nsearch \
sax/source/expatwrap/expwrap \
sfx2/util/sfx \
ucb/source/core/ucb1 \
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 55d5c2a8388a..b29a89ea6361 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -64,6 +64,7 @@
#include <svx/svdpage.hxx>
#include <svx/svdocirc.hxx>
#include <svx/svdopath.hxx>
+#include "svl/srchitem.hxx"
#include <sfx2/docfile.hxx>
@@ -234,6 +235,7 @@ public:
void testCopyPaste();
void testMergedCells();
void testUpdateReference();
+ void testSearchCells();
/**
* Make sure the sheet streams are invalidated properly.
@@ -349,6 +351,7 @@ public:
CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testMergedCells);
CPPUNIT_TEST(testUpdateReference);
+ CPPUNIT_TEST(testSearchCells);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
CPPUNIT_TEST(testSetBackgroundColor);
CPPUNIT_TEST(testRenameTable);
@@ -6205,6 +6208,41 @@ void Test::testUpdateReference()
m_pDoc->DeleteTab(0);
}
+void Test::testSearchCells()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ m_pDoc->SetString(ScAddress(0,0,0), "A");
+ m_pDoc->SetString(ScAddress(0,1,0), "B");
+ m_pDoc->SetString(ScAddress(0,2,0), "A");
+ // Leave A4 blank.
+ m_pDoc->SetString(ScAddress(0,4,0), "A");
+ m_pDoc->SetString(ScAddress(0,5,0), "B");
+ m_pDoc->SetString(ScAddress(0,6,0), "C");
+
+ SvxSearchItem aItem(SID_SEARCH_ITEM);
+ aItem.SetSearchString(OUString("A"));
+ aItem.SetCommand(SVX_SEARCHCMD_FIND_ALL);
+ ScMarkData aMarkData;
+ aMarkData.SelectOneTable(0);
+ SCCOL nCol = 0;
+ SCROW nRow = 0;
+ SCTAB nTab = 0;
+ ScRangeList aMatchedRanges;
+ OUString aUndoStr;
+ m_pDoc->SearchAndReplace(aItem, nCol, nRow, nTab, aMarkData, aMatchedRanges, aUndoStr);
+
+ CPPUNIT_ASSERT_MESSAGE("There should be exactly 3 matching cells.", aMatchedRanges.size() == 3);
+ ScAddress aHit(0,0,0);
+ CPPUNIT_ASSERT_MESSAGE("A1 should be inside the matched range.", aMatchedRanges.In(aHit));
+ aHit.SetRow(2);
+ CPPUNIT_ASSERT_MESSAGE("A3 should be inside the matched range.", aMatchedRanges.In(aHit));
+ aHit.SetRow(4);
+ CPPUNIT_ASSERT_MESSAGE("A5 should be inside the matched range.", aMatchedRanges.In(aHit));
+
+ m_pDoc->DeleteTab(0);
+}
+
namespace {
bool hasRange(const std::vector<ScTokenRef>& rRefTokens, const ScRange& rRange)
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 10eba3f32079..02ce164fa3bf 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1346,6 +1346,9 @@ bool ScColumn::GetNextDataPos(SCROW& rRow) const // greater than rRow
if (it == maCells.end())
// No more next block.
return false;
+
+ // Next block exists, and is non-empty.
+ return true;
}
if (aPos.second < it->size - 1)