Remove uses of OUString::setCharAt

This commit is contained in:
August Sodora
2011-11-26 02:03:23 -05:00
committed by Thorsten Behrens
parent b1447d6466
commit 13673b71bc
3 changed files with 31 additions and 31 deletions

View File

@@ -85,13 +85,13 @@ static rtl::OUString ImpCurrencyToString( const sal_Int64 &rVal )
for ( sal_Int32 charCpyIndex = aAbsStr.getLength() - 1; nInsertIndex >= nEndIndex; ++nDigitCount ) for ( sal_Int32 charCpyIndex = aAbsStr.getLength() - 1; nInsertIndex >= nEndIndex; ++nDigitCount )
{ {
if ( nDigitCount == 4 ) if ( nDigitCount == 4 )
aBuf.setCharAt( nInsertIndex--, cDecimalSep ); aBuf[nInsertIndex--] = cDecimalSep;
#if MAYBEFUTURE #if MAYBEFUTURE
if ( nDigitCount > 4 && ! ( ( nDigitCount - 4 ) % 3) ) if ( nDigitCount > 4 && ! ( ( nDigitCount - 4 ) % 3) )
aBuf.setCharAt( nInsertIndex--, cThousandSep ); aBuf[nInsertIndex--] = cThousandSep;
#endif #endif
if ( nDigitCount < initialLen ) if ( nDigitCount < initialLen )
aBuf.setCharAt( nInsertIndex--, aAbsStr[ charCpyIndex-- ] ); aBuf[nInsertIndex--] = aAbsStr[ charCpyIndex-- ];
else else
// Handle leading 0's to right of decimal point // Handle leading 0's to right of decimal point
// Note: in VBA the stringification is a little more complex // Note: in VBA the stringification is a little more complex
@@ -104,10 +104,10 @@ static rtl::OUString ImpCurrencyToString( const sal_Int64 &rVal )
// 0 0.0000 0 // 0 0.0000 0
// 0.1 0.1000 0.1 // 0.1 0.1000 0.1
aBuf.setCharAt( nInsertIndex--, (sal_Unicode)'0' ); aBuf[nInsertIndex--] = (sal_Unicode)'0';
} }
if ( isNeg ) if ( isNeg )
aBuf.setCharAt( nInsertIndex, (sal_Unicode)'-' ); aBuf[nInsertIndex] = (sal_Unicode)'-';
aAbsStr = aBuf.makeStringAndClear(); aAbsStr = aBuf.makeStringAndClear();
return aAbsStr; return aAbsStr;

View File

@@ -73,16 +73,16 @@ rtl::OUString encodeBase64( const sal_Int8* i_pBuffer, const sal_uInt32 i_nBuffe
aBuf.appendAscii("===="); aBuf.appendAscii("====");
sal_uInt8 nIndex (static_cast<sal_uInt8>((nBinary & 0xFC0000) >> 18)); sal_uInt8 nIndex (static_cast<sal_uInt8>((nBinary & 0xFC0000) >> 18));
aBuf.setCharAt(nBufPos, aBase64EncodeTable [nIndex]); aBuf[nBufPos] = aBase64EncodeTable [nIndex];
nIndex = static_cast<sal_uInt8>((nBinary & 0x3F000) >> 12); nIndex = static_cast<sal_uInt8>((nBinary & 0x3F000) >> 12);
aBuf.setCharAt(nBufPos+1, aBase64EncodeTable [nIndex]); aBuf[nBufPos+1] = aBase64EncodeTable [nIndex];
nIndex = static_cast<sal_uInt8>((nBinary & 0xFC0) >> 6); nIndex = static_cast<sal_uInt8>((nBinary & 0xFC0) >> 6);
aBuf.setCharAt(nBufPos+2, aBase64EncodeTable [nIndex]); aBuf[nBufPos+2] = aBase64EncodeTable [nIndex];
nIndex = static_cast<sal_uInt8>((nBinary & 0x3F)); nIndex = static_cast<sal_uInt8>((nBinary & 0x3F));
aBuf.setCharAt(nBufPos+3, aBase64EncodeTable [nIndex]); aBuf[nBufPos+3] = aBase64EncodeTable [nIndex];
} }
if( nRemain > 0 ) if( nRemain > 0 )
{ {
@@ -98,15 +98,15 @@ rtl::OUString encodeBase64( const sal_Int8* i_pBuffer, const sal_uInt32 i_nBuffe
break; break;
} }
sal_uInt8 nIndex (static_cast<sal_uInt8>((nBinary & 0xFC0000) >> 18)); sal_uInt8 nIndex (static_cast<sal_uInt8>((nBinary & 0xFC0000) >> 18));
aBuf.setCharAt(nBufPos, aBase64EncodeTable [nIndex]); aBuf[nBufPos] = aBase64EncodeTable [nIndex];
nIndex = static_cast<sal_uInt8>((nBinary & 0x3F000) >> 12); nIndex = static_cast<sal_uInt8>((nBinary & 0x3F000) >> 12);
aBuf.setCharAt(nBufPos+1, aBase64EncodeTable [nIndex]); aBuf[nBufPos+1] = aBase64EncodeTable [nIndex];
if( nRemain == 2 ) if( nRemain == 2 )
{ {
nIndex = static_cast<sal_uInt8>((nBinary & 0xFC0) >> 6); nIndex = static_cast<sal_uInt8>((nBinary & 0xFC0) >> 6);
aBuf.setCharAt(nBufPos+2, aBase64EncodeTable [nIndex]); aBuf[nBufPos+2] = aBase64EncodeTable [nIndex];
} }
} }

View File

