summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-01-03 23:19:24 +0100
committerEike Rathke <erack@redhat.com>2014-01-03 23:29:34 +0100
commita7d6e1f3eb60e4b73092dfe3f21501b4d150f041 (patch)
tree1a2887801ee2b45600a9586885578c184930d77a
parent7dce44a5218ecd683eb677f875a54d462331b4e3 (diff)
resolved fdo#72949 evaluate criteria on the query range
... and not on the result vector if that isn't included. Actually implements a TODO introduced with c008dc483f8c6840803983e7e351cec6fdd32070 Change-Id: Ic6c7ae70651aca21f22f10f76f94eb8690536bef
-rw-r--r--sc/inc/dociter.hxx2
-rw-r--r--sc/source/core/data/dociter.cxx22
2 files changed, 16 insertions, 8 deletions
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 3a83f0a38660..846bb1111e4e 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -111,7 +111,7 @@ public:
private:
static const sc::CellStoreType* GetColumnCellStore(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
static const ScAttrArray* GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
- static bool IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, ScRefCellValue& rCell);
+ static bool IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, ScRefCellValue* pCell);
class DataAccess
{
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index dab4a10cf94a..0fd07c716608 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -330,11 +330,11 @@ const ScAttrArray* ScDBQueryDataIterator::GetAttrArrayByCol(ScDocument& rDoc, SC
}
bool ScDBQueryDataIterator::IsQueryValid(
- ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, ScRefCellValue& rCell)
+ ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, ScRefCellValue* pCell)
{
if (nTab >= rDoc.GetTableCount())
OSL_FAIL("try to access index out of bounds, FIX IT");
- return rDoc.maTabs[nTab]->ValidQuery(nRow, rParam, &rCell);
+ return rDoc.maTabs[nTab]->ValidQuery(nRow, rParam, pCell);
}
// ----------------------------------------------------------------------------
@@ -376,10 +376,11 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
// Start with the current row position, and find the first row position
// that satisfies the query.
- // TODO: The following line nFirstQueryField is supposed to be used some
- // way. Find out how it's supposed to be used and fix this bug.
+ // If the query starts in the same column as the result vector we can
+ // prefetch the cell which saves us one fetch in the success case.
+ SCCOLROW nFirstQueryField = mpParam->GetEntry(0).nField;
+ ScRefCellValue aCell;
- // SCCOLROW nFirstQueryField = mpParam->GetEntry(0).nField;
while (true)
{
if (maCurPos.first == mpCells->end() || nRow > mpParam->nRow2)
@@ -396,10 +397,17 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
continue;
}
- ScRefCellValue aCell = sc::toRefCell(maCurPos.first, maCurPos.second);
+ ScRefCellValue* pCell = NULL;
+ if (nCol == static_cast<SCCOL>(nFirstQueryField))
+ {
+ aCell = sc::toRefCell(maCurPos.first, maCurPos.second);
+ pCell = &aCell;
+ }
- if (ScDBQueryDataIterator::IsQueryValid(*mpDoc, *mpParam, nTab, nRow, aCell))
+ if (ScDBQueryDataIterator::IsQueryValid(*mpDoc, *mpParam, nTab, nRow, pCell))
{
+ if (!pCell)
+ aCell = sc::toRefCell(maCurPos.first, maCurPos.second);
switch (aCell.meType)
{
case CELLTYPE_VALUE: