sc/source/ui/cctrl/checklistmenu.cxx | 10 ++++++---- sc/source/ui/inc/checklistmenu.hxx | 13 ++++++++++++- sc/source/ui/view/gridwin.cxx | 24 ++++++++++-------------- sc/source/ui/view/gridwin2.cxx | 14 +++++++------- 4 files changed, 35 insertions(+), 26 deletions(-)
New commits: commit 67afc3a01426aba970619afdba4ace1a8e25923a Author: Markus Mohrhard <markus.mohrh...@googlemail.com> AuthorDate: Sun Mar 26 22:50:18 2017 +0200 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Mon Aug 6 11:19:21 2018 +0200 handle date autofilter entries correctly, tdf#106214 Change-Id: I8fd2896c8998e79794a0ccaae1c2442caf8b89ac Reviewed-on: https://gerrit.libreoffice.org/35730 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Reviewed-on: https://gerrit.libreoffice.org/58352 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index a74e5817e34c..8934e8d09c23 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1911,12 +1911,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 ea9e7edfc4b7..9a8cd973e458 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -293,7 +293,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 a33b36464848..b9a4afc12874 100755 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -657,13 +657,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); + } } }; @@ -863,17 +866,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)); if (mpAutoFilterPopup->isAllSelected()) { diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index d99972898a9b..ad6a16f4d092 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -555,29 +555,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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits