diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 13:24:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 22:15:21 +0200 |
commit | a55d164b2e2a5df61078bcbd018f2d20712c3388 (patch) | |
tree | 02124525524a194d8b98b9e22a24e7addc606df3 | |
parent | bdc0b3e3d7f1f5a07f4863913aef0824dedf9a69 (diff) |
adjust min/max chars label width calc
Change-Id: Ia220d01a20df5aa20839155391ac5e46cfe172c1
Reviewed-on: https://gerrit.libreoffice.org/54486
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/control/fixed.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
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; } |