summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-10-21 10:21:01 +0200
committerNoel Grandin <noel@peralex.com>2013-10-23 08:29:15 +0200
commit7a06928bcf638e1eeedebc9d53c306a1b852cc9b (patch)
treec0402c2da4e2c522ecf32a0b413128f727cbc0fa /svtools
parenta55d02bacb2c8f21cba759c8fe3931df07a85b0c (diff)
convert code to use OUString::endsWith
Convert places that call aStr[aStr.getLength()-1] == 'x' to use the shorter form aStr.endsWith("x") Change-Id: I1b3a19c0e89b8989cdbeed440f95fc76f9a4b6b6
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/inettbc.cxx22
-rw-r--r--svtools/source/svhtml/htmlsupp.cxx6
-rw-r--r--svtools/source/svhtml/parhtml.cxx11
3 files changed, 17 insertions, 22 deletions
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index 00dbfbb21d45..ec9de0deba67 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -240,7 +240,7 @@ IMPL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void*, )
// note: if this doesn't work, we're not interested in: we're checking the
// untouched sCompletion then
- if ( !sURL.isEmpty() && ( sURL[sURL.getLength()-1] != '/' ))
+ if ( !sURL.isEmpty() && !sURL.endsWith("/") )
{
OUString sUpperURL( sURL.toAsciiUpperCase() );
@@ -316,9 +316,9 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL,
#endif
sal_Bool bExectMatch = bPureHomePath
- || aText.compareTo( "." ) == 0
- || (aText.getLength() > 1 && aText.copy( aText.getLength() - 2, 2 ).compareTo( "/." ) == 0)
- || (aText.getLength() > 2 && aText.copy( aText.getLength() - 3, 3 ).compareTo( "/.." ) == 0);
+ || aText == "."
+ || aText.endsWith("/.")
+ || aText.endsWith("/..");
// for pure home paths ( ~username ) the '.' at the end of rMatch
// means that it poits to root catalog
@@ -346,7 +346,7 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL,
aMatchName = aMatchName.toAsciiLowerCase();
// if the matchstring ends with a slash, we must search for this also
- if ( rMatch[ rMatch.getLength()-1 ] == '/' )
+ if ( rMatch.endsWith("/") )
aMatchName += "/";
}
@@ -435,7 +435,7 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL,
OUString aInput( aText );
if ( nMatchLen )
{
- if ((aText.getLength() && aText[ aText.getLength() - 1 ] == '.') || bPureHomePath)
+ if (aText.endsWith(".") || bPureHomePath)
{
// if a "special folder" URL was typed, don't touch the user input
aMatch = aMatch.copy( nMatchLen );
@@ -508,7 +508,7 @@ OUString SvtURLBox::ParseSmart( OUString aText, OUString aBaseURL, const OUStrin
// HRO: INetURLObject::smatRel2Abs does not recognize '\\' as a relative path
// but in case of "\\\\" INetURLObject is right - this is an absolute path !
- if( aText.indexOf( '\\' ) == 0 && (aText.getLength() < 2 || aText[ 1 ] != '\\') )
+ if( aText.startsWith("\\") && (aText.getLength() < 2 || aText[ 1 ] != '\\') )
{
// cut to first segment
OUString aTmp = INetURLObject::GetScheme( eBaseProt );
@@ -535,7 +535,7 @@ OUString SvtURLBox::ParseSmart( OUString aText, OUString aBaseURL, const OUStrin
INetURLObject aTmp( aObj.smartRel2Abs( aSmart, bWasAbsolute ) );
#endif
- if ( aText[ aText.getLength() - 1 ] == '.' )
+ if ( aText.endsWith(".") )
// INetURLObject appends a final slash for the directories "." and "..", this is a bug!
// Remove it as a workaround
aTmp.removeFinalSlash();
@@ -788,7 +788,7 @@ void SvtMatchContext_Impl::doExecute()
if( bFull )
continue;
- if( aText.compareTo( aCurMainURL, aText.getLength() ) == 0 )
+ if( aCurMainURL.startsWith(aText) )
{
if( aText.getLength() < aCurMainURL.getLength() )
Insert( aCurMainURL, aCurMainURL );
@@ -978,7 +978,7 @@ void SvtURLBox::UpdatePicklistForSmartProtocol_Impl()
if ( !aURL.isEmpty() )
{
- sal_Bool bFound = aURL[aURL.getLength()-1] == '/' ;
+ sal_Bool bFound = aURL.endsWith("/");
if ( !bFound )
{
OUString aUpperURL( aURL );
@@ -1363,7 +1363,7 @@ sal_Bool SvtURLBox_Impl::TildeParsing(
}
else
{
- if( aParseTilde[ aParseTilde.getLength() - 1 ] != '/' )
+ if( !aParseTilde.endsWith("/") )
aParseTilde += "/";
if( aText.getLength() > 2 )
aParseTilde += aText.copy( 2 );
diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx
index 829e8f3b2a19..f1de1c0e3313 100644
--- a/svtools/source/svhtml/htmlsupp.cxx
+++ b/svtools/source/svhtml/htmlsupp.cxx
@@ -96,8 +96,7 @@ void HTMLParser::RemoveSGMLComment( OUString &rString, sal_Bool bFull )
// remove SGML comments
- if( rString.getLength() >= 4 &&
- rString.startsWith( "<!--" ) )
+ if( rString.startsWith( "<!--" ) )
{
sal_Int32 nPos = 3;
if( bFull )
@@ -117,8 +116,7 @@ void HTMLParser::RemoveSGMLComment( OUString &rString, sal_Bool bFull )
rString = rString.copy( nPos, rString.getLength() - nPos );
}
- if( rString.getLength() >=3 &&
- rString.endsWith("-->") )
+ if( rString.endsWith("-->") )
{
rString = rString.copy( 0, rString.getLength()-3 );
if( bFull )
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index b7292594c523..dd90ac37d79b 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -907,8 +907,7 @@ int HTMLParser::_GetNextRawToken()
: aTok.compareTo(aEndToken) );
}
}
- if( bReadComment && '>'==nNextCh && aTok.getLength() >= 2 &&
- aTok.endsWith( "--" ) )
+ if( bReadComment && '>'==nNextCh && aTok.endsWith( "--" ) )
{
// End of comment of style <!----->
bReadComment = false;
@@ -1214,8 +1213,7 @@ int HTMLParser::_GetNextToken()
// generate pending HTML_<TOKEN>_OFF for HTML_<TOKEN>_ON
// Do not convert this to a single HTML_<TOKEN>_OFF
// which lead to fdo#56772.
- if ((HTML_TOKEN_ONOFF & nRet) && (aToken.getLength() >= 1) &&
- ('/' == aToken[aToken.getLength()-1]))
+ if ((HTML_TOKEN_ONOFF & nRet) && aToken.endsWith("/"))
{
mnPendingOffToken = nRet + 1; // HTML_<TOKEN>_ON -> HTML_<TOKEN>_OFF
aToken = aToken.replaceAt( aToken.getLength()-1, 1, ""); // remove trailing '/'
@@ -1275,8 +1273,7 @@ int HTMLParser::_GetNextToken()
// Read until closing %>. If not found restart at first >.
while( !bDone && !rInput.IsEof() && IsParserWorking() )
{
- bDone = '>'==nNextCh && aToken.getLength() >= 1 &&
- '%' == aToken[ aToken.getLength()-1 ];
+ bDone = '>'==nNextCh && aToken.endsWith("%");
if( !bDone )
{
aToken += OUString(nNextCh);
@@ -2127,7 +2124,7 @@ bool HTMLParser::ParseMetaOptionsImpl(
if ( bHTTPEquiv && i_pHTTPHeader )
{
// Netscape seems to just ignore a closing ", so we do too
- if ( !aContent.isEmpty() && '"' == aContent[ aContent.getLength()-1 ] )
+ if ( aContent.endsWith("\"") )
{
aContent = aContent.copy( 0, aContent.getLength() - 1 );
}