vcl/source/app/help.cxx | 5 ++--- vcl/source/control/edit.cxx | 2 +- vcl/source/control/field2.cxx | 2 +- vcl/source/control/fixed.cxx | 4 ++-- vcl/source/control/fmtfield.cxx | 5 +---- vcl/source/control/longcurr.cxx | 3 +-- 6 files changed, 8 insertions(+), 13 deletions(-)
New commits: commit 423174a7830c2cf9333c55872ef3775fabfd6962 Author: Mike Kaganski <[email protected]> AuthorDate: Sun Feb 6 14:30:02 2022 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Sun Feb 6 16:25:13 2022 +0100 We know the length here Change-Id: I45b90c40f062afe950952740901c40fee085ed06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129552 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 5fc3ed4b2a91..611bf3422bb2 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -341,10 +341,9 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText ) { sal_Int32 nCharsInLine = 35 + ((maHelpText.getLength()/100)*5); // average width to have all windows consistent - OUStringBuffer aBuf; + OUStringBuffer aBuf(nCharsInLine); comphelper::string::padToLength(aBuf, nCharsInLine, 'x'); - OUString aXXX = aBuf.makeStringAndClear(); - tools::Long nWidth = GetTextWidth( aXXX ); + tools::Long nWidth = GetTextWidth( OUString::unacquired(aBuf) ); Size aTmpSize( nWidth, 0x7FFFFFFF ); tools::Rectangle aTry1( Point(), aTmpSize ); DrawTextFlags nDrawFlags = DrawTextFlags::MultiLine | DrawTextFlags::WordBreak | diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index ceb238feaf52..bb511a34b8b0 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -431,7 +431,7 @@ OUString Edit::ImplGetText() const cEchoChar = mcEchoChar; else cEchoChar = u'\x2022'; - OUStringBuffer aText; + OUStringBuffer aText(maText.getLength()); comphelper::string::padToLength(aText, maText.getLength(), cEchoChar); return aText.makeStringAndClear(); } diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index f1e24cd2fb6b..1fa8d4d0be5b 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -798,7 +798,7 @@ namespace { OUStringBuffer aBuf(rLiteralMask); if (rEditMask.getLength() < aBuf.getLength()) - aBuf.remove(rEditMask.getLength(), aBuf.getLength() - rEditMask.getLength()); + aBuf.setLength(rEditMask.getLength()); else comphelper::string::padToLength(aBuf, rEditMask.getLength(), ' '); rLiteralMask = aBuf.makeStringAndClear(); diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index d06eeecc292e..3ba251d271ce 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -331,7 +331,7 @@ Size FixedText::GetOptimalSize() const sal_Int32 nMaxAvailWidth = 0x7fffffff; if (m_nMaxWidthChars != -1) { - OUStringBuffer aBuf; + OUStringBuffer aBuf(m_nMaxWidthChars); comphelper::string::padToLength(aBuf, m_nMaxWidthChars, 'x'); nMaxAvailWidth = getTextDimensions(this, aBuf.makeStringAndClear(), 0x7fffffff).Width(); @@ -339,7 +339,7 @@ Size FixedText::GetOptimalSize() const Size aRet = CalcMinimumSize(nMaxAvailWidth); if (m_nMinWidthChars != -1) { - OUStringBuffer aBuf; + OUStringBuffer aBuf(m_nMinWidthChars); comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x'); Size aMinAllowed = getTextDimensions(this, aBuf.makeStringAndClear(), 0x7fffffff); diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index 326ba7f7ef3e..f027ada878e5 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -1100,10 +1100,7 @@ void DoubleCurrencyField::UpdateCurrencyFormat() if (nDigits) { sNewFormat.append(aLocaleInfo.getNumDecimalSep()); - - OUStringBuffer sTemp; - comphelper::string::padToLength(sTemp, nDigits, '0'); - sNewFormat.append(sTemp); + comphelper::string::padToLength(sNewFormat, sNewFormat.getLength() + nDigits, '0'); } if (getPrependCurrSym()) diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 4a9c86187677..633b61faa862 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -192,8 +192,7 @@ bool ImplCurrencyGetValue( const OUString& rStr, BigInt& rValue, bRound = true; string::truncateToLength(aStr2, nDecDigits); } - if (aStr2.getLength() < nDecDigits) - string::padToLength(aStr2, nDecDigits, '0'); + string::padToLength(aStr2, nDecDigits, '0'); aStr1.append(aStr2); aStr = aStr1.makeStringAndClear();
