summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-07 00:48:10 -0500
committerEike Rathke <erack@redhat.com>2014-01-08 12:56:47 +0000
commit7c4a58833df3931c168c57be3239e904e3a3baba (patch)
tree9a8e0fba04b52ecde25d1db72e4d49d56e1f7751 /sc
parent83eb0b64980b405bc94ed19f3bcb60860f86e7d4 (diff)
fdo#72645: Case-insensitive string comparison in GETPIVOTDATA.
Change-Id: Ibdb2b7ab2bae03875a3462816e860f58d9076457 Reviewed-on: https://gerrit.libreoffice.org/7285 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dpobject.cxx12
-rw-r--r--sc/source/core/data/dpresfilter.cxx29
2 files changed, 28 insertions, 13 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 3d9f5af641fb..f9344aae4561 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1321,24 +1321,24 @@ namespace {
class FindByName : std::unary_function<const ScDPSaveDimension*, bool>
{
- OUString maName;
+ OUString maName; // must be all uppercase.
public:
FindByName(const OUString& rName) : maName(rName) {}
bool operator() (const ScDPSaveDimension* pDim) const
{
// Layout name takes precedence.
const OUString* pLayoutName = pDim->GetLayoutName();
- if (pLayoutName && *pLayoutName == maName)
+ if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName)
return true;
sheet::GeneralFunction eGenFunc = static_cast<sheet::GeneralFunction>(pDim->GetFunction());
ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(eGenFunc);
OUString aSrcName = ScDPUtil::getSourceDimensionName(pDim->GetName());
OUString aFuncName = ScDPUtil::getDisplayedMeasureName(aSrcName, eFunc);
- if (maName == aFuncName)
+ if (maName == ScGlobal::pCharClass->uppercase(aFuncName))
return true;
- return maName == aSrcName;
+ return maName == ScGlobal::pCharClass->uppercase(aSrcName);
}
};
@@ -1382,7 +1382,9 @@ double ScDPObject::GetPivotData(const OUString& rDataFieldName, std::vector<shee
return fRet;
std::vector<const ScDPSaveDimension*>::iterator it = std::find_if(
- aDataDims.begin(), aDataDims.end(), FindByName(rDataFieldName));
+ aDataDims.begin(), aDataDims.end(),
+ FindByName(ScGlobal::pCharClass->uppercase(rDataFieldName)));
+
if (it == aDataDims.end())
return fRet;
diff --git a/sc/source/core/data/dpresfilter.cxx b/sc/source/core/data/dpresfilter.cxx
index 41b2d7eb396d..d4895b825130 100644
--- a/sc/source/core/data/dpresfilter.cxx
+++ b/sc/source/core/data/dpresfilter.cxx
@@ -10,6 +10,7 @@
#include "dpresfilter.hxx"
#include "global.hxx"
+#include <unotools/charclass.hxx>
#include <rtl/math.hxx>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -113,12 +114,13 @@ void ScDPResultTree::add(
// See if this dimension exists.
DimensionsType& rDims = pMemNode->maChildDimensions;
- DimensionsType::iterator itDim = rDims.find(filter.maDimName);
+ OUString aUpperName = ScGlobal::pCharClass->uppercase(filter.maDimName);
+ DimensionsType::iterator itDim = rDims.find(aUpperName);
if (itDim == rDims.end())
{
// New dimenison. Insert it.
std::pair<DimensionsType::iterator, bool> r =
- rDims.insert(DimensionsType::value_type(filter.maDimName, new DimensionNode(pMemNode)));
+ rDims.insert(DimensionsType::value_type(aUpperName, new DimensionNode(pMemNode)));
if (!r.second)
// Insertion failed!
@@ -132,13 +134,14 @@ void ScDPResultTree::add(
// Now, see if this dimension member exists.
DimensionNode* pDim = itDim->second;
MembersType& rMembers = pDim->maChildMembers;
- MembersType::iterator itMem = rMembers.find(filter.maValue);
+ aUpperName = ScGlobal::pCharClass->uppercase(filter.maValue);
+ MembersType::iterator itMem = rMembers.find(aUpperName);
if (itMem == rMembers.end())
{
// New member. Insert it.
std::pair<MembersType::iterator, bool> r =
rMembers.insert(
- MembersType::value_type(filter.maValue, new MemberNode(pDim)));
+ MembersType::value_type(aUpperName, new MemberNode(pDim)));
if (!r.second)
// Insertion failed!
@@ -153,7 +156,10 @@ void ScDPResultTree::add(
if (pDimName && pMemName)
{
- NamePairType aNames(*pDimName, *pMemName);
+ NamePairType aNames(
+ ScGlobal::pCharClass->uppercase(*pDimName),
+ ScGlobal::pCharClass->uppercase(*pMemName));
+
LeafValuesType::iterator it = maLeafValues.find(aNames);
if (it == maLeafValues.end())
{
@@ -197,13 +203,17 @@ const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
const MemberNode* pMember = mpRoot;
for (; p != pEnd; ++p)
{
- DimensionsType::const_iterator itDim = pMember->maChildDimensions.find(p->FieldName);
+ DimensionsType::const_iterator itDim = pMember->maChildDimensions.find(
+ ScGlobal::pCharClass->uppercase(p->FieldName));
+
if (itDim == pMember->maChildDimensions.end())
// Specified dimension not found.
return NULL;
const DimensionNode* pDim = itDim->second;
- MembersType::const_iterator itMem = pDim->maChildMembers.find(p->MatchValue);
+ MembersType::const_iterator itMem = pDim->maChildMembers.find(
+ ScGlobal::pCharClass->uppercase(p->MatchValue));
+
if (itMem == pDim->maChildMembers.end())
// Specified member not found.
return NULL;
@@ -216,7 +226,10 @@ const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
double ScDPResultTree::getLeafResult(const com::sun::star::sheet::DataPilotFieldFilter& rFilter) const
{
- NamePairType aPair(rFilter.FieldName, rFilter.MatchValue);
+ NamePairType aPair(
+ ScGlobal::pCharClass->uppercase(rFilter.FieldName),
+ ScGlobal::pCharClass->uppercase(rFilter.MatchValue));
+
LeafValuesType::const_iterator it = maLeafValues.find(aPair);
if (it != maLeafValues.end())
// Found!