svtools/source/contnr/svlbitm.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
New commits: commit 3e6ce9e2102a923bd0dab0b791db3587c6e434f2 Author: Jan Holesovsky <ke...@collabora.com> Date: Thu Dec 12 09:55:35 2013 +0100 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 diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index ca3b342..e47baaa 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()); } // *************************************************************** _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits