Kaydet (Commit) 200b4539 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Some attempt to store string ID's into query items.

Change-Id: I8db7cd327728be0974405eabb0fd58156ba231d6
üst f54cdb59
...@@ -42,8 +42,9 @@ struct SC_DLLPUBLIC ScQueryEntry ...@@ -42,8 +42,9 @@ struct SC_DLLPUBLIC ScQueryEntry
QueryType meType; QueryType meType;
double mfVal; double mfVal;
OUString maString; 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; bool operator== (const Item& r) const;
}; };
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include "svl/stringpool.hxx"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -6448,6 +6449,43 @@ void ScInterpreter::ScHLookup() ...@@ -6448,6 +6449,43 @@ void ScInterpreter::ScHLookup()
CalculateLookup(true); 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) void ScInterpreter::CalculateLookup(bool bHLookup)
{ {
sal_uInt8 nParamCount = GetByte(); sal_uInt8 nParamCount = GetByte();
...@@ -6683,10 +6721,19 @@ void ScInterpreter::CalculateLookup(bool bHLookup) ...@@ -6683,10 +6721,19 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
nRow = nZIndex; nRow = nZIndex;
} }
else else
{
if (isFilterByEqualString(aParam))
{
nRow = nRow1;
bFound = true;
}
else
{ {
ScAddress aResultPos( nCol1, nRow1, nTab1); ScAddress aResultPos( nCol1, nRow1, nTab1);
bFound = LookupQueryWithCache( aResultPos, aParam); bFound = LookupQueryWithCache( aResultPos, aParam);
nRow = aResultPos.Row(); nRow = aResultPos.Row();
}
nCol = nSpIndex; nCol = nSpIndex;
} }
...@@ -6716,6 +6763,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) ...@@ -6716,6 +6763,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
const OUString& sStr = GetString(); const OUString& sStr = GetString();
rItem.meType = ScQueryEntry::ByString; rItem.meType = ScQueryEntry::ByString;
rItem.maString = sStr; rItem.maString = sStr;
rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
} }
break; break;
case svDoubleRef : case svDoubleRef :
...@@ -6740,6 +6788,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) ...@@ -6740,6 +6788,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
GetCellString(aStr, aCell); GetCellString(aStr, aCell);
rItem.meType = ScQueryEntry::ByString; rItem.meType = ScQueryEntry::ByString;
rItem.maString = aStr; rItem.maString = aStr;
rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
} }
} }
break; break;
...@@ -6748,6 +6797,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) ...@@ -6748,6 +6797,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
OUString aStr; OUString aStr;
const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr); const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr);
rItem.maString = aStr; rItem.maString = aStr;
rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
rItem.meType = ScMatrix::IsNonValueType(nType) ? rItem.meType = ScMatrix::IsNonValueType(nType) ?
ScQueryEntry::ByString : ScQueryEntry::ByValue; ScQueryEntry::ByString : ScQueryEntry::ByValue;
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
bool ScQueryEntry::Item::operator== (const Item& r) const 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() : ScQueryEntry::ScQueryEntry() :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment