summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-04-16 22:25:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-20 14:36:35 +0000
commit05006dd3b2cd3e3961127d719e5a4d2c39aaa051 (patch)
treeac8a39368d986caa25d26f3872149a472dcbee8f
parent9a4be346d24e7988d6b18eb89f39ae939c85418a (diff)
tdf#86793: vcl: speed up OutputDevice::GetEllipsisString()
The ridiculous algrorithm used for TEXT_DRAW_CENTERELLIPSIS will go faster if we cut out most of the text at the beginning instead of one at a time. (regression from 912ecaf565e68d2ca3fb9584712313e712749f75) (cherry picked from commit c6ec3e4cee8c7c22380780f2661ac23946cdb050) Change-Id: I9310dda1847222215bafe372e3efef9d365e1ad9 Reviewed-on: https://gerrit.libreoffice.org/15356 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 2cd486b1dd75d530d8c12eb223e5f215fa8f1944) Reviewed-on: https://gerrit.libreoffice.org/15439 Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/source/outdev/text.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 55ffe71bf4f7..b9a23caddc02 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1907,7 +1907,8 @@ OUString OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice,
if( (nStyle & TEXT_DRAW_CENTERELLIPSIS) == TEXT_DRAW_CENTERELLIPSIS )
{
OUStringBuffer aTmpStr( aStr );
- sal_Int32 nEraseChars = 4;
+ // speed it up by removing all but 1.33x as many as the break pos.
+ sal_Int32 nEraseChars = std::max<sal_Int32>(4, aStr.getLength() - (nIndex*4)/3);
while( nEraseChars < aStr.getLength() && _rLayout.GetTextWidth( aTmpStr.toString(), 0, aTmpStr.getLength() ) > nMaxWidth )
{
aTmpStr = OUStringBuffer(aStr);