@@ -224,9 +224,9 @@ void lcl_SwapQuotesInField(::rtl::OUString &rFmt)
for (sal_Int32 nI = 0; nI < nLen; ++nI) for (sal_Int32 nI = 0; nI < nLen; ++nI)
{ {
if ((pFmt[nI] == '\"') && (!nI || pFmt[nI-1] != '\\')) if ((pFmt[nI] == '\"') && (!nI || pFmt[nI-1] != '\\'))
aBuffer.setCharAt(nI, '\''); aBuffer[nI] = '\'';
else if ((pFmt[nI] == '\'') && (!nI || pFmt[nI-1] != '\\')) else if ((pFmt[nI] == '\'') && (!nI || pFmt[nI-1] != '\\'))
aBuffer.setCharAt(nI, '\"'); aBuffer[nI] = '\"';
} }
rFmt = aBuffer.makeStringAndClear(); rFmt = aBuffer.makeStringAndClear();
} }
@@ -235,8 +235,8 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
return ( return (
(nPos == rFmt.getLength() - 1) || (nPos == rFmt.getLength() - 1) ||
( (
(rFmt.getStr()[nPos+1] != 'M') && (rFmt[nPos+1] != 'M') &&
(rFmt.getStr()[nPos+1] != 'm') (rFmt[nPos+1] != 'm')
) )
); );
} }
@@ -253,34 +253,34 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
sal_Int32 nLen = sFormat.getLength(); sal_Int32 nLen = sFormat.getLength();
sal_Int32 nI = 0; sal_Int32 nI = 0;
// const sal_Unicode* pFormat = sFormat.getStr(); // const sal_Unicode* pFormat = sFormat.getStr();
::rtl::OUStringBuffer aNewFormat( sFormat.getStr() ); ::rtl::OUStringBuffer aNewFormat( sFormat );
while (nI < nLen) while (nI < nLen)
{ {
if (aNewFormat.charAt(nI) == '\\') if (aNewFormat[nI] == '\\')
nI++; nI++;
else if (aNewFormat.charAt(nI) == '\"') else if (aNewFormat[nI] == '\"')
{ {
++nI; ++nI;
//While not at the end and not at an unescaped end quote //While not at the end and not at an unescaped end quote
while ((nI < nLen) && (!(aNewFormat.charAt(nI) == '\"') && (aNewFormat.charAt(nI-1) != '\\'))) while ((nI < nLen) && (!(aNewFormat[nI] == '\"') && (aNewFormat[nI-1] != '\\')))
++nI; ++nI;
} }
else //normal unquoted section else //normal unquoted section
{ {
sal_Unicode nChar = aNewFormat.charAt(nI); sal_Unicode nChar = aNewFormat[nI];
if (nChar == 'O') if (nChar == 'O')
{ {
aNewFormat.setCharAt(nI, 'M'); aNewFormat[nI] = 'M';
bForceNatNum = true; bForceNatNum = true;
} }
else if (nChar == 'o') else if (nChar == 'o')
{ {
aNewFormat.setCharAt(nI, 'm'); aNewFormat[nI] = 'm';
bForceNatNum = true; bForceNatNum = true;
} }
else if ((nChar == 'A') && lcl_IsNotAM(sFormat, nI)) else if ((nChar == 'A') && lcl_IsNotAM(sFormat, nI))
{ {
aNewFormat.setCharAt(nI, 'D'); aNewFormat[nI] = 'D';
bForceNatNum = true; bForceNatNum = true;
} }
else if ((nChar == 'g') || (nChar == 'G')) else if ((nChar == 'g') || (nChar == 'G'))
@@ -289,11 +289,11 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
bForceJapanese = true; bForceJapanese = true;
else if (nChar == 'E') else if (nChar == 'E')
{ {
if ((nI != nLen-1) && (aNewFormat.charAt(nI+1) == 'E')) if ((nI != nLen-1) && (aNewFormat[nI+1] == 'E'))
{ {
//todo: this cannot be the right way to replace a part of the string! //todo: this cannot be the right way to replace a part of the string!
aNewFormat.setCharAt( nI, 'Y' ); aNewFormat[nI] = 'Y';
aNewFormat.setCharAt( nI + 1, 'Y' ); aNewFormat[nI + 1] = 'Y';
aNewFormat.insert(nI + 2, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YY"))); aNewFormat.insert(nI + 2, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YY")));
nLen+=2; nLen+=2;
nI+=3; nI+=3;
@@ -302,11 +302,11 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
} }
else if (nChar == 'e') else if (nChar == 'e')
{ {
if ((nI != nLen-1) && (aNewFormat.charAt(nI+1) == 'e')) if ((nI != nLen-1) && (aNewFormat[nI+1] == 'e'))
{ {
//todo: this cannot be the right way to replace a part of the string! //todo: this cannot be the right way to replace a part of the string!
aNewFormat.setCharAt( nI, 'y' ); aNewFormat[nI] = 'y';
aNewFormat.setCharAt( nI + 1, 'y' ); aNewFormat[nI + 1] = 'y';
aNewFormat.insert(nI + 2, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("yy"))); aNewFormat.insert(nI + 2, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("yy")));
nLen+=2; nLen+=2;
nI+=3; nI+=3;
@@ -317,7 +317,7 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
{ {
// MM We have to escape '/' in case it's used as a char // MM We have to escape '/' in case it's used as a char
//todo: this cannot be the right way to replace a part of the string! //todo: this cannot be the right way to replace a part of the string!
aNewFormat.setCharAt( nI, '\\' ); aNewFormat[nI] = '\\';
aNewFormat.insert(nI + 1, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"))); aNewFormat.insert(nI + 1, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")));
nI++; nI++;
nLen++; nLen++;