summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-02-06 14:30:02 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2022-02-06 16:25:13 +0100
commit423174a7830c2cf9333c55872ef3775fabfd6962 (patch)
tree4b167936d6aabbf576f84d84bd0f84056f501557
parent4f533655dd635dab30574c2a3b3915377124bd60 (diff)
We know the length here
Change-Id: I45b90c40f062afe950952740901c40fee085ed06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129552 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--vcl/source/app/help.cxx5
-rw-r--r--vcl/source/control/edit.cxx2
-rw-r--r--vcl/source/control/field2.cxx2
-rw-r--r--vcl/source/control/fixed.cxx4
-rw-r--r--vcl/source/control/fmtfield.cxx5
-rw-r--r--vcl/source/control/longcurr.cxx3
6 files changed, 8 insertions, 13 deletions
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();