vcl/source/control/fixed.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
New commits: commit a55d164b2e2a5df61078bcbd018f2d20712c3388 Author: Caolán McNamara <caol...@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 <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits