diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-28 20:31:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-28 23:09:32 +0000 |
commit | 0dd085f8f327b08cf5d69c3e1b93ff82016995fb (patch) | |
tree | 0fec0966cd3a88b840621161de72ef5c462bb877 | |
parent | 8865b7f013bcd9b4ce41dd98be28ba28aeb22e66 (diff) |
UniString->rtl::OUStringBuffer
Change-Id: I9938d7c4ab5594baeb10f405f0aa0964ef84d6c5
-rw-r--r-- | basic/source/runtime/step1.cxx | 16 | ||||
-rw-r--r-- | sc/inc/global.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xeescher.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xehelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xicontent.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/html/htmlimp.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/html/htmlpars.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/validate.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 8 | ||||
-rw-r--r-- | tools/inc/tools/string.hxx | 3 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 29 | ||||
-rw-r--r-- | vcl/source/control/field.cxx | 45 | ||||
-rw-r--r-- | vcl/source/control/longcurr.cxx | 37 |
17 files changed, 91 insertions, 99 deletions
diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index a9466faae69b..9ca79d019ac0 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -19,7 +19,9 @@ #include <stdlib.h> +#include <comphelper/string.hxx> #include <rtl/math.hxx> +#include <rtl/ustrbuf.hxx> #include <basic/sbuno.hxx> #include "runtime.hxx" #include "sbintern.hxx" @@ -147,10 +149,16 @@ void SbiRuntime::StepPAD( sal_uInt32 nOp1 ) { SbxVariable* p = GetTOS(); String& s = (String&)(const String&) *p; - if( s.Len() > nOp1 ) - s.Erase( static_cast<xub_StrLen>( nOp1 ) ); - else - s.Expand( static_cast<xub_StrLen>( nOp1 ), ' ' ); + if (s.Len() != nOp1) + { + rtl::OUStringBuffer aBuf(s); + sal_Int32 nLen(nOp1); + if (aBuf.getLength() > nLen) + comphelper::string::truncateToLength(aBuf, nLen); + else + comphelper::string::padToLength(aBuf, nLen, ' '); + s = aBuf.makeStringAndClear(); + } } // jump (+target) diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 44d8810ddd2d..5dfe54763375 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -632,9 +632,9 @@ public: @param cSep The character to separate the tokens. @param nSepCount Specifies how often cSep is inserted between two tokens. @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */ - SC_DLLPUBLIC static void AddToken( - String& rTokenList, const String& rToken, - sal_Unicode cSep, xub_StrLen nSepCount = 1, + SC_DLLPUBLIC static OUString addToken( + const OUString& rTokenList, const OUString& rToken, + sal_Unicode cSep, sal_Int32 nSepCount = 1, bool bForceSep = false ); /** Returns true, if the first and last character of the string is cQuote. */ diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 4d269a1465dd..2cefa9468cc5 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -56,6 +56,7 @@ #include <i18npool/mslangid.hxx> #include <com/sun/star/lang/Locale.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <unotools/calendarwrapper.hxx> #include <unotools/collatorwrapper.hxx> #include <com/sun/star/i18n/CollatorOptions.hpp> @@ -806,11 +807,14 @@ const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr, // ---------------------------------------------------------------------------- -void ScGlobal::AddToken( String& rTokenList, const String& rToken, sal_Unicode cSep, xub_StrLen nSepCount, bool bForceSep ) +OUString ScGlobal::addToken(const OUString& rTokenList, const OUString& rToken, + sal_Unicode cSep, sal_Int32 nSepCount, bool bForceSep) { - if( bForceSep || (rToken.Len() && rTokenList.Len()) ) - rTokenList.Expand( rTokenList.Len() + nSepCount, cSep ); - rTokenList.Append( rToken ); + rtl::OUStringBuffer aBuf(rTokenList); + if( bForceSep || (!rToken.isEmpty() && !rTokenList.isEmpty()) ) + comphelper::string::padToLength(aBuf, aBuf.getLength() + nSepCount, cSep); + aBuf.append(rToken); + return aBuf.makeStringAndClear(); } bool ScGlobal::IsQuoted( const String& rString, sal_Unicode cQuote ) diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index fc899502d7d4..9e5056341ea1 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <comphelper/string.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/objsh.hxx> @@ -2602,7 +2603,14 @@ void ScInterpreter::ScRoman() { if( nDigit > 4 ) aRoman += pChars[ nIndex - 1 ]; - aRoman.Expand( aRoman.Len() + (nDigit % 5), pChars[ nIndex ] ); + sal_Int32 nPad = nDigit % 5; + if (nPad) + { + rtl::OUStringBuffer aBuf(aRoman); + comphelper::string::padToLength(aBuf, aBuf.getLength() + nPad, + pChars[nIndex]); + aRoman = aBuf.makeStringAndClear(); + } nVal %= pValues[ nIndex ]; } } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index c73155be6518..219bbb84fcf5 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -1600,7 +1600,7 @@ XclExpWebQuery::XclExpWebQuery( mbEntireDoc = ScfTools::IsHTMLDocName( aToken ); bExitLoop = mbEntireDoc || ScfTools::IsHTMLTablesName( aToken ); if( !bExitLoop && ScfTools::GetHTMLNameFromName( aToken, aAppendTable ) ) - ScGlobal::AddToken( aNewTables, aAppendTable, ',' ); + aNewTables = ScGlobal::addToken( aNewTables, aAppendTable, ',' ); } if( !bExitLoop ) // neither HTML_all nor HTML_tables found diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 74bc82d532b9..b4e4aafe8c6c 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1225,7 +1225,7 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos, mpNoteContents = XclExpStringHelper::CreateString( rRoot, *pEditObj ); } // append additional text - ScGlobal::AddToken( aNoteText, rAddText, '\n', 2 ); + aNoteText = ScGlobal::addToken( aNoteText, rAddText, '\n', 2 ); maOrigNoteText = aNoteText; // initialize record dependent on BIFF type diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx index b2a68d467265..581c6142c9dd 100644 --- a/sc/source/filter/excel/xehelper.cxx +++ b/sc/source/filter/excel/xehelper.cxx @@ -320,7 +320,7 @@ rtl::OUString XclExpHyperlinkHelper::ProcessUrlField( const SvxURLField& rUrlFie aUrlRepr = *pRepr; // add URL to note text - ScGlobal::AddToken( maUrlList, rUrlField.GetURL(), '\n' ); + maUrlList = ScGlobal::addToken( maUrlList, rUrlField.GetURL(), '\n' ); } // no hyperlink representation from Excel HLINK record -> use it from text field @@ -879,7 +879,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico aSel.nStartPos = aSel.nEndPos; } - ScGlobal::AddToken( aText, aParaText, '\n' ); + aText = ScGlobal::addToken( aText, aParaText, '\n' ); if( nParaHeight == 0 ) nParaHeight = aFontData.mnHeight * 20; // points -> twips nHeight += nParaHeight; diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index bebb239e9289..04458d18e404 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2329,7 +2329,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : mxHyperlinkList->AppendRecord( aLinkHelper.GetLinkRecord() ); // add list of multiple URLs to the additional cell note text if( aLinkHelper.HasMultipleUrls() ) - ScGlobal::AddToken( aAddNoteText, aLinkHelper.GetUrlList(), '\n', 2 ); + aAddNoteText = ScGlobal::addToken( aAddNoteText, aLinkHelper.GetUrlList(), '\n', 2 ); } break; diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index c5f6dad50a6a..edd47173f524 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -947,12 +947,12 @@ void XclImpWebQuery::ReadWqtables( XclImpStream& rStrm ) String aToken( ScStringUtil::GetQuotedToken( aTables, 0, aQuotedPairs, ',', nStringIx ) ); sal_Int32 nTabNum = CharClass::isAsciiNumeric( aToken ) ? aToken.ToInt32() : 0; if( nTabNum > 0 ) - ScGlobal::AddToken( maTables, ScfTools::GetNameFromHTMLIndex( static_cast< sal_uInt32 >( nTabNum ) ), cSep ); + maTables = ScGlobal::addToken( maTables, ScfTools::GetNameFromHTMLIndex( static_cast< sal_uInt32 >( nTabNum ) ), cSep ); else { ScGlobal::EraseQuotes( aToken, '"', false ); if( aToken.Len() ) - ScGlobal::AddToken( maTables, ScfTools::GetNameFromHTMLName( aToken ), cSep ); + maTables = ScGlobal::addToken( maTables, ScfTools::GetNameFromHTMLName( aToken ), cSep ); } } } diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index b75b1cc351b1..facda67aa573 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -238,7 +238,7 @@ String ScHTMLImport::GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrig ScRange aRange; if( pRangeData->IsReference( aRange ) && !aRangeList.In( aRange ) ) { - ScGlobal::AddToken( aNewName, aToken, ';' ); + aNewName = ScGlobal::addToken(aNewName, aToken, ';'); aRangeList.Append( aRange ); } } @@ -247,7 +247,7 @@ String ScHTMLImport::GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrig } } else - ScGlobal::AddToken( aNewName, aToken, ';' ); + aNewName = ScGlobal::addToken(aNewName, aToken, ';'); } return aNewName; } diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 7b412f3ddb21..d5ad5e7f3326 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -3082,7 +3082,7 @@ void ScHTMLQueryParser::FontOn( const ImportInfo& rInfo ) { // font list separator: VCL = ';' HTML = ',' String aFName = comphelper::string::strip(rFace.GetToken(0, ',', nPos), ' '); - ScGlobal::AddToken( aFontName, aFName, ';' ); + aFontName = ScGlobal::addToken(aFontName, aFName, ';'); } if ( aFontName.Len() ) mpCurrTable->PutItem( SvxFontItem( FAMILY_DONTKNOW, diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 390ad1743e63..ea12ad189296 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -269,7 +269,7 @@ void lclGetFormulaFromStringList( String& rFmlaStr, const String& rStringList, s { String aToken( rStringList.GetToken( 0, '\n', nStringIx ) ); ScGlobal::AddQuotes( aToken, '"' ); - ScGlobal::AddToken( rFmlaStr, aToken, cFmlaSep ); + rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep); } if( !rFmlaStr.Len() ) rFmlaStr.AssignAscii( "\"\"" ); @@ -300,7 +300,7 @@ bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, s if( bIsStringList ) { ScGlobal::EraseQuotes( aToken, '"' ); - ScGlobal::AddToken( rStringList, aToken, '\n', 1, bTokenAdded ); + rStringList = ScGlobal::addToken(rStringList, aToken, '\n', 1, bTokenAdded); bTokenAdded = true; } } diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index e9eb4e99f858..41f61009f816 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -31,6 +31,7 @@ #include <hintids.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/i18n/XBreakIterator.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/InputSequenceCheckMode.hpp> @@ -2386,7 +2387,7 @@ KEYINPUT_CHECKTABLE_INSDEL: { // insert a blank ahead of the character. this ends up // between the expanded text and the new "non-word-seperator". - aInBuffer.Expand( aInBuffer.Len() + 1, ' ' ); + aInBuffer += ' '; } sal_Bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh ); @@ -2417,7 +2418,10 @@ KEYINPUT_CHECKTABLE_INSDEL: } else { - aInBuffer.Expand( aInBuffer.Len() + aKeyEvent.GetRepeat() + 1,aCh ); + rtl::OUStringBuffer aBuf(aInBuffer); + comphelper::string::padToLength(aBuf, + aInBuffer.Len() + aKeyEvent.GetRepeat() + 1, aCh); + aInBuffer = aBuf.makeStringAndClear(); bFlushCharBuffer = Application::AnyInput( VCL_INPUT_KEYBOARD ); bFlushBuffer = !bFlushCharBuffer; if( bFlushCharBuffer ) diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx index 7603b9727040..3aeb7e9a37d7 100644 --- a/tools/inc/tools/string.hxx +++ b/tools/inc/tools/string.hxx @@ -131,7 +131,7 @@ private: sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); TOOLS_DLLPRIVATE UniString( const sal_Unicode* pCharStr ); TOOLS_DLLPRIVATE UniString( const sal_Unicode* pCharStr, xub_StrLen nLen ); - + TOOLS_DLLPRIVATE UniString& Expand( xub_StrLen nCount, sal_Unicode cExpandChar ); public: UniString(); UniString( const ResId& rResId ); @@ -216,7 +216,6 @@ public: UniString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const; UniString& Fill( xub_StrLen nCount, sal_Unicode cFillChar = ' ' ); - UniString& Expand( xub_StrLen nCount, sal_Unicode cExpandChar = ' ' ); UniString& ToLowerAscii(); UniString& ToUpperAscii(); diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 0893e4afb256..898d2d899597 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -267,35 +267,6 @@ STRING& STRING::Fill( xub_StrLen nCount, STRCODE cFillChar ) return *this; } -STRING& STRING::Expand( xub_StrLen nCount, STRCODE cExpandChar ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // return if string doesn't need expanding - sal_Int32 nLen = mpData->mnLen; - if ( nCount <= nLen ) - return *this; - - // allocate string of new size - STRINGDATA* pNewData = ImplAllocData( nCount ); - - // copy from old string - memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) ); - - // and expand using the given character - STRCODE* pStr = pNewData->maStr; - pStr += nLen; - for (sal_Int32 i = nCount - nLen; i > 0; --i) { - *pStr++ = cExpandChar; - } - - // free old string - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - - return *this; -} - STRCODE* STRING::GetBufferAccess() { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index f258ffcd6288..93c3a1c2c098 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -103,10 +103,9 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, { XubString aStr = rStr; XubString aStr1; - XubString aStr2; + rtl::OUStringBuffer aStr2; sal_Bool bNegative = sal_False; xub_StrLen nDecPos; - xub_StrLen i; // react on empty string if ( !rStr.Len() ) @@ -120,7 +119,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, if ( nDecPos != STRING_NOTFOUND ) { aStr1 = aStr.Copy( 0, nDecPos ); - aStr2 = aStr.Copy( nDecPos+1 ); + aStr2.append(aStr.Copy(nDecPos+1)); } else aStr1 = aStr; @@ -132,7 +131,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, bNegative = sal_True; if ( !bNegative ) { - for ( i=0; i < aStr.Len(); i++ ) + for (xub_StrLen i=0; i < aStr.Len(); i++ ) { if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) break; @@ -149,7 +148,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, if ( (nFormat == 3) || (nFormat == 6) || (nFormat == 7) || (nFormat == 10) ) { - for ( i = (xub_StrLen)(aStr.Len()-1); i > 0; i++ ) + for (xub_StrLen i = (xub_StrLen)(aStr.Len()-1); i > 0; i++ ) { if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) break; @@ -169,22 +168,22 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, } // remove all unwanted charaters - for ( i=0; i < aStr1.Len(); ) + for (xub_StrLen i=0; i < aStr1.Len(); ) { if ( (aStr1.GetChar( i ) >= '0') && (aStr1.GetChar( i ) <= '9') ) i++; else aStr1.Erase( i, 1 ); } - for ( i=0; i < aStr2.Len(); ) + for (sal_Int32 i=0; i < aStr2.getLength(); ) { - if ( (aStr2.GetChar( i ) >= '0') && (aStr2.GetChar( i ) <= '9') ) - i++; + if ((aStr2[i] >= '0') && (aStr2[i] <= '9')) + ++i; else - aStr2.Erase( i, 1 ); + aStr2.remove(i, 1); } - if ( !aStr1.Len() && !aStr2.Len() ) + if ( !aStr1.Len() && !aStr2.getLength() ) return sal_False; if ( !aStr1.Len() ) @@ -193,22 +192,22 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue, aStr1.Insert( '-', 0 ); // prune and round fraction - sal_Bool bRound = sal_False; - if ( aStr2.Len() > nDecDigits ) + bool bRound = false; + if (aStr2.getLength() > nDecDigits) { - if ( aStr2.GetChar( nDecDigits ) >= '5' ) - bRound = sal_True; - aStr2.Erase( nDecDigits ); + if (aStr2[nDecDigits] >= '5') + bRound = true; + string::truncateToLength(aStr2, nDecDigits); } - if ( aStr2.Len() < nDecDigits ) - aStr2.Expand( nDecDigits, '0' ); + if (aStr2.getLength() < nDecDigits) + string::padToLength(aStr2, nDecDigits, '0'); aStr = aStr1; - aStr += aStr2; + aStr += aStr2.makeStringAndClear(); // check range double nValue = rtl::OUString(aStr).toDouble(); - if ( bRound ) + if (bRound) { if ( !bNegative ) nValue++; @@ -950,12 +949,12 @@ namespace sal_Int32 nTextLen; nTextLen = rtl::OUString::valueOf(rFormatter.GetMin()).getLength(); - comphelper::string::padToLength(aBuf, nTextLen, '9'); + string::padToLength(aBuf, nTextLen, '9'); Size aMinTextSize = rSpinField.CalcMinimumSizeForText( rFormatter.CreateFieldText(aBuf.makeStringAndClear().toInt64())); nTextLen = rtl::OUString::valueOf(rFormatter.GetMax()).getLength(); - comphelper::string::padToLength(aBuf, nTextLen, '9'); + string::padToLength(aBuf, nTextLen, '9'); Size aMaxTextSize = rSpinField.CalcMinimumSizeForText( rFormatter.CreateFieldText(aBuf.makeStringAndClear().toInt64())); @@ -967,7 +966,7 @@ namespace if (nDigits) { sBuf.append('.'); - comphelper::string::padToLength(aBuf, aBuf.getLength() + nDigits, '9'); + string::padToLength(aBuf, aBuf.getLength() + nDigits, '9'); } aMaxTextSize = rSpinField.CalcMinimumSizeForText(sBuf.makeStringAndClear()); aRet.Width() = std::min(aRet.Width(), aMaxTextSize.Width()); diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index fa9fe0f71c9a..6e76c299b7bb 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -142,10 +142,9 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, { XubString aStr = rStr; XubString aStr1; - XubString aStr2; + rtl::OUStringBuffer aStr2; sal_uInt16 nDecPos; sal_Bool bNegative = sal_False; - xub_StrLen i; // Reaktion auf leeren String if ( !rStr.Len() ) @@ -160,7 +159,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, if ( nDecPos != STRING_NOTFOUND ) { aStr1 = aStr.Copy( 0, nDecPos ); - aStr2 = aStr.Copy( nDecPos+1 ); + aStr2.append(aStr.Copy(nDecPos+1)); } else aStr1 = aStr; @@ -172,7 +171,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, bNegative = sal_True; if ( !bNegative ) { - for ( i=0; i < aStr.Len(); i++ ) + for (xub_StrLen i=0; i < aStr.Len(); i++ ) { if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) break; @@ -189,7 +188,7 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, if ( (nFormat == 3) || (nFormat == 6) || (nFormat == 7) || (nFormat == 10) ) { - for ( i = (sal_uInt16)(aStr.Len()-1); i > 0; i++ ) + for (xub_StrLen i = (sal_uInt16)(aStr.Len()-1); i > 0; i++ ) { if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) break; @@ -209,22 +208,22 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, } // Alle unerwuenschten Zeichen rauswerfen - for ( i=0; i < aStr1.Len(); ) + for (xub_StrLen i=0; i < aStr1.Len(); ) { if ( (aStr1.GetChar( i ) >= '0') && (aStr1.GetChar( i ) <= '9') ) i++; else aStr1.Erase( i, 1 ); } - for ( i=0; i < aStr2.Len(); ) + for (sal_Int32 i=0; i < aStr2.getLength();) { - if ( (aStr2.GetChar( i ) >= '0') && (aStr2.GetChar( i ) <= '9') ) - i++; + if ((aStr2[i] >= '0') && (aStr2[i] <= '9')) + ++i; else - aStr2.Erase( i, 1 ); + aStr2.remove(i, 1); } - if ( !aStr1.Len() && !aStr2.Len() ) + if (!aStr1.Len() && !aStr2.getLength()) return sal_False; if ( !aStr1.Len() ) @@ -233,18 +232,18 @@ static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, aStr1.Insert( '-', 0 ); // Nachkommateil zurechtstutzen und dabei runden - sal_Bool bRound = sal_False; - if ( aStr2.Len() > nDecDigits ) + bool bRound = false; + if (aStr2.getLength() > nDecDigits) { - if ( aStr2.GetChar( nDecDigits ) >= '5' ) - bRound = sal_True; - aStr2.Erase( nDecDigits ); + if (aStr2[nDecDigits] >= '5') + bRound = true; + string::truncateToLength(aStr2, nDecDigits); } - if ( aStr2.Len() < nDecDigits ) - aStr2.Expand( nDecDigits, '0' ); + if (aStr2.getLength() < nDecDigits) + string::padToLength(aStr2, nDecDigits, '0'); aStr = aStr1; - aStr += aStr2; + aStr += aStr2.makeStringAndClear(); // Bereichsueberpruefung BigInt nValue( aStr ); |