Kaydet (Commit) 90059da9 authored tarafından Matteo Casalin's avatar Matteo Casalin

Avoid getTokenCount in SmViewShell::SetZoomFactor

Change-Id: Idb874a60868595ccc648da86c8bd32c28b92547b
üst 13ea7ab9
...@@ -976,23 +976,21 @@ void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY ) ...@@ -976,23 +976,21 @@ void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY )
Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const OUString& rLine) Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const OUString& rLine)
{ {
Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight()); Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t'); const long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_char_width() * 8;
long nTabPos = 0;
if (nTabs > 0)
nTabPos = rDevice.approximate_char_width() * 8;
if (nTabPos) if (nTabPos)
{ {
aSize.Width() = 0; aSize.Width() = 0;
sal_Int32 nPos = 0;
for (sal_uInt16 i = 0; i < nTabs; i++) do
{ {
if (i > 0) if (nPos > 0)
aSize.Width() = ((aSize.Width() / nTabPos) + 1) * nTabPos; aSize.Width() = ((aSize.Width() / nTabPos) + 1) * nTabPos;
OUString aText = rLine.getToken(i, '\t'); const OUString aText = rLine.getToken(0, '\t', nPos);
aSize.Width() += rDevice.GetTextWidth(aText); aSize.Width() += rDevice.GetTextWidth(aText);
} }
while (nPos >= 0);
} }
return aSize; return aSize;
......
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