From 443a7229f96806e6bbece775cc7cd643e1c4a042 Mon Sep 17 00:00:00 2001 From: August Sodora Date: Mon, 28 Nov 2011 21:44:30 -0500 Subject: Remove uses of charAt --- basegfx/source/polygon/b2dsvgpolypolygon.cxx | 4 ++-- chart2/source/tools/TitleHelper.cxx | 2 +- chart2/source/view/main/ShapeFactory.cxx | 3 +-- connectivity/source/parse/sqlnode.cxx | 12 +++++----- dbaccess/source/filter/xml/xmlExport.cxx | 4 ++-- oox/source/xls/worksheetbuffer.cxx | 2 +- registry/source/keyimpl.cxx | 2 +- sal/rtl/source/uri.cxx | 2 +- .../ui/Accessibility/AccessibleCsvControl.cxx | 6 ++--- scaddins/source/datefunc/datefunc.cxx | 2 +- sdext/source/pdfimport/tree/writertreevisiting.cxx | 7 +++--- svl/source/misc/urihelper.cxx | 2 +- tools/source/fsys/urlobj.cxx | 13 +++++------ vcl/unx/x11/x11sys.cxx | 4 ++-- xmloff/source/style/xmlnumfi.cxx | 26 +++++++++++----------- 15 files changed, 45 insertions(+), 46 deletions(-) diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 931c3442001f..7a342195256a 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -190,9 +190,9 @@ namespace basegfx fValue -= fOldValue; const sal_Int32 aLen( rStr.getLength() ); - if(aLen) + if(aLen > 0) { - if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) && + if( lcl_isOnNumberChar(rStr[aLen - 1], false) && fValue >= 0.0 ) { rStr.append( sal_Unicode(' ') ); diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx index 09a4b1822c6d..7a7a6ae585b2 100644 --- a/chart2/source/tools/TitleHelper.cxx +++ b/chart2/source/tools/TitleHelper.cxx @@ -285,7 +285,7 @@ void TitleHelper::setCompleteString( const rtl::OUString& rNewText sal_Int32 nLen = rNewText.getLength(); for( sal_Int32 nPos = 0; nPos < nLen; ++nPos ) { - sal_Unicode aChar = aSource.charAt( nPos ); + sal_Unicode aChar = aSource[nPos]; if( aChar != '\n' ) { aUnstackedStr.append( aChar ); diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 40f25366eff3..e6ba468850cd 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2245,7 +2245,6 @@ rtl::OUString ShapeFactory::getStackedString( const rtl::OUString& rString, bool return rString; rtl::OUStringBuffer aStackStr; - rtl::OUStringBuffer aSource(rString); //add a newline after each letter //as we do not no letters here add a newline after each char @@ -2253,7 +2252,7 @@ rtl::OUString ShapeFactory::getStackedString( const rtl::OUString& rString, bool { if( nPosSrc ) aStackStr.append( sal_Unicode('\r') ); - aStackStr.append( aSource.charAt( nPosSrc ) ); + aStackStr.append(rString[nPosSrc]); } return aStackStr.makeStringAndClear(); } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 5571bb6463b1..dfc37969f1cc 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2464,15 +2464,15 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode rString.append(SetQuotation(m_aNodeValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\'")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\'\'")))); break; case SQL_NODE_NAME: - if (rString.getLength()) + if (rString.getLength() > 0) { - switch(rString.charAt(rString.getLength()-1) ) + switch(rString[rString.getLength()-1]) { case ' ' : case '.' : break; default : if ( !rParam.aMetaData.getCatalogSeparator().getLength() - || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar() + || rString[rString.getLength() - 1] != rParam.aMetaData.getCatalogSeparator().toChar() ) rString.appendAscii(" "); break; } @@ -2520,15 +2520,15 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode } // fall through default: - if (rString.getLength() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' ) + if (rString.getLength() > 0 && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' ) { - switch( rString.charAt(rString.getLength()-1) ) + switch( rString[rString.getLength() - 1] ) { case ' ' : case '.' : break; default : if ( !rParam.aMetaData.getCatalogSeparator().getLength() - || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar() + || rString[rString.getLength() - 1] != rParam.aMetaData.getCatalogSeparator().toChar() ) rString.appendAscii(" "); break; } diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 6f0505828897..50bf0b1598f2 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -565,8 +565,8 @@ void ODBExport::exportConnectionData() { ::svt::OFileNotation aTransformer( sFileName ); ::rtl::OUStringBuffer sURL( aTransformer.get( ::svt::OFileNotation::N_URL ) ); - if ( sURL.charAt(sURL.getLength()-1) != '/' ) - sURL.append(sal_Unicode('/')); + if (sURL[sURL.getLength() - 1] != '/') + sURL.append('/'); AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,GetRelativeReference(sURL.makeStringAndClear())); } diff --git a/oox/source/xls/worksheetbuffer.cxx b/oox/source/xls/worksheetbuffer.cxx index 0214da3a286c..84ffb4c955b8 100644 --- a/oox/source/xls/worksheetbuffer.cxx +++ b/oox/source/xls/worksheetbuffer.cxx @@ -183,7 +183,7 @@ OUString lclQuoteName( const OUString& rName ) OUStringBuffer aBuffer( rName ); // duplicate all quote characters for( sal_Int32 nPos = aBuffer.getLength() - 1; nPos >= 0; --nPos ) - if( aBuffer.charAt( nPos ) == '\'' ) + if( aBuffer[nPos] == '\'' ) aBuffer.insert( nPos, sal_Unicode( '\'' ) ); // add outer quotes and return return aBuffer.insert( 0, sal_Unicode( '\'' ) ).append( sal_Unicode( '\'' ) ).makeStringAndClear(); diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx index 1ff5cb672480..6657cb3f5fb7 100644 --- a/registry/source/keyimpl.cxx +++ b/registry/source/keyimpl.cxx @@ -1061,7 +1061,7 @@ OStoreDirectory ORegKey::getStoreDir() OUString ORegKey::getFullPath(OUString const & path) const { OSL_ASSERT(m_name.getLength() != 0 && path.getLength() != 0); OUStringBuffer b(m_name); - if (b.charAt(b.getLength() - 1) == '/') { + if (b.getLength() > 0 && b[b.getLength() - 1] == '/') { if (path[0] == '/') { b.append(path.getStr() + 1, path.getLength() - 1); } else { diff --git a/sal/rtl/source/uri.cxx b/sal/rtl/source/uri.cxx index 89107df17c7b..af5da83e785f 100644 --- a/sal/rtl/source/uri.cxx +++ b/sal/rtl/source/uri.cxx @@ -495,7 +495,7 @@ rtl::OUString joinPaths(Component const & rBasePath, Component const & rRelPath) } else { - while (aBuffer.charAt(i - 1) != '/') + while (i > 0 && aBuffer[i - 1] != '/') --i; aBuffer.setLength(i); } diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx index 433385efcf39..14c5c0964537 100644 --- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx +++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx @@ -464,7 +464,7 @@ sal_Unicode SAL_CALL ScAccessibleCsvRuler::getCharacter( sal_Int32 nIndex ) SolarMutexGuard aGuard; ensureAlive(); ensureValidIndex( nIndex ); - return maBuffer.charAt( nIndex ); + return maBuffer[nIndex]; } Sequence< PropertyValue > SAL_CALL ScAccessibleCsvRuler::getCharacterAttributes( sal_Int32 nIndex, @@ -579,7 +579,7 @@ TextSegment SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal case AccessibleTextType::CHARACTER: { aResult.SegmentStart = nIndex; - aResultText.append( maBuffer.charAt( nIndex ) ); + aResultText.append(maBuffer[nIndex]); } break; @@ -588,7 +588,7 @@ TextSegment SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal case AccessibleTextType::GLYPH: aResult.SegmentStart = nIndex; if( nRulerPos % 10 ) - aResultText.append( maBuffer.charAt( nIndex ) ); + aResultText.append(maBuffer[nIndex]); else aResultText.append( nRulerPos ); // string representation of sal_Int32!!! break; diff --git a/scaddins/source/datefunc/datefunc.cxx b/scaddins/source/datefunc/datefunc.cxx index 6c5d0fa72b78..e3d11bdbbb0c 100644 --- a/scaddins/source/datefunc/datefunc.cxx +++ b/scaddins/source/datefunc/datefunc.cxx @@ -948,7 +948,7 @@ OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( un OUStringBuffer aBuffer( aSrcString ); for( sal_Int32 nIndex = 0; nIndex < aBuffer.getLength(); nIndex++ ) { - sal_Unicode cChar = aBuffer.charAt( nIndex ); + sal_Unicode cChar = aBuffer[nIndex]; if( ((cChar >= 'a') && (cChar <= 'z') && ((cChar += 13) > 'z')) || ((cChar >= 'A') && (cChar <= 'Z') && ((cChar += 13) > 'Z')) ) cChar -= 26; diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index 8cda4a5ff1f2..310c13327ad7 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -759,9 +759,10 @@ void WriterXmlOptimizer::optimizeTextElements(Element& rParent) if( !bRotatedFrame && ! rCurGC.isRotatedOrSkewed() && ! rNextGC.isRotatedOrSkewed() - && pNext->Text.charAt( 0 ) != sal_Unicode(' ') + && pNext->Text.gerLength() > 0 + && pNext->Text[0] != sal_Unicode(' ') && pCur->Text.getLength() > 0 - && pCur->Text.charAt( pCur->Text.getLength()-1 ) != sal_Unicode(' ') + && pCur->Text[pCur->Text.getLength() - 1] != sal_Unicode(' ') ) { // check for new line in paragraph @@ -769,7 +770,7 @@ void WriterXmlOptimizer::optimizeTextElements(Element& rParent) { // new line begins // check whether a space would should be inserted or a hyphen removed - sal_Unicode aLastCode = pCur->Text.charAt( pCur->Text.getLength()-1 ); + sal_Unicode aLastCode = pCur->Text[pCur->Text.getLength() - 1]; if( aLastCode == '-' || aLastCode == 0x2010 || (aLastCode >= 0x2012 && aLastCode <= 0x2015) diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index 1f77417e264f..e2de352ac8da 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -265,7 +265,7 @@ rtl::OUString normalize( if (preCount == i - 1) { buf.append(static_cast< sal_Unicode >('/')); } else if (preCount - 1 == i && buf.getLength() > 0 - && buf.charAt(buf.getLength() - 1) == '/') + && buf[buf.getLength() - 1] == '/') { buf.setLength(buf.getLength() - 1); } else { diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 4af5f7ea5387..40eb94691131 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1777,7 +1777,7 @@ bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef, sal_Int32 nPathBegin = aSynAbsURIRef.getLength(); aSynAbsURIRef.append(pBasePathBegin, pBasePathEnd - pBasePathBegin); DBG_ASSERT(aSynAbsURIRef.getLength() > nPathBegin - && aSynAbsURIRef.charAt(aSynAbsURIRef.getLength() - 1) == '/', + && aSynAbsURIRef[aSynAbsURIRef.getLength() - 1] == '/', "INetURLObject::convertRelToAbs(): Bad base path"); while (p != pEnd && *p != nQueryDelimiter && *p != nFragmentDelimiter) @@ -1807,13 +1807,12 @@ bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef, ++p; sal_Int32 i = aSynAbsURIRef.getLength() - 2; - while (i > nPathBegin && aSynAbsURIRef.charAt(i) != '/') + while (i > nPathBegin && aSynAbsURIRef[i] != '/') --i; aSynAbsURIRef.setLength(i + 1); DBG_ASSERT( aSynAbsURIRef.getLength() > nPathBegin - && aSynAbsURIRef.charAt(aSynAbsURIRef.getLength() - 1) - == '/', + && aSynAbsURIRef[aSynAbsURIRef.getLength() - 1] == '/', "INetURLObject::convertRelToAbs(): Bad base path"); continue; } @@ -2275,8 +2274,8 @@ sal_Int32 INetURLObject::getAuthorityBegin() const else nBegin = m_aPath.getBegin(); nBegin -= RTL_CONSTASCII_LENGTH("//"); - DBG_ASSERT(m_aAbsURIRef.charAt(nBegin) == '/' - && m_aAbsURIRef.charAt(nBegin + 1) == '/', + DBG_ASSERT(m_aAbsURIRef.getStr()[nBegin] == '/' + && m_aAbsURIRef.getStr()[nBegin + 1] == '/', "INetURLObject::getAuthority(): Bad authority"); return nBegin; } @@ -3044,7 +3043,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, || *pPos == nSegmentDelimiter || *pPos == nAltSegmentDelimiter) && aTheSynPath.getLength() == 2 - && INetMIME::isAlpha(aTheSynPath.charAt(1))) + && INetMIME::isAlpha(aTheSynPath[1])) { // A first segment of is translated to // : diff --git a/vcl/unx/x11/x11sys.cxx b/vcl/unx/x11/x11sys.cxx index e9dbc374faa8..522aeecfae85 100644 --- a/vcl/unx/x11/x11sys.cxx +++ b/vcl/unx/x11/x11sys.cxx @@ -124,10 +124,10 @@ rtl::OUString X11SalSystem::GetScreenName( unsigned int nScreen ) int nPos = aBuf.getLength(); if( nPos > 0 ) nPos--; - while( nPos > 0 && aBuf.charAt( nPos ) != ':' ) + while( nPos > 0 && aBuf[nPos] != ':' ) nPos--; // search forward to '.' - while( nPos < aBuf.getLength() && aBuf.charAt( nPos ) != '.' ) + while( nPos < aBuf.getLength() && aBuf[nPos] != '.' ) nPos++; if( nPos < aBuf.getLength() ) aBuf.setLength( nPos+1 ); diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 824e883ccd6c..56a4dc66c152 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -823,10 +823,10 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat sal_Int32 nLength = rContent.getLength(); if ( ( nLength == 1 && - lcl_ValidChar( rContent.charAt(0), rParent ) ) || + lcl_ValidChar( rContent[0], rParent ) ) || ( nLength == 2 && - lcl_ValidChar( rContent.charAt(0), rParent ) && - rContent.charAt(1) == ' ' ) ) + lcl_ValidChar( rContent[0], rParent ) && + rContent[1] == ' ' ) ) { // don't quote single separator characters like space or percent, // or separator characters followed by space (used in date formats) @@ -843,7 +843,7 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat { if ( nPos + 1 < nLength ) { - if ( nPos + 2 == nLength && lcl_ValidChar( rContent.charAt(nPos + 1), rParent ) ) + if ( nPos + 2 == nLength && lcl_ValidChar( rContent[nPos + 1], rParent ) ) { // single character that doesn't need quoting } @@ -856,7 +856,7 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat } if ( nPos > 0 ) { - if ( nPos == 1 && lcl_ValidChar( rContent.charAt(0), rParent ) ) + if ( nPos == 1 && lcl_ValidChar( rContent[0], rParent ) ) { // single character that doesn't need quoting } @@ -886,7 +886,7 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat sal_Int32 nPos = 0; while ( nPos < rContent.getLength() ) { - if ( rContent.charAt( nPos ) == (sal_Unicode) '"' ) + if ( rContent[nPos] == (sal_Unicode) '"' ) { rContent.insert( nPos, aInsert ); nPos += aInsert.getLength(); @@ -903,8 +903,8 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat if ( bEscape ) { if ( rContent.getLength() > 2 && - rContent.charAt(0) == (sal_Unicode) '"' && - rContent.charAt(1) == (sal_Unicode) '"' ) + rContent[0] == (sal_Unicode) '"' && + rContent[1] == (sal_Unicode) '"' ) { String aTrimmed( rContent.makeStringAndClear().copy(2) ); rContent = rtl::OUStringBuffer( aTrimmed ); @@ -912,8 +912,8 @@ void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNumFormat sal_Int32 nLen = rContent.getLength(); if ( nLen > 2 && - rContent.charAt(nLen-1) == (sal_Unicode) '"' && - rContent.charAt(nLen-2) == (sal_Unicode) '"' ) + rContent[nLen - 1] == (sal_Unicode) '"' && + rContent[nLen - 2] == (sal_Unicode) '"' ) { String aTrimmed( rContent.makeStringAndClear().copy( 0, nLen - 2 ) ); rContent = rtl::OUStringBuffer( aTrimmed ); @@ -1873,14 +1873,14 @@ void SvXMLNumFormatContext::AddCurrency( const rtl::OUString& rContent, Language // otherwise the currency symbol isn't recognized (#94048#) sal_Int32 nLength = aFormatCode.getLength(); - if ( nLength > 1 && aFormatCode.charAt( nLength-1 ) == '"' ) + if ( nLength > 1 && aFormatCode[nLength - 1] == '"' ) { // find start of quoted string // When SvXMLNumFmtElementContext::EndElement creates escaped quotes, // they must be handled here, too. sal_Int32 nFirst = nLength - 2; - while ( nFirst >= 0 && aFormatCode.charAt( nFirst ) != '"' ) + while ( nFirst >= 0 && aFormatCode[nFirst] != '"' ) --nFirst; if ( nFirst >= 0 ) { @@ -1982,7 +1982,7 @@ sal_Bool lcl_IsAtEnd( rtl::OUStringBuffer& rBuffer, const String& rToken ) sal_Int32 nStartPos = nBufLen - nTokLen; for ( xub_StrLen nTokPos = 0; nTokPos < nTokLen; nTokPos++ ) - if ( rToken.GetChar( nTokPos ) != rBuffer.charAt( nStartPos + nTokPos ) ) + if ( rToken.GetChar( nTokPos ) != rBuffer[nStartPos + nTokPos] ) return sal_False; return sal_True; -- cgit