summaryrefslogtreecommitdiff
path: root/vcl/source/control/imp_listbox.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-09-07 16:33:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-09-10 09:05:38 +0200
commit433fce6571d4b9121374047324a7d2d2722ac3e4 (patch)
treed326ede2f8215db21c69f1f5bc3225c77002aedc /vcl/source/control/imp_listbox.cxx
parentf3d6c44c9cb533fe4f1cd28fc95adc36cac4bfd5 (diff)
vcl: less text layout calls in ListBox
Number of GenericSalLayout::LayoutText() calls during Writer startup at this call-site: 1068 -> 614. Change-Id: I3bef56e550294a6b2c9fe73c0c6531249c9f1f30 Reviewed-on: https://gerrit.libreoffice.org/60164 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl/source/control/imp_listbox.cxx')
-rw-r--r--vcl/source/control/imp_listbox.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 0655b74c6d8e..629d1609fbfc 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -601,6 +601,27 @@ struct ImplEntryMetrics
long nImgHeight;
};
+SalLayoutGlyphs* ImplEntryType::GetTextGlyphs(OutputDevice* pOutputDevice)
+{
+ if (!maStrGlyphs.empty())
+ // Use pre-calculated result.
+ return &maStrGlyphs;
+
+ std::unique_ptr<SalLayout> pLayout = pOutputDevice->ImplLayout(
+ maStr, 0, maStr.getLength(), Point(0, 0), 0, nullptr, SalLayoutFlags::GlyphItemsOnly);
+ if (!pLayout)
+ return nullptr;
+
+ const SalLayoutGlyphs* pGlyphs = pLayout->GetGlyphs();
+ if (!pGlyphs)
+ return nullptr;
+
+ // Remember the calculation result.
+ maStrGlyphs = *pGlyphs;
+
+ return &maStrGlyphs;
+}
+
void ImplListBoxWindow::EnableQuickSelection( bool b )
{
maQuickSelectionEngine.SetEnabled( b );
@@ -637,7 +658,9 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry )
else
{
// normal single line case
- aMetrics.nTextWidth = static_cast<sal_uInt16>(GetTextWidth( rEntry.maStr ));
+ const SalLayoutGlyphs* pGlyphs = rEntry.GetTextGlyphs(this);
+ aMetrics.nTextWidth
+ = static_cast<sal_uInt16>(GetTextWidth(rEntry.maStr, 0, -1, nullptr, pGlyphs));
if( aMetrics.nTextWidth > mnMaxTxtWidth )
mnMaxTxtWidth = aMetrics.nTextWidth;
aMetrics.nEntryWidth = mnMaxTxtWidth;