[Libreoffice-commits] core.git: vcl/source
Caolán McNamara
caolanm at redhat.com
Thu May 17 20:15:49 UTC 2018
vcl/source/control/fixed.cxx | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit a55d164b2e2a5df61078bcbd018f2d20712c3388
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu May 17 13:24:34 2018 +0100
adjust min/max chars label width calc
Change-Id: Ia220d01a20df5aa20839155391ac5e46cfe172c1
Reviewed-on: https://gerrit.libreoffice.org/54486
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index f998285abc1a..dac10a896278 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -344,11 +344,12 @@ Size FixedText::CalcMinimumSize( long nMaxWidth ) const
Size FixedText::GetOptimalSize() const
{
sal_Int32 nMaxAvailWidth = 0x7fffffff;
- const OUString &rTxt = GetText();
- if (m_nMaxWidthChars != -1 && m_nMaxWidthChars < rTxt.getLength())
+ if (m_nMaxWidthChars != -1)
{
+ OUStringBuffer aBuf;
+ comphelper::string::padToLength(aBuf, m_nMaxWidthChars, 'x');
nMaxAvailWidth = getTextDimensions(this,
- rTxt.copy(0, m_nMaxWidthChars), 0x7fffffff).Width();
+ aBuf.makeStringAndClear(), 0x7fffffff).Width();
}
Size aRet = CalcMinimumSize(nMaxAvailWidth);
if (m_nMinWidthChars != -1)
@@ -357,8 +358,7 @@ Size FixedText::GetOptimalSize() const
comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x');
Size aMinAllowed = getTextDimensions(this,
aBuf.makeStringAndClear(), 0x7fffffff);
- if (aMinAllowed.Width() > aRet.Width())
- aRet = aMinAllowed;
+ aRet.setWidth(std::max(aMinAllowed.Width(), aRet.Width()));
}
return aRet;
}
More information about the Libreoffice-commits
mailing list