From cbba41823a2e67add2620e4901bf0ead542c2932 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 29 Aug 2012 11:22:25 +0100 Subject: String::Expand -> string::padToLength Change-Id: I684e371c31ba76d2e9b563eed70449764346161b --- basic/source/runtime/step0.cxx | 13 +++++++------ sc/source/ui/view/output2.cxx | 7 ++++--- svl/source/numbers/zforfind.cxx | 15 +++++++++------ svl/source/numbers/zformat.cxx | 16 ++++++++++------ svtools/source/svhtml/parhtml.cxx | 10 +++++++--- svx/source/svdraw/svdotxat.cxx | 7 ++++--- vcl/source/control/field2.cxx | 8 +++++--- 7 files changed, 46 insertions(+), 30 deletions(-) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 667a8056a641..40d8f6982fcb 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include @@ -1305,13 +1306,13 @@ void SbiRuntime::StepPRINT() // print TOS void SbiRuntime::StepPRINTF() // print TOS in field { SbxVariableRef p = PopVar(); - String s1 = p->GetString(); - String s; + OUString s1 = p->GetString(); + OUStringBuffer s; if( p->GetType() >= SbxINTEGER && p->GetType() <= SbxDOUBLE ) - s = ' '; - s += s1; - s.Expand( 14, ' ' ); - rtl::OString aByteStr(rtl::OUStringToOString(s, osl_getThreadTextEncoding())); + s.append(' '); + s.append(s1); + comphelper::string::padToLength(s, 14, ' '); + OString aByteStr(OUStringToOString(s.makeStringAndClear(), osl_getThreadTextEncoding())); pIosys->Write( aByteStr ); Error( pIosys->GetError() ); } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 956bf686336a..edfdf60e226f 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -65,6 +65,7 @@ #include "fillinfo.hxx" #include +#include #include @@ -566,9 +567,9 @@ void ScDrawStringsVars::RepeatToFill( long colWidth ) return; long nCharsToInsert = aSpaceToFill / charWidth; - String aFill; - aFill.Expand( nCharsToInsert, nChar); - aString.Insert( aFill, nPos); + StringBuffer aFill; + comphelper::string::padToLength(aFill, nCharsToInsert, nChar); + aString.Insert( aFill.makeStringAndClear(), nPos); TextChanged(); } diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 83ac5f345a4e..6d0cbdc93551 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -1122,14 +1122,16 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) nPat += nLen - 1; else if (nPat + nLen > rPat.getLength() && sStrArray[nNext].GetChar(nLen-1) == ' ') { + using namespace comphelper::string; // Trailing blanks in input. - String aStr(comphelper::string::stripEnd(sStrArray[nNext], ' ')); + OUStringBuffer aBuf(stripEnd(sStrArray[nNext], ' ')); // Expand again in case of pattern "M. D. " and // input "M. D. ", maybe fetched far, but.. - aStr.Expand( rPat.getLength() - nPat, ' '); + padToLength(aBuf, rPat.getLength() - nPat, ' '); + OUString aStr = aBuf.makeStringAndClear(); bOk = (rPat.indexOf( aStr, nPat) == nPat); if (bOk) - nPat += aStr.Len() - 1; + nPat += aStr.getLength() - 1; } } break; @@ -1196,9 +1198,10 @@ bool ImpSvNumberInputScan::SkipDatePatternSeparator( sal_uInt16 nParticle, xub_S { // The same ugly trailing blanks check as in // IsAcceptedDatePattern(). - String aStr(comphelper::string::stripEnd(sStrArray[nNext], ' ')); - aStr.Expand( rPat.getLength() - nPat, ' '); - bOk = (rPat.indexOf( aStr, nPat) == nPat); + using namespace comphelper::string; + OUStringBuffer aBuf(stripEnd(sStrArray[nNext], ' ')); + padToLength(aBuf, rPat.getLength() - nPat, ' '); + bOk = (rPat.indexOf( aBuf.makeStringAndClear(), nPat) == nPat); } if (bOk) { diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 8c30d2442390..5cf224ba451e 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2774,9 +2774,11 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber, sSecStr = comphelper::string::stripStart(sSecStr, '.'); if ( bInputLine ) { - sSecStr = comphelper::string::stripEnd(sSecStr, '0'); - if ( sSecStr.Len() < xub_StrLen(rInfo.nCntPost) ) - sSecStr.Expand( xub_StrLen(rInfo.nCntPost), '0' ); + using namespace comphelper::string; + OUStringBuffer aBuf(stripEnd(sSecStr, '0')); + if (aBuf.getLength() < rInfo.nCntPost) + padToLength(aBuf, rInfo.nCntPost, '0'); + sSecStr = aBuf.makeStringAndClear(); ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() ); nCntPost = sSecStr.Len(); } @@ -3491,9 +3493,11 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber, sSecStr = comphelper::string::stripStart(sSecStr, '.'); if ( bInputLine ) { - sSecStr = comphelper::string::stripEnd(sSecStr, '0'); - if ( sSecStr.Len() < xub_StrLen(rInfo.nCntPost) ) - sSecStr.Expand( xub_StrLen(rInfo.nCntPost), '0' ); + using namespace comphelper::string; + OUStringBuffer aBuf(stripEnd(sSecStr, '0')); + if (aBuf.getLength() < rInfo.nCntPost) + padToLength(aBuf, rInfo.nCntPost, '0'); + sSecStr = aBuf.makeStringAndClear(); ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() ); nCntPost = sSecStr.Len(); } diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 5d94f12a4040..2cf6ebbc3c2b 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -1632,10 +1632,14 @@ int HTMLParser::FilterPRE( int nToken ) case HTML_TABCHAR: { - xub_StrLen nSpaces = sal::static_int_cast< xub_StrLen >( - 8 - (nPre_LinePos % 8)); + sal_Int32 nSpaces = (8 - (nPre_LinePos % 8)); DBG_ASSERT( !aToken.Len(), "Why is the token not empty?" ); - aToken.Expand( nSpaces, ' ' ); + if (aToken.Len() < nSpaces) + { + using comphelper::string::padToLength; + OUStringBuffer aBuf(aToken); + aToken = padToLength(aBuf, nSpaces, ' ').makeStringAndClear(); + } nPre_LinePos += nSpaces; nToken = HTML_TEXTTOKEN; } diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx index 48541e778093..75c7541d7956 100644 --- a/svx/source/svdraw/svdotxat.cxx +++ b/svx/source/svdraw/svdotxat.cxx @@ -251,11 +251,12 @@ void SdrTextObj::ImpSetTextStyleSheetListeners() if(aStyleName.Len()) { - XubString aFam = UniString::CreateFromInt32((sal_uInt16)eStyleFam); - aFam.Expand(5); + OUStringBuffer aFam; + aFam.append(static_cast(eStyleFam)); + comphelper::string::padToLength(aFam, 5, ' '); aStyleName += sal_Unicode('|'); - aStyleName += aFam; + aStyleName += aFam.makeStringAndClear(); sal_Bool bFnd(sal_False); sal_uInt32 nNum(aStyleNames.size()); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index b30e275da104..ec5ad7e7df99 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -753,10 +753,12 @@ void PatternFormatter::ImplSetMask(const rtl::OString& rEditMask, if ( m_aEditMask.getLength() != maLiteralMask.Len() ) { - if ( m_aEditMask.getLength() < maLiteralMask.Len() ) - maLiteralMask.Erase(m_aEditMask.getLength()); + OUStringBuffer aBuf(maLiteralMask); + if (m_aEditMask.getLength() < aBuf.getLength()) + aBuf.remove(m_aEditMask.getLength(), aBuf.getLength() - m_aEditMask.getLength()); else - maLiteralMask.Expand(m_aEditMask.getLength(), ' '); + comphelper::string::padToLength(aBuf, m_aEditMask.getLength(), ' '); + maLiteralMask = aBuf.makeStringAndClear(); } // Strict mode allows only the input mode if only equal characters are allowed as mask and if -- cgit