summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-05-21 15:05:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-05-21 16:01:29 +0200
commitf71557e958a8a626dfc1eef646b84b3c8b72569a (patch)
tree673599f09add52c8390283b7f248b6ef4933c68a /sc
parent0677d46bcc56c1f6c27b9331662990b38fd452d6 (diff)
tdf#76481 speed up searching in autofilter pulldown
turning setUpdateMode on/off fixes the common case, but we need to special case the "return to show all items" situation On my machine this takes the searching time from "more than 30s" to "just under 1s" Change-Id: I02d11c428e82dba1e840e981507337a1012dd09f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94633 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx60
1 files changed, 29 insertions, 31 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index f6cc3fef223d..2a3d272f2397 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1223,20 +1223,27 @@ IMPL_LINK_NOARG(ScCheckListMenuWindow, EdModifyHdl, Edit&, void)
bool bSearchTextEmpty = aSearchText.isEmpty();
size_t n = maMembers.size();
size_t nSelCount = 0;
- OUString aLabelDisp;
bool bSomeDateDeletes = false;
- for (size_t i = 0; i < n; ++i)
+ maChecks->SetUpdateMode(false);
+
+ if (bSearchTextEmpty)
+ {
+ // when there are a lot of rows, it is cheaper to simply clear the tree and re-initialise
+ maChecks->Clear();
+ initMembers();
+ }
+ else
{
- bool bIsDate = maMembers[i].mbDate;
- bool bPartialMatch = false;
+ for (size_t i = 0; i < n; ++i)
+ {
+ bool bIsDate = maMembers[i].mbDate;
+ bool bPartialMatch = false;
- aLabelDisp = maMembers[i].maName;
- if ( aLabelDisp.isEmpty() )
- aLabelDisp = ScResId( STR_EMPTYDATA );
+ OUString aLabelDisp = maMembers[i].maName;
+ if ( aLabelDisp.isEmpty() )
+ aLabelDisp = ScResId( STR_EMPTYDATA );
- 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
@@ -1244,30 +1251,19 @@ IMPL_LINK_NOARG(ScCheckListMenuWindow, EdModifyHdl, Edit&, void)
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 )
+ if ( bPartialMatch )
+ {
+ SvTreeListEntry* pLeaf = maChecks->ShowCheckEntry( aLabelDisp, maMembers[i] );
+ updateMemberParents( pLeaf, i );
++nSelCount;
- continue;
- }
-
- if ( bPartialMatch )
- {
- SvTreeListEntry* pLeaf = maChecks->ShowCheckEntry( aLabelDisp, maMembers[i] );
- updateMemberParents( pLeaf, i );
- ++nSelCount;
- }
- else
- {
- maChecks->ShowCheckEntry( aLabelDisp, maMembers[i], false, false );
- if( bIsDate )
- bSomeDateDeletes = true;
+ }
+ else
+ {
+ maChecks->ShowCheckEntry( aLabelDisp, maMembers[i], false, false );
+ if( bIsDate )
+ bSomeDateDeletes = true;
+ }
}
}
@@ -1281,6 +1277,8 @@ IMPL_LINK_NOARG(ScCheckListMenuWindow, EdModifyHdl, Edit&, void)
}
}
+ maChecks->SetUpdateMode(true);
+
if ( nSelCount == n )
maChkToggleAll->SetState( TRISTATE_TRUE );
else if ( nSelCount == 0 )