[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/CppunitTest_sc_ucalc.mk sc/qa sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Jun 20 20:56:22 PDT 2013


 sc/CppunitTest_sc_ucalc.mk      |    1 +
 sc/qa/unit/ucalc.cxx            |   38 ++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/column2.cxx |    3 +++
 3 files changed, 42 insertions(+)

New commits:
commit 0a3dd7a30a6fb9e795b76f7d3d90184825fa49f7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Jun 20 23:58:46 2013 -0400

    Fix a bug in "find all" search, and a test to catch it in the future.
    
    Change-Id: I296d2dff65da55cc86e10a78eb9c768a924fcddd

diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk
index acf7bdb..628c366 100644
--- a/sc/CppunitTest_sc_ucalc.mk
+++ b/sc/CppunitTest_sc_ucalc.mk
@@ -79,6 +79,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 a21592f..2934a59 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>
 
@@ -224,6 +225,7 @@ public:
     void testCopyPaste();
     void testMergedCells();
     void testUpdateReference();
+    void testSearchCells();
 
     /**
      * Make sure the sheet streams are invalidated properly.
@@ -329,6 +331,7 @@ public:
     CPPUNIT_TEST(testCopyPaste);
     CPPUNIT_TEST(testMergedCells);
     CPPUNIT_TEST(testUpdateReference);
+    CPPUNIT_TEST(testSearchCells);
     CPPUNIT_TEST(testJumpToPrecedentsDependents);
     CPPUNIT_TEST(testSetBackgroundColor);
     CPPUNIT_TEST(testRenameTable);
@@ -6135,6 +6138,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 6ac4a17..8c52e5c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1349,6 +1349,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)


More information about the Libreoffice-commits mailing list