Kaydet (Commit) c6ec3e4c authored tarafından Michael Stahl's avatar Michael Stahl

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 912ecaf5)

Change-Id: I9310dda1847222215bafe372e3efef9d365e1ad9
üst 6ffecab0
......@@ -2022,7 +2022,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(4, aStr.getLength() - (nIndex*4)/3);
while( nEraseChars < aStr.getLength() && _rLayout.GetTextWidth( aTmpStr.toString(), 0, aTmpStr.getLength() ) > nMaxWidth )
{
aTmpStr = OUStringBuffer(aStr);
......
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