sc/source/ui/cctrl/checklistmenu.cxx | 35 +++++++++++++++++++++++++---------- sc/source/ui/inc/checklistmenu.hxx | 1 + 2 files changed, 26 insertions(+), 10 deletions(-)
New commits: commit ec24a2a139f9bb8104b324a1009d934a4dbe9fd2 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jun 8 11:37:00 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Jun 8 16:59:26 2020 +0200 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 <caol...@redhat.com> 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits