summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-04-25 20:21:43 +0100
committerTor Lillqvist <tml@iki.fi>2013-04-26 05:51:34 +0000
commit075a5863050f3031b4aa33adb289d3380e009425 (patch)
tree0dae513b39fb9f3b4e90364c717120d3eaafc7b7 /svtools
parent7bd7e75d6914573289656ea544f8928097614b14 (diff)
fix scrolling performance of listboxes with hundreds of entries
make it approximately infinitely faster a) add a method AdjustEntryHeightAndRecalc that just does AdjustEntryHeight and RecalcViewData and replace all the places that do the two of those together with that utility b) in our SetFont now only call AdjustEntryHeightAndRecalc if the new font is different to the old font, ignoring color which doesn't have a bearing on row size. c) where we originally called SetFont(GetFont()), which would have triggered AdjustEntryHeightAndRecalc, now call the new AdjustEntryHeightAndRecalc explicitly. The performance problem apparently a regression from ac7acb0ab1329913b0cec79790adcde0263960be where we seem to now end up drawing on ourself and calling SetFont on ourself rather than on a pImpl without an overridden SetFont. So when we redraw on scrolling we triggered a cascade of calculations and force text layout of every row. (cherry picked from commit 3b6e61c3968a4aaec0b594803219961f3fcc9232) Conflicts: include/svtools/treelistbox.hxx Change-Id: I3c284c360f06ac383e8c38045fc4c2946f505b35 Reviewed-on: https://gerrit.libreoffice.org/3611 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/treelistbox.hxx1
-rw-r--r--svtools/source/contnr/treelistbox.cxx30
2 files changed, 25 insertions, 6 deletions
diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx
index ba678aeb9186..d2590889ac6f 100644
--- a/svtools/inc/svtools/treelistbox.hxx
+++ b/svtools/inc/svtools/treelistbox.hxx
@@ -580,6 +580,7 @@ protected:
sal_Bool AreChildrenTransient() const;
void SetChildrenNotTransient();
+ void AdjustEntryHeightAndRecalc( const Font& rFont );
public:
void SetExtendedWinBits( ExtendedWinBits _nBits );
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index b6c9613f79ca..2fe94e7fe95d 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -1510,7 +1510,10 @@ void SvTreeListBox::InitTreeView()
mbContextBmpExpanded = true;
nContextBmpWidthMax = 0;
+
SetFont( GetFont() );
+ AdjustEntryHeightAndRecalc( GetFont() );
+
SetSpaceBetweenEntries( 0 );
SetLineColor();
InitSettings( sal_True, sal_True, sal_True );
@@ -2575,15 +2578,32 @@ void SvTreeListBox::SetExpandedNodeBmp( const Image& rBmp )
void SvTreeListBox::SetFont( const Font& rFont )
{
DBG_CHKTHIS(SvTreeListBox,0);
+
Font aTempFont( rFont );
+ Font aOrigFont( GetFont() );
aTempFont.SetTransparent( sal_True );
+ if (aTempFont == aOrigFont)
+ return;
Control::SetFont( aTempFont );
- AdjustEntryHeight( aTempFont );
+
+ aTempFont.SetColor(aOrigFont.GetColor());
+ aTempFont.SetFillColor(aOrigFont.GetFillColor());
+ aTempFont.SetTransparent(aOrigFont.IsTransparent());
+
+ if (aTempFont == aOrigFont)
+ return;
+
+ AdjustEntryHeightAndRecalc( GetFont() );
+}
+
+void SvTreeListBox::AdjustEntryHeightAndRecalc( const Font& rFont )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ AdjustEntryHeight( rFont );
// always invalidate, else things go wrong in SetEntryHeight
RecalcViewData();
}
-
void SvTreeListBox::Paint( const Rectangle& rRect )
{
DBG_CHKTHIS(SvTreeListBox,0);
@@ -2626,8 +2646,7 @@ void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
nEntryHeight = nEntryHeight - nEntryHeightOffs;
nEntryHeightOffs = (short)nOffsLogic;
nEntryHeight = nEntryHeight + nOffsLogic;
- AdjustEntryHeight( GetFont() );
- RecalcViewData();
+ AdjustEntryHeightAndRecalc( GetFont() );
pImp->SetEntryHeight( nEntryHeight );
}
}
@@ -3842,8 +3861,7 @@ void SvTreeListBox::InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bB
aFont = rStyleSettings.GetFieldFont();
aFont.SetColor( rStyleSettings.GetWindowTextColor() );
SetPointFont( aFont );
- AdjustEntryHeight( aFont );
- RecalcViewData();
+ AdjustEntryHeightAndRecalc( aFont );
}
if( bForeground || bFont )