diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-08 11:37:00 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-08 16:59:26 +0200 |
commit | ec24a2a139f9bb8104b324a1009d934a4dbe9fd2 (patch) | |
tree | f30f69037eb1f6e56a7d6d904a0ba5b47246e3af /sc | |
parent | 746590257b4404682cf5a9fc85b1b9e34f1f1462 (diff) |
tdf#133785 autofilter with dates crashes when search entry is used and cleared
restore original logic, and just keep the clear-all optimization for the
non-hierarchical case
Change-Id: Iafcd934c7e6e48e7e11f7fca9e51478e7e678b44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95817
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/inc/checklistmenu.hxx | 1 |
2 files changed, 26 insertions, 10 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 02ed5ed049cb..27976641e37d 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -888,7 +888,8 @@ ScCheckListMenuWindow::ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* p maBtnCancel(VclPtr<CancelButton>::Create(this)), maWndSize(), mePrevToggleAllState(TRISTATE_INDET), - maTabStops(this) + maTabStops(this), + mbHasDates(false) { maChkToggleAll->EnableTriState(true); @@ -1227,7 +1228,7 @@ IMPL_LINK_NOARG(ScCheckListMenuWindow, EdModifyHdl, Edit&, void) maChecks->SetUpdateMode(false); - if (bSearchTextEmpty) + if (bSearchTextEmpty && !mbHasDates) { // when there are a lot of rows, it is cheaper to simply clear the tree and re-initialise maChecks->Clear(); @@ -1244,14 +1245,28 @@ IMPL_LINK_NOARG(ScCheckListMenuWindow, EdModifyHdl, Edit&, void) if ( aLabelDisp.isEmpty() ) aLabelDisp = ScResId( STR_EMPTYDATA ); - if ( !bIsDate ) - bPartialMatch = ( ScGlobal::getCharClassPtr()->lowercase( aLabelDisp ).indexOf( aSearchText ) != -1 ); - else if ( maMembers[i].meDatePartType == ScCheckListMember::DAY ) // Match with both numerical and text version of month - bPartialMatch = (ScGlobal::getCharClassPtr()->lowercase( OUString( - maMembers[i].maRealName + maMembers[i].maDateParts[1] )).indexOf( aSearchText ) != -1); - else + if ( !bSearchTextEmpty ) + { + if ( !bIsDate ) + bPartialMatch = ( ScGlobal::getCharClassPtr()->lowercase( aLabelDisp ).indexOf( aSearchText ) != -1 ); + else if ( maMembers[i].meDatePartType == ScCheckListMember::DAY ) // Match with both numerical and text version of month + bPartialMatch = (ScGlobal::getCharClassPtr()->lowercase( OUString( + maMembers[i].maRealName + maMembers[i].maDateParts[1] )).indexOf( aSearchText ) != -1); + else + continue; + } + else if ( bIsDate && maMembers[i].meDatePartType != ScCheckListMember::DAY ) continue; + if ( bSearchTextEmpty ) + { + SvTreeListEntry* pLeaf = maChecks->ShowCheckEntry( aLabelDisp, maMembers[i], true, maMembers[i].mbVisible ); + updateMemberParents( pLeaf, i ); + if ( maMembers[i].mbVisible ) + ++nSelCount; + continue; + } + if ( bPartialMatch ) { SvTreeListEntry* pLeaf = maChecks->ShowCheckEntry( aLabelDisp, maMembers[i] ); @@ -1881,9 +1896,10 @@ void ScSearchEdit::MouseButtonDown(const MouseEvent& rMEvt) void ScCheckListMenuWindow::setHasDates(bool bHasDates) { + mbHasDates = bHasDates; // Enables type-ahead search in the check list box. maChecks->SetQuickSearch(true); - if (bHasDates) + if (mbHasDates) maChecks->SetStyle(WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT); else maChecks->SetStyle(WB_HASBUTTONS); @@ -1894,7 +1910,6 @@ size_t ScCheckListMenuWindow::initMembers() size_t n = maMembers.size(); size_t nVisMemCount = 0; - maChecks->SetUpdateMode(false); maChecks->GetModel()->EnableInvalidate(false); diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index d0ce25136f8a..5e988e31e3d7 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -439,6 +439,7 @@ private: Size maMenuSize; /// size of all menu items combined. TriState mePrevToggleAllState; ScTabStops maTabStops; + bool mbHasDates; }; #endif |