summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/queryiter.hxx2
-rw-r--r--sc/qa/unit/ucalc_sort.cxx46
-rw-r--r--sc/source/core/data/queryiter.cxx6
3 files changed, 27 insertions, 27 deletions
diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx
index f151bba90ab6..5370dd0fb211 100644
--- a/sc/inc/queryiter.hxx
+++ b/sc/inc/queryiter.hxx
@@ -148,7 +148,7 @@ protected:
or if the range is not properly sorted, with nRow in that case set to the first row or after
the last row. In that case use GetFirst().
*/
- bool BinarySearch();
+ bool BinarySearch( SCCOL col );
public:
ScQueryCellIteratorBase(ScDocument& rDocument, const ScInterpreterContext& rContext, SCTAB nTable,
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index b381d6195b04..23b32e9a5b66 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -2099,19 +2099,19 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS_EQUAL, 5 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS, 5 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(2), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_EQUAL, 5 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
}
@@ -2123,13 +2123,13 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER_EQUAL, 5 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(6), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER, 5 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(1), it.GetRow());
}
@@ -2141,19 +2141,19 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS_EQUAL, 6 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS, 6 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_EQUAL, 6 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
}
@@ -2165,13 +2165,13 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER_EQUAL, 6 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(1), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER, 6 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(1), it.GetRow());
}
@@ -2183,19 +2183,19 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS_EQUAL, 0 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS, 0 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_EQUAL, 0 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
@@ -2207,13 +2207,13 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER_EQUAL, 0 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER, 0 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
}
@@ -2225,19 +2225,19 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS_EQUAL, 10 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_LESS, 10 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_EQUAL, 10 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(it.BinarySearch());
+ CPPUNIT_ASSERT(it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
}
@@ -2249,13 +2249,13 @@ void TestSort::testQueryBinarySearch()
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER_EQUAL, 10 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
{
ScQueryParam param = makeSearchParam( range, descendingCol, SC_GREATER, 10 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
@@ -2263,7 +2263,7 @@ void TestSort::testQueryBinarySearch()
// Search as ascending but use descending range, will return no match.
ScQueryParam param = makeSearchParam( range, descendingCol, SC_LESS_EQUAL, 1 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
@@ -2271,7 +2271,7 @@ void TestSort::testQueryBinarySearch()
// Search as descending but use ascending range, will return no match.
ScQueryParam param = makeSearchParam( range, ascendingCol, SC_GREATER_EQUAL, 9 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( ascendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
@@ -2279,7 +2279,7 @@ void TestSort::testQueryBinarySearch()
// SC_EQUAL with descending is considered an error, will return no match.
ScQueryParam param = makeSearchParam( range, descendingCol, SC_EQUAL, 9 );
TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, param, false );
- CPPUNIT_ASSERT(!it.BinarySearch());
+ CPPUNIT_ASSERT(!it.BinarySearch( descendingCol ));
CPPUNIT_ASSERT_EQUAL(SCROW(0), it.GetRow());
}
diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx
index 6f8f6483140a..deea08fd9b1f 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -275,7 +275,7 @@ void decBlock(std::pair<Iter, size_t>& rPos)
}
template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
-bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch()
+bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col )
{
assert(maParam.GetEntry(0).bDoQuery && !maParam.GetEntry(1).bDoQuery
&& maParam.GetEntry(0).GetQueryItems().size() == 1 );
@@ -290,7 +290,7 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch()
// TODO: This will be extremely slow with mdds::multi_type_vector.
assert(nTab < rDoc.GetTableCount() && "index out of bounds, FIX IT");
- nCol = maParam.nCol1;
+ nCol = col;
nRow = maParam.nRow1;
if (nCol >= rDoc.maTabs[nTab]->GetAllocatedColumnsCount())
@@ -632,7 +632,7 @@ bool ScQueryCellIterator< accessType >::FindEqualOrSortedLastInRange( SCCOL& nFo
bool bFound = false;
if (bBinary)
{
- if (BinarySearch())
+ if (BinarySearch( maParam.nCol1 ))
{
// BinarySearch() already positions correctly and only needs real
// query comparisons afterwards, skip the verification check below.