[Libreoffice-commits] core.git: sc/source
Jean-Sebastien Bevilacqua
realitix at gmail.com
Tue Jun 6 10:23:32 UTC 2017
sc/source/ui/cctrl/checklistmenu.cxx | 37 +++++++++++++++++++++++++++--------
sc/source/ui/inc/checklistmenu.hxx | 1
2 files changed, 30 insertions(+), 8 deletions(-)
New commits:
commit 2a39dc74724d3648ff76aa900edfebe0dd19b296
Author: Jean-Sebastien Bevilacqua <realitix at gmail.com>
Date: Thu Jun 1 18:27:13 2017 +0200
tdf#108259 Fix nested checkbox handling in autofilter popup
The regression breaks autofilter with hierarchy (date for example).
Commit id which introduces the regression 511fb8e80d298d42f5c45e7410bf64f2a25b441e
Change-Id: If15f32db6b8c1a90d96fefe9740173c2cbfb919a
Reviewed-on: https://gerrit.libreoffice.org/38343
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 6625101788d6..d4ff05e72f6c 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1639,21 +1639,39 @@ void ScCheckListBox::Init()
SetNodeDefaultImages();
}
+void ScCheckListBox::GetRecursiveChecked(SvTreeListEntry* pEntry, std::unordered_set<OUString, OUStringHash>& vOut, SvTreeListEntry* pParent)
+{
+ if (GetCheckButtonState(pEntry) == SvButtonState::Checked)
+ {
+ // we have to hash both parent and child together
+ OUString aName = GetEntryText(pEntry);
+ if (pParent) aName += GetEntryText(pParent);
+ vOut.insert(aName);
+ }
+
+ if (pEntry->HasChildren())
+ {
+ const SvTreeListEntries& rChildren = pEntry->GetChildEntries();
+ for (auto& rChild : rChildren)
+ {
+ GetRecursiveChecked(rChild.get(), vOut, pEntry);
+ }
+ }
+
+}
+
std::unordered_set<OUString, OUStringHash> ScCheckListBox::GetAllChecked()
{
- std::unordered_set<OUString, OUStringHash> results(0);
+ std::unordered_set<OUString, OUStringHash> vResults(0);
sal_uInt32 nRootPos = 0;
SvTreeListEntry* pEntry = GetEntry(nRootPos);
while (pEntry)
{
- if (GetCheckButtonState(pEntry) == SvButtonState::Checked)
- {
- results.insert(GetEntryText(pEntry));
- }
+ GetRecursiveChecked(pEntry, vResults, nullptr);
pEntry = GetEntry(++nRootPos);
}
- return results;
+ return vResults;
}
bool ScCheckListBox::IsChecked( const OUString& sName, SvTreeListEntry* pParent )
@@ -1924,7 +1942,7 @@ bool ScCheckListMenuWindow::isAllSelected() const
void ScCheckListMenuWindow::getResult(ResultType& rResult)
{
ResultType aResult;
- std::unordered_set<OUString, OUStringHash> checkeds = maChecks->GetAllChecked();
+ std::unordered_set<OUString, OUStringHash> vCheckeds = maChecks->GetAllChecked();
size_t n = maMembers.size();
for (size_t i = 0; i < n; ++i)
{
@@ -1933,7 +1951,10 @@ void ScCheckListMenuWindow::getResult(ResultType& rResult)
OUString aLabel = maMembers[i].maName;
if (aLabel.isEmpty())
aLabel = ScGlobal::GetRscString(STR_EMPTYDATA);
- bool bState = checkeds.find(aLabel) != checkeds.end();
+
+ bool bState = vCheckeds.find(maMembers[i].mpParent ?
+ aLabel.copy(0).concat(maChecks->GetEntryText(maMembers[i].mpParent)) :
+ aLabel) != vCheckeds.end();
ResultEntry aResultEntry;
aResultEntry.bValid = bState;
if ( maMembers[i].mbDate )
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 7bae3853e82e..6ac7c4879fc2 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -240,6 +240,7 @@ class ScCheckListBox : public SvTreeListBox
void CheckEntry( const OUString& sName, SvTreeListEntry* pParent, bool bCheck );
void CheckEntry( SvTreeListEntry* pEntry, bool bCheck );
SvTreeListEntry* ShowCheckEntry( const OUString& sName, ScCheckListMember& rMember, bool bShow = true, bool bCheck = true );
+ void GetRecursiveChecked(SvTreeListEntry* pEntry, std::unordered_set<OUString, OUStringHash>& vOut, SvTreeListEntry* pParent);
std::unordered_set<OUString, OUStringHash> GetAllChecked();
bool IsChecked( const OUString& sName, SvTreeListEntry* pParent );
SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& sNode );
More information about the Libreoffice-commits
mailing list