sc/source/core/data/queryiter.cxx | 1 + sc/source/core/tool/rangecache.cxx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
New commits: commit 905475435c85ebae9ec48e37de4768e1b92914d2 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue May 10 08:43:08 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed May 11 11:50:52 2022 +0200 limit rows to ones having data when computing ScSortedRangeCache Change-Id: I2de9ea4887b6101f10eb3b8da6f3596de0ea09eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134128 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx index 0cd1a19ec744..ffb37c0e272f 100644 --- a/sc/source/core/data/queryiter.cxx +++ b/sc/source/core/data/queryiter.cxx @@ -45,6 +45,7 @@ #include <rowheightcontext.hxx> #include <queryevaluator.hxx> #include <rangecache.hxx> +#include <refdata.hxx> #include <o3tl/safeint.hxx> #include <tools/fract.hxx> diff --git a/sc/source/core/tool/rangecache.cxx b/sc/source/core/tool/rangecache.cxx index e8e49db6a8fe..f188342871c3 100644 --- a/sc/source/core/tool/rangecache.cxx +++ b/sc/source/core/tool/rangecache.cxx @@ -68,6 +68,14 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, && param.GetEntry(0).GetQueryItems().size() == 1); const ScQueryEntry& entry = param.GetEntry(0); const ScQueryEntry::Item& item = entry.GetQueryItem(); + + SCROW startRow = maRange.aStart.Row(); + SCROW endRow = maRange.aEnd.Row(); + SCCOL startCol = maRange.aStart.Col(); + SCCOL endCol = maRange.aEnd.Col(); + if (!pDoc->ShrinkToDataArea(nTab, startCol, startRow, endCol, endRow)) + return; + if (mValues == ValueType::Values) { struct RowData @@ -76,7 +84,7 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, double value; }; std::vector<RowData> rowData; - for (SCROW nRow = maRange.aStart.Row(); nRow <= maRange.aEnd.Row(); ++nRow) + for (SCROW nRow = startRow; nRow <= endRow; ++nRow) { ScRefCellValue cell(pDoc->GetRefCellValue(ScAddress(nCol, nRow, nTab))); if (ScQueryEvaluator::isQueryByValue(entry, item, cell)) @@ -102,7 +110,7 @@ ScSortedRangeCache::ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, // Try to reuse as much ScQueryEvaluator code as possible, this should // basically do the same comparisons. ScQueryEvaluator evaluator(*pDoc, *pDoc->FetchTable(nTab), param, context); - for (SCROW nRow = maRange.aStart.Row(); nRow <= maRange.aEnd.Row(); ++nRow) + for (SCROW nRow = startRow; nRow <= endRow; ++nRow) { ScRefCellValue cell(pDoc->GetRefCellValue(ScAddress(nCol, nRow, nTab))); if (ScQueryEvaluator::isQueryByString(entry, item, cell))