diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-03-26 22:50:18 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-03-27 00:51:54 +0000 |
commit | b3d498755238cb0d9a7a3e33b6070c1e4c0e3482 (patch) | |
tree | 65ae82d1d923a1ae1aa23e10a6e7fca633897414 | |
parent | d6861b8f38db9dc465f344474943b9477dd22a0c (diff) |
handle date autofilter entries correctly, tdf#106214
Change-Id: I8fd2896c8998e79794a0ccaae1c2442caf8b89ac
Reviewed-on: https://gerrit.libreoffice.org/35730
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/inc/checklistmenu.hxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 24 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin2.cxx | 14 |
4 files changed, 35 insertions, 26 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index ce637818191c..dba72366b4aa 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1916,12 +1916,14 @@ void ScCheckListMenuWindow::getResult(ResultType& rResult) if (aLabel.isEmpty()) aLabel = ScGlobal::GetRscString(STR_EMPTYDATA); bool bState = maChecks->IsChecked( aLabel, maMembers[i].mpParent ); - OUString sName; + ResultEntry aResultEntry; + aResultEntry.bValid = bState; if ( maMembers[i].mbDate ) - sName = maMembers[i].maRealName; + aResultEntry.aName = maMembers[i].maRealName; else - sName = maMembers[i].maName; - aResult.insert(ResultType::value_type(sName, bState)); + aResultEntry.aName = maMembers[i].maName; + aResultEntry.bDate = maMembers[i].mbDate; + aResult.insert(aResultEntry); } } rResult.swap(aResult); diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index f2e208ad4f6b..1864415b6aaa 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -292,7 +292,18 @@ struct ScCheckListMember class ScCheckListMenuWindow : public ScMenuFloatingWindow { public: - typedef std::unordered_map<OUString, bool, OUStringHash> ResultType; + struct ResultEntry + { + OUString aName; + bool bValid; + bool bDate; + + bool operator<(const ResultEntry& rhs) const + { + return aName < rhs.aName; + } + }; + typedef std::set<ResultEntry> ResultType; /** * Extended data that the client code may need to store. Create a diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index bfbae1242a84..c590bc336b0d 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -590,13 +590,16 @@ class AddItemToEntry : public std::unary_function<OUString, void> public: AddItemToEntry(ScQueryEntry::QueryItemsType& rItems, svl::SharedStringPool& rPool) : mrItems(rItems), mrPool(rPool) {} - void operator() (const OUString& rSelected) + void operator() (const ScCheckListMenuWindow::ResultEntry& rEntry) { - ScQueryEntry::Item aNew; - aNew.maString = mrPool.intern(rSelected); - aNew.meType = ScQueryEntry::ByString; - aNew.mfVal = 0.0; - mrItems.push_back(aNew); + if (rEntry.bValid) + { + ScQueryEntry::Item aNew; + aNew.maString = mrPool.intern(rEntry.aName); + aNew.meType = rEntry.bDate ? ScQueryEntry::ByDate : ScQueryEntry::ByString; + aNew.mfVal = 0.0; + mrItems.push_back(aNew); + } } }; @@ -800,17 +803,10 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) ScCheckListMenuWindow::ResultType aResult; mpAutoFilterPopup->getResult(aResult); - std::vector<OUString> aSelected; - ScCheckListMenuWindow::ResultType::const_iterator itr = aResult.begin(), itrEnd = aResult.end(); - for (; itr != itrEnd; ++itr) - { - if (itr->second) - aSelected.push_back(itr->first); - } ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems(); rItems.clear(); - std::for_each(aSelected.begin(), aSelected.end(), AddItemToEntry(rItems, rPool)); + std::for_each(aResult.begin(), aResult.end(), AddItemToEntry(rItems, rPool)); } break; case Top10: diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index 1cdef6e1b205..59d70bdb2164 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -568,29 +568,29 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu() ScCheckListMenuWindow::ResultType aRawResult; mpDPFieldPopup->getResult(aRawResult); - ScCheckListMenuWindow::ResultType aResult; + std::unordered_map<OUString, bool, OUStringHash> aResult; ScCheckListMenuWindow::ResultType::const_iterator itr = aRawResult.begin(), itrEnd = aRawResult.end(); for (; itr != itrEnd; ++itr) { - MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->first); + MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->aName); if (itrNameMap == aMemNameMap.end()) { // This is an original member name. Use it as-is. - OUString aName = itr->first; + OUString aName = itr->aName; if (aName.equals(ScGlobal::GetRscString(STR_EMPTYDATA))) // Translate the special empty name into an empty string. aName.clear(); aResult.insert( - ScCheckListMenuWindow::ResultType::value_type( - aName, itr->second)); + std::unordered_map<OUString, bool, OUStringHash>::value_type( + aName, itr->bValid)); } else { // This is a layout name. Get the original member name and use it. aResult.insert( - ScCheckListMenuWindow::ResultType::value_type( - itrNameMap->second, itr->second)); + std::unordered_map<OUString, bool, OUStringHash>::value_type( + itrNameMap->second, itr->bValid)); } } pDim->UpdateMemberVisibility(aResult); |