summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-12 09:19:23 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-13 17:04:05 +0200
commite1f62d3c387b7080d50e06554fa65512bcbe1d83 (patch)
tree167dd44fbcf012d7c6abe8a571855111504ea4bb
parent732fdafd9f7ccf383038258792c8cb15f30f8e74 (diff)
make ScSortedRangeCache-based queries work with mbMatchEmpty
Change-Id: Ifc8195222568184dc4f337b23f00e315e22febe2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134218 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/source/core/data/queryiter.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx
index 656fedc3c717..ac8c791710e2 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -266,6 +266,14 @@ void ScQueryCellIteratorBase< accessType, queryType >::InitPos()
// the position to the first row in the range.
op = saveOp; // back to SC_EQUAL
}
+ else if( maParam.GetEntry(0).GetQueryItem().mbMatchEmpty
+ && rDoc.IsEmptyData(nCol, maParam.nRow1, nCol, maParam.nRow2, nTab))
+ {
+ // BinarySearch() returns false in case it's all empty data,
+ // handle that specially.
+ beforeRow = -1;
+ lastRow = maParam.nRow2;
+ }
}
else
{ // The range is from the start up to and including the last matching.
@@ -1221,8 +1229,6 @@ static bool CanBeUsedForSorterCache(const ScDocument& rDoc, const ScQueryParam&
return false;
if(rParam.bHasHeader)
return false;
- if(rParam.GetEntry(0).GetQueryItem().mbMatchEmpty)
- return false;
if(rParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString
&& !ScQueryEvaluator::isMatchWholeCell(rDoc, rParam.GetEntry(0)))
return false; // substring matching cannot be sorted
@@ -1395,6 +1401,13 @@ sal_uInt64 ScCountIfCellIterator< ScQueryCellIteratorAccess::SortedCache >::GetC
size_t lastMatching = sortedCache->indexForRow(nRow) + 1;
count += lastMatching;
}
+ else if( maParam.GetEntry(0).GetQueryItem().mbMatchEmpty
+ && rDoc.IsEmptyData(col, maParam.nRow1, col, maParam.nRow2, nTab))
+ {
+ // BinarySearch() returns false in case it's all empty data,
+ // handle that specially.
+ count += maParam.nRow2 - maParam.nRow1 + 1;
+ }
}
}
else
@@ -1405,6 +1418,12 @@ sal_uInt64 ScCountIfCellIterator< ScQueryCellIteratorAccess::SortedCache >::GetC
count += sortedCache->indexForRow(nRow) + 1;
}
}
+ if( maParam.GetEntry(0).GetQueryItem().mbMatchEmpty
+ && maParam.nCol2 >= rDoc.GetAllocatedColumnsCount( nTab ))
+ {
+ count += (maParam.nCol2 - rDoc.GetAllocatedColumnsCount( nTab ))
+ * ( maParam.nRow2 - maParam.nRow1 + 1 );
+ }
return count;
}