[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Oct 4 12:20:14 PDT 2013


 sc/inc/queryentry.hxx              |    3 +
 sc/source/core/tool/interpr1.cxx   |   56 +++++++++++++++++++++++++++++++++++--
 sc/source/core/tool/queryentry.cxx |    2 -
 3 files changed, 56 insertions(+), 5 deletions(-)

New commits:
commit db79eb60fb977b83190fb16880f240b21ceaf878
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Oct 4 15:21:36 2013 -0400

    Some attempt to store string ID's into query items.
    
    Change-Id: I8db7cd327728be0974405eabb0fd58156ba231d6

diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index a3baea6..636372e 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -42,8 +42,9 @@ struct SC_DLLPUBLIC ScQueryEntry
         QueryType     meType;
         double        mfVal;
         OUString maString;
+        sal_uIntPtr mnStrId;
 
-        Item() : meType(ByValue), mfVal(0.0) {}
+        Item() : meType(ByValue), mfVal(0.0), mnStrId(0) {}
 
         bool operator== (const Item& r) const;
     };
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index a997c92..b8e424a 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -60,6 +60,7 @@
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
+#include "svl/stringpool.hxx"
 
 #include <stdlib.h>
 #include <string.h>
@@ -6448,6 +6449,43 @@ void ScInterpreter::ScHLookup()
     CalculateLookup(true);
 }
 
+namespace {
+
+#if 1
+bool isFilterByEqualString( const ScQueryParam& )
+{
+    return false;
+}
+#else
+bool isFilterByEqualString( const ScQueryParam& rParam )
+{
+    if (rParam.bRegExp)
+        // filter by regular expression.
+        return false;
+
+    if (!rParam.GetEntryCount())
+        // No entries.
+        return false;
+
+    const ScQueryEntry& rEntry = rParam.GetEntry(0);
+    if (rEntry.eOp != SC_EQUAL)
+        return false;
+
+    const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
+    if (rItems.size() != 1)
+        // Multi-item query is not supported.
+        return false;
+
+    if (rItems[0].meType != ScQueryEntry::ByString)
+        // Not by string equality.
+        return false;
+
+    return true;
+}
+#endif
+
+}
+
 void ScInterpreter::CalculateLookup(bool bHLookup)
 {
     sal_uInt8 nParamCount = GetByte();
@@ -6684,9 +6722,18 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
         }
         else
         {
-            ScAddress aResultPos( nCol1, nRow1, nTab1);
-            bFound = LookupQueryWithCache( aResultPos, aParam);
-            nRow = aResultPos.Row();
+            if (isFilterByEqualString(aParam))
+            {
+                nRow = nRow1;
+                bFound = true;
+            }
+            else
+            {
+                ScAddress aResultPos( nCol1, nRow1, nTab1);
+                bFound = LookupQueryWithCache( aResultPos, aParam);
+                nRow = aResultPos.Row();
+            }
+
             nCol = nSpIndex;
         }
 
@@ -6716,6 +6763,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             const OUString& sStr = GetString();
             rItem.meType = ScQueryEntry::ByString;
             rItem.maString = sStr;
+            rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
         }
         break;
         case svDoubleRef :
@@ -6740,6 +6788,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
                 GetCellString(aStr, aCell);
                 rItem.meType = ScQueryEntry::ByString;
                 rItem.maString = aStr;
+                rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
             }
         }
         break;
@@ -6748,6 +6797,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             OUString aStr;
             const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr);
             rItem.maString = aStr;
+            rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
             rItem.meType = ScMatrix::IsNonValueType(nType) ?
                 ScQueryEntry::ByString : ScQueryEntry::ByValue;
         }
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index 1ac1a89..e061d0f 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -32,7 +32,7 @@
 
 bool ScQueryEntry::Item::operator== (const Item& r) const
 {
-    return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString);
+    return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString) && mnStrId == r.mnStrId;
 }
 
 ScQueryEntry::ScQueryEntry() :


More information about the Libreoffice-commits mailing list