[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/inc sc/source

Eike Rathke erack at redhat.com
Fri Jan 3 14:48:23 PST 2014


 sc/inc/dociter.hxx              |    2 +-
 sc/source/core/data/dociter.cxx |   22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit d16363aa6c8d7a01f9579f7f062a2d005fa1a854
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jan 3 23:19:24 2014 +0100

    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
    (cherry picked from commit a7d6e1f3eb60e4b73092dfe3f21501b4d150f041)

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 3a83f0a..846bb11 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 dab4a10..0fd07c7 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:


More information about the Libreoffice-commits mailing list