Kaydet (Commit) 62ea355b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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
üst e74ddf42
......@@ -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());
}
// ***************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment