summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2013-12-12 09:55:35 +0100
committerJan Holesovsky <kendy@collabora.com>2013-12-12 09:58:59 +0100
commit3e6ce9e2102a923bd0dab0b791db3587c6e434f2 (patch)
tree636ab081c3e094268f93b33cce24467dedfdbcd8
parent0e25ff00645b0103b6420156388933b6862694a7 (diff)
fdo#72125: GetTextWidth() can get very expensive.
Let's just count an approximate width using a cached value when we have too many entries. Change-Id: I2113887c477bc774dd00df538ec1a01f102f4726
-rw-r--r--svtools/source/contnr/svlbitm.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx
index ca3b3423659d..e47baaa48b14 100644
--- a/svtools/source/contnr/svlbitm.cxx
+++ b/svtools/source/contnr/svlbitm.cxx
@@ -247,7 +247,25 @@ void SvLBoxString::InitViewData(
DBG_CHKTHIS(SvLBoxString,0);
if( !pViewData )
pViewData = pView->GetViewDataItem( pEntry, this );
- pViewData->maSize = Size(pView->GetTextWidth(maText), pView->GetTextHeight());
+
+ // fdo#72125: GetTextWidth() can get very expensive; let's just count
+ // an approximate width using a cached value when we have many entries
+ long nTextWidth;
+ if (pView->GetEntryCount() > 100)
+ {
+ static SvTreeListBox *pPreviousView = NULL;
+ static float fApproximateCharWidth = 0.0;
+ if (pPreviousView != pView)
+ {
+ pPreviousView = pView;
+ fApproximateCharWidth = pView->approximate_char_width();
+ }
+ nTextWidth = maText.getLength() * fApproximateCharWidth;
+ }
+ else
+ nTextWidth = pView->GetTextWidth(maText);
+
+ pViewData->maSize = Size(nTextWidth, pView->GetTextHeight());
}
// ***************************************************************