sc/inc/queryiter.hxx              |    6 +++---
 sc/source/core/data/queryiter.cxx |    8 ++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 02c5ec92e3dfa8dee51e606ff8e929168948a8a7
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Mon Apr 25 13:59:07 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue May 10 16:22:43 2022 +0200

    assert pre-requisities of BinarySearch()
    
    Change-Id: I090a6538628eb5337a311ed8aec3580901e957ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134095
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx
index c2378bca6aa2..f5cba350bff2 100644
--- a/sc/inc/queryiter.hxx
+++ b/sc/inc/queryiter.hxx
@@ -87,9 +87,9 @@ protected:
 
     /* Only works if no regular expression is involved, only searches for rows 
in one column,
        and only the first query entry is considered with simple conditions 
SC_LESS_EQUAL
-       (sorted ascending) or SC_GREATER_EQUAL (sorted descending). Check these 
things before
-       invocation! Delivers a starting point, continue with e.g. GetThis() and 
GetNext()
-       afterwards. Introduced for FindEqualOrSortedLastInRange(). */
+       (sorted ascending) or SC_GREATER_EQUAL (sorted descending). Delivers a 
starting point,
+       continue with e.g. GetThis() and GetNext() afterwards. Introduced
+       for FindEqualOrSortedLastInRange(). */
     bool BinarySearch();
 
 public:
diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index 040dfdfc403d..cbdd83668920 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -505,6 +505,14 @@ public:
 template< ScQueryCellIteratorType iteratorType >
 bool ScQueryCellIteratorBase< iteratorType >::BinarySearch()
 {
+    assert(maParam.GetEntry(0).bDoQuery && !maParam.GetEntry(1).bDoQuery
+        && maParam.GetEntry(0).GetQueryItems().size() == 1 );
+    assert(maParam.eSearchType == utl::SearchParam::SearchType::Normal);
+    assert(maParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString
+        || maParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByValue);
+    assert(maParam.bByRow);
+    assert(maParam.GetEntry(0).eOp == SC_LESS_EQUAL || maParam.GetEntry(0).eOp 
== SC_GREATER_EQUAL);
+
     // TODO: This will be extremely slow with mdds::multi_type_vector.
 
     assert(nTab < rDoc.GetTableCount() && "index out of bounds, FIX IT");

Reply via email to