Kaydet (Commit) 2a39dc74 authored tarafından Jean-Sebastien Bevilacqua's avatar Jean-Sebastien Bevilacqua Kaydeden (comit) Eike Rathke

tdf#108259 Fix nested checkbox handling in autofilter popup

The regression breaks autofilter with hierarchy (date for example).

Commit id which introduces the regression 511fb8e8

Change-Id: If15f32db6b8c1a90d96fefe9740173c2cbfb919a
Reviewed-on: https://gerrit.libreoffice.org/38343Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst a915f55c
...@@ -1639,21 +1639,39 @@ void ScCheckListBox::Init() ...@@ -1639,21 +1639,39 @@ void ScCheckListBox::Init()
SetNodeDefaultImages(); 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> ScCheckListBox::GetAllChecked()
{ {
std::unordered_set<OUString, OUStringHash> results(0); std::unordered_set<OUString, OUStringHash> vResults(0);
sal_uInt32 nRootPos = 0; sal_uInt32 nRootPos = 0;
SvTreeListEntry* pEntry = GetEntry(nRootPos); SvTreeListEntry* pEntry = GetEntry(nRootPos);
while (pEntry) while (pEntry)
{ {
if (GetCheckButtonState(pEntry) == SvButtonState::Checked) GetRecursiveChecked(pEntry, vResults, nullptr);
{
results.insert(GetEntryText(pEntry));
}
pEntry = GetEntry(++nRootPos); pEntry = GetEntry(++nRootPos);
} }
return results; return vResults;
} }
bool ScCheckListBox::IsChecked( const OUString& sName, SvTreeListEntry* pParent ) bool ScCheckListBox::IsChecked( const OUString& sName, SvTreeListEntry* pParent )
...@@ -1924,7 +1942,7 @@ bool ScCheckListMenuWindow::isAllSelected() const ...@@ -1924,7 +1942,7 @@ bool ScCheckListMenuWindow::isAllSelected() const
void ScCheckListMenuWindow::getResult(ResultType& rResult) void ScCheckListMenuWindow::getResult(ResultType& rResult)
{ {
ResultType aResult; ResultType aResult;
std::unordered_set<OUString, OUStringHash> checkeds = maChecks->GetAllChecked(); std::unordered_set<OUString, OUStringHash> vCheckeds = maChecks->GetAllChecked();
size_t n = maMembers.size(); size_t n = maMembers.size();
for (size_t i = 0; i < n; ++i) for (size_t i = 0; i < n; ++i)
{ {
...@@ -1933,7 +1951,10 @@ void ScCheckListMenuWindow::getResult(ResultType& rResult) ...@@ -1933,7 +1951,10 @@ void ScCheckListMenuWindow::getResult(ResultType& rResult)
OUString aLabel = maMembers[i].maName; OUString aLabel = maMembers[i].maName;
if (aLabel.isEmpty()) if (aLabel.isEmpty())
aLabel = ScGlobal::GetRscString(STR_EMPTYDATA); 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; ResultEntry aResultEntry;
aResultEntry.bValid = bState; aResultEntry.bValid = bState;
if ( maMembers[i].mbDate ) if ( maMembers[i].mbDate )
......
...@@ -240,6 +240,7 @@ class ScCheckListBox : public SvTreeListBox ...@@ -240,6 +240,7 @@ class ScCheckListBox : public SvTreeListBox
void CheckEntry( const OUString& sName, SvTreeListEntry* pParent, bool bCheck ); void CheckEntry( const OUString& sName, SvTreeListEntry* pParent, bool bCheck );
void CheckEntry( SvTreeListEntry* pEntry, bool bCheck ); void CheckEntry( SvTreeListEntry* pEntry, bool bCheck );
SvTreeListEntry* ShowCheckEntry( const OUString& sName, ScCheckListMember& rMember, bool bShow = true, bool bCheck = true ); 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(); std::unordered_set<OUString, OUStringHash> GetAllChecked();
bool IsChecked( const OUString& sName, SvTreeListEntry* pParent ); bool IsChecked( const OUString& sName, SvTreeListEntry* pParent );
SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& sNode ); SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& sNode );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment