summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-07 00:48:10 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-01-07 00:57:03 -0500
commitfd58eb3e92fc82d45130e06f89f9fcee29d08f1e (patch)
tree8a2fd43d1ea9a1bbd95b7a40362a4db6ae7facf4 /sc
parente5dcc06cf898109a1dd8218cf5eeecb83fb01492 (diff)
fdo#72645: Case-insensitive string comparison in GETPIVOTDATA.
(cherry picked from commit 17b00767948f7add229ec589c06cd8c898032ffa) Conflicts: sc/qa/unit/subsequent_filters-test.cxx Change-Id: Ibdb2b7ab2bae03875a3462816e860f58d9076457
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xls/pivot-getpivotdata.xlsbin0 -> 10752 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx19
-rw-r--r--sc/source/core/data/dpobject.cxx12
-rw-r--r--sc/source/core/data/dpresfilter.cxx29
4 files changed, 47 insertions, 13 deletions
diff --git a/sc/qa/unit/data/xls/pivot-getpivotdata.xls b/sc/qa/unit/data/xls/pivot-getpivotdata.xls
new file mode 100644
index 000000000000..f9ad24a9de84
--- /dev/null
+++ b/sc/qa/unit/data/xls/pivot-getpivotdata.xls
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 581734beac4e..425dc3b93173 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -138,6 +138,8 @@ public:
void testCellAnchoredShapesODS();
void testPivotTableBasicODS();
+ void testGetPivotDataXLS();
+
void testFormulaDependency();
void testRowHeightODS();
@@ -198,6 +200,7 @@ public:
CPPUNIT_TEST(testCellAnchoredShapesODS);
CPPUNIT_TEST(testPivotTableBasicODS);
+ CPPUNIT_TEST(testGetPivotDataXLS);
CPPUNIT_TEST(testRowHeightODS);
CPPUNIT_TEST(testFormulaDependency);
CPPUNIT_TEST(testRichTextContentODS);
@@ -1646,6 +1649,22 @@ void ScFiltersTest::testPivotTableBasicODS()
xDocSh->DoClose();
}
+void ScFiltersTest::testGetPivotDataXLS()
+{
+ ScDocShellRef xDocSh = loadDoc("pivot-getpivotdata.", XLS);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ pDoc->CalcAll();
+
+ // Check GETPIVOTDATA results in E3:E20. Expected results are given in
+ // F3:F20.
+
+ for (SCROW nRow = 2; nRow <= 19; ++nRow)
+ CPPUNIT_ASSERT_EQUAL(pDoc->GetValue(ScAddress(4,nRow,1)), pDoc->GetValue(ScAddress(5,nRow,1)));
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testRowHeightODS()
{
ScDocShellRef xDocSh = loadDoc("row-height-import.", ODS);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index e244e315cbca..bde315618e18 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!