[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Mar 30 22:16:48 UTC 2017
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 99744cb30435f2158d29967b77d08d0e4f79492c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 26 22:50:18 2017 +0200
handle date autofilter entries correctly, tdf#106214
Change-Id: I8fd2896c8998e79794a0ccaae1c2442caf8b89ac
Reviewed-on: https://gerrit.libreoffice.org/35730
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
(cherry picked from commit b3d498755238cb0d9a7a3e33b6070c1e4c0e3482)
Reviewed-on: https://gerrit.libreoffice.org/35733
Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 226f029c6633..e73c229ff975 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 1ee9e7bdc102..d80e20b76d21 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 aea4f5365f3b..317d1941c1f0 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -642,13 +642,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);
+ }
}
};
@@ -852,17 +855,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 c2e34db084ea..ae9398ecb416 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -554,29 +554,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);
More information about the Libreoffice-commits
mailing list