We know the length here
Change-Id: I630b7fbda7c9ebf578e74260a0d67eea32e9e429 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129549 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -135,7 +135,7 @@ OUString VCLXAccessibleEdit::implGetText()
|
||||
sal_Unicode cEchoChar = pEdit->GetEchoChar();
|
||||
if ( !cEchoChar )
|
||||
cEchoChar = '*';
|
||||
OUStringBuffer sTmp;
|
||||
OUStringBuffer sTmp(aText.getLength());
|
||||
aText = comphelper::string::padToLength(sTmp, aText.getLength(),
|
||||
cEchoChar).makeStringAndClear();
|
||||
}
|
||||
|
@@ -1610,8 +1610,9 @@ void SbRtl_Tab(StarBASIC *, SbxArray & rPar, bool)
|
||||
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
|
||||
else
|
||||
{
|
||||
OUStringBuffer aStr;
|
||||
comphelper::string::padToLength(aStr, rPar.Get(1)->GetLong(), '\t');
|
||||
const sal_Int32 nCount = std::max(rPar.Get(1)->GetLong(), sal_Int32(0));
|
||||
OUStringBuffer aStr(nCount);
|
||||
comphelper::string::padToLength(aStr, nCount, '\t');
|
||||
rPar.Get(0)->PutString(aStr.makeStringAndClear());
|
||||
}
|
||||
}
|
||||
|
@@ -4585,7 +4585,7 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3
|
||||
if( bFixedString )
|
||||
{
|
||||
sal_uInt16 nCount = static_cast<sal_uInt16>( nOp2 >> 17 ); // len = all bits above 0x10000
|
||||
OUStringBuffer aBuf;
|
||||
OUStringBuffer aBuf(nCount);
|
||||
comphelper::string::padToLength(aBuf, nCount);
|
||||
pVar->PutString(aBuf.makeStringAndClear());
|
||||
}
|
||||
|
@@ -302,7 +302,7 @@ SbxArray* StringToByteArray(const OUString& rStr)
|
||||
OUString ByteArrayToString(SbxArray* pArr)
|
||||
{
|
||||
sal_uInt32 nCount = pArr->Count();
|
||||
OUStringBuffer aStrBuf;
|
||||
OUStringBuffer aStrBuf((nCount + 1) / 2);
|
||||
sal_Unicode aChar = 0;
|
||||
for( sal_uInt32 i = 0 ; i < nCount ; i++ )
|
||||
{
|
||||
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
|
||||
#include <file/FStringFunctions.hxx>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
|
||||
using namespace connectivity;
|
||||
@@ -61,7 +63,7 @@ ORowSetValue OOp_Char::operate(const std::vector<ORowSetValue>& lhs) const
|
||||
if (lhs.empty())
|
||||
return ORowSetValue();
|
||||
|
||||
OUStringBuffer sRet;
|
||||
OUStringBuffer sRet(static_cast<sal_Int32>(lhs.size()));
|
||||
std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
|
||||
std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
|
||||
for (; aIter != aEnd; ++aIter)
|
||||
@@ -151,13 +153,9 @@ ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const
|
||||
if (lhs.isNull())
|
||||
return lhs;
|
||||
|
||||
const char c = ' ';
|
||||
OUStringBuffer sRet;
|
||||
sal_Int32 nCount = lhs.getInt32();
|
||||
for (sal_Int32 i = 0; i < nCount; ++i)
|
||||
{
|
||||
sRet.appendAscii(&c, 1);
|
||||
}
|
||||
sal_Int32 nCount = std::max(lhs.getInt32(), sal_Int32(0));
|
||||
OUStringBuffer sRet(nCount);
|
||||
comphelper::string::padToLength(sRet, nCount, ' ');
|
||||
return sRet.makeStringAndClear();
|
||||
}
|
||||
|
||||
@@ -184,11 +182,12 @@ ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs, const ORowSetValue& rh
|
||||
if (lhs.isNull() || rhs.isNull())
|
||||
return lhs;
|
||||
|
||||
OUStringBuffer sRet;
|
||||
sal_Int32 nCount = rhs.getInt32();
|
||||
const OUString s = lhs.getString();
|
||||
const sal_Int32 nCount = std::max(rhs.getInt32(), sal_Int32(0));
|
||||
OUStringBuffer sRet(s.getLength() * nCount);
|
||||
for (sal_Int32 i = 0; i < nCount; ++i)
|
||||
{
|
||||
sRet.append(lhs.getString());
|
||||
sRet.append(s);
|
||||
}
|
||||
return sRet.makeStringAndClear();
|
||||
}
|
||||
|
@@ -3595,7 +3595,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
aTmpFont.SetEscapement( 0 );
|
||||
aTmpFont.SetPropr( 100 );
|
||||
aTmpFont.SetPhysFont(rOutDev);
|
||||
OUStringBuffer aBlanks;
|
||||
OUStringBuffer aBlanks(nTextLen);
|
||||
comphelper::string::padToLength( aBlanks, nTextLen, ' ' );
|
||||
Point aUnderlinePos( aOutPos );
|
||||
if ( nOrientation )
|
||||
@@ -3726,7 +3726,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
else if ( nChars == 2 )
|
||||
nChars = 3; // looks better
|
||||
|
||||
OUStringBuffer aBuf;
|
||||
OUStringBuffer aBuf(nChars);
|
||||
comphelper::string::padToLength(aBuf, nChars, rTextPortion.GetExtraValue());
|
||||
OUString aText(aBuf.makeStringAndClear());
|
||||
aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength() );
|
||||
|
@@ -124,9 +124,9 @@ OUString lcl_ValueString( sal_Int32 nValue, sal_uInt16 nMinDigits )
|
||||
OUString aStr = OUString::number( std::abs( nValue ) );
|
||||
if ( aStr.getLength() < nMinDigits )
|
||||
{
|
||||
OUStringBuffer aZero;
|
||||
OUStringBuffer aZero(nMinDigits);
|
||||
comphelper::string::padToLength(aZero, nMinDigits - aStr.getLength(), '0');
|
||||
aStr = aZero.makeStringAndClear() + aStr;
|
||||
aStr = aZero.append(aStr).makeStringAndClear();
|
||||
}
|
||||
// nMinDigits doesn't include the '-' sign -> add after inserting zeros
|
||||
if ( nValue < 0 )
|
||||
|
Reference in New Issue
Block a user