diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-02 10:55:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-05 09:18:19 +0000 |
commit | bacfd2dc4cea1a5d87658ed8592116acd931e000 (patch) | |
tree | d22172a33fdd13a440b6882a28c23ea2d639bbad /unotools | |
parent | 6281eb0e0792da0194c07da18296e94dd944b8e5 (diff) |
add a comphelper::string::getTokenCount
suitable for conversion from [Byte]String::GetTokenCount
converted low-hanging variants to rtl::O[UString]::getToken loops
added unit test
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/pathoptions.cxx | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx index 1411d79d3f0c..463d90315045 100644 --- a/unotools/source/config/pathoptions.cxx +++ b/unotools/source/config/pathoptions.cxx @@ -877,7 +877,7 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) return sal_False; } - String aIniFile = pImp->SubstVar( rIniFile ); + rtl::OUString aIniFile = pImp->SubstVar( rIniFile ); sal_Bool bRet = sal_False; switch ( ePath ) @@ -887,9 +887,14 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) // path is a URL bRet = sal_True; INetURLObject aObj( GetUserConfigPath() ); - xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' ); - for ( i = 0; i < nCount; ++i ) - aObj.insertName( aIniFile.GetToken( i, '/' ) ); + + sal_Int32 nIniIndex = 0; + do + { + rtl::OUString aToken = aIniFile.getToken( 0, '/', nIniIndex ); + aObj.insertName(aToken); + } + while ( nIniIndex >= 0 ); if ( !::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) ) { @@ -906,7 +911,7 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) default: { - String aPath; + rtl::OUString aPath; switch ( ePath ) { case PATH_ADDIN: aPath = GetAddinPath(); break; @@ -936,11 +941,11 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) case PATH_COUNT: /*-Wall???*/ break; } - sal_uInt16 j, nIdx = 0, nTokenCount = aPath.GetTokenCount( SEARCHPATH_DELIMITER ); - for ( j = 0; j < nTokenCount; ++j ) + sal_Int32 nPathIndex = 0; + do { sal_Bool bIsURL = sal_True; - String aPathToken = aPath.GetToken( 0, SEARCHPATH_DELIMITER, nIdx ); + rtl::OUString aPathToken = aPath.getToken( 0, SEARCHPATH_DELIMITER, nPathIndex ); INetURLObject aObj( aPathToken ); if ( aObj.HasError() ) { @@ -961,9 +966,14 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) } } - xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' ); - for ( i = 0; i < nCount; ++i ) - aObj.insertName( aIniFile.GetToken( i, '/' ) ); + sal_Int32 nIniIndex = 0; + do + { + rtl::OUString aToken = aIniFile.getToken( 0, '/', nIniIndex ); + aObj.insertName(aToken); + } + while ( nIniIndex >= 0 ); + bRet = ::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) ); if ( bRet ) @@ -976,6 +986,7 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) break; } } + while ( nPathIndex >= 0 ); } } |