From ca8614fc44e66308b846d01b8c0ab6a63cc93eb9 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Sun, 15 May 2022 06:36:44 +0200 Subject: fix GETPIVOTDATA() field name lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Field names are case-insensitive, so the lookup was failing if the name wasn't typed in a way that matched exactly as case-sensitive. The A29 field in getpivotdata.fods test was passing only because the fields were typed in the same order as present in the pivot table, and std::sort() was accidentally stable. But reordering the fields in the formula makes it fail, and so does using libc++ with debug mode (which randomizes equal fields in std::sort()). Change-Id: I88d078da435685c3557f24dc5f4a0bfc4d563aa6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134336 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- .../unit/data/functions/spreadsheet/fods/getpivotdata.fods | 14 +++++++++++--- sc/source/core/data/dpobject.cxx | 6 ++++-- sc/source/core/data/dpsave.cxx | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods b/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods index 7ea70d7b3acf..b392f066bc2b 100644 --- a/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods +++ b/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods @@ -7906,9 +7906,17 @@ - - - + + 34 + + + 34 + + + TRUE + + diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index efa77beb3377..b74fc5d7dfe5 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1341,11 +1341,13 @@ public: { size_t nRank1 = mrDimOrder.size(); size_t nRank2 = mrDimOrder.size(); - ScDPSaveData::DimOrderType::const_iterator it1 = mrDimOrder.find(r1.FieldName); + ScDPSaveData::DimOrderType::const_iterator it1 = mrDimOrder.find( + ScGlobal::getCharClass().uppercase(r1.FieldName)); if (it1 != mrDimOrder.end()) nRank1 = it1->second; - ScDPSaveData::DimOrderType::const_iterator it2 = mrDimOrder.find(r2.FieldName); + ScDPSaveData::DimOrderType::const_iterator it2 = mrDimOrder.find( + ScGlobal::getCharClass().uppercase(r2.FieldName)); if (it2 != mrDimOrder.end()) nRank2 = it2->second; diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index d9bc8d722a8b..0f8bfbf11712 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -783,7 +784,7 @@ public: void operator() (const ScDPSaveDimension* pDim) { size_t nRank = mrNames.size(); - mrNames.emplace(pDim->GetName(), nRank); + mrNames.emplace(ScGlobal::getCharClass().uppercase(pDim->GetName()), nRank); } }; -- cgit