diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-09-13 10:44:38 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-09-13 11:05:27 +0200 |
commit | a37535e3ff7be959d9a3aab3399ffbcc89688662 (patch) | |
tree | 657f88722f0d93553344812a139baef672da0c83 /cui | |
parent | c488f3fc0c07a5c9ef0aed7f9d4e6447fc397292 (diff) |
Avoid getTokenCount
in SvxMultiPathDialog::SetPath and SvxPathSelectDialog::SetPath
Change-Id: I4d360caacf438949ccd9a90c4fec14a7e7d1c009
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/multipat.cxx | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index cd6dca3af00a..2b91b89066f2 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -29,7 +29,6 @@ #include <cuires.hrc> #include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> @@ -304,25 +303,26 @@ OUString SvxPathSelectDialog::GetPath() const void SvxMultiPathDialog::SetPath( const OUString& rPath ) { - sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; - sal_uInt16 nCount = comphelper::string::getTokenCount(rPath, cDelim); - - for ( sal_uInt16 i = 0; i < nCount; ++i ) + if ( !rPath.isEmpty() ) { - OUString sPath = rPath.getToken( i, cDelim ); - OUString sSystemPath; - bool bIsSystemPath = - osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; - - OUString sEntry( '\t' ); - sEntry += (bIsSystemPath ? sSystemPath : OUString(sPath)); - SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry ); - OUString* pURL = new OUString( sPath ); - pEntry->SetUserData( pURL ); - } + const sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; + sal_uLong nCount = 0; + sal_Int32 nIndex = 0; + do + { + const OUString sPath = rPath.getToken( 0, cDelim, nIndex ); + OUString sSystemPath; + bool bIsSystemPath = + osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; + + const OUString sEntry( "\t" + bIsSystemPath ? sSystemPath : sPath); + SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry ); + OUString* pURL = new OUString( sPath ); + pEntry->SetUserData( pURL ); + ++nCount; + } + while (nIndex >= 0); - if (nCount > 0) - { SvTreeListEntry* pEntry = m_pRadioLB->GetEntry( nCount - 1 ); if ( pEntry ) { @@ -337,17 +337,21 @@ void SvxMultiPathDialog::SetPath( const OUString& rPath ) void SvxPathSelectDialog::SetPath(const OUString& rPath) { sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; - sal_uInt16 nCount = comphelper::string::getTokenCount(rPath, cDelim); - for ( sal_uInt16 i = 0; i < nCount; ++i ) + if ( !rPath.isEmpty() ) { - OUString sPath = rPath.getToken( i, cDelim ); - OUString sSystemPath; - bool bIsSystemPath = - osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; + sal_Int32 nIndex = 0; + do + { + const OUString sPath = rPath.getToken( 0, cDelim, nIndex ); + OUString sSystemPath; + bool bIsSystemPath = + osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; - const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath ); - m_pPathLB->SetEntryData( nPos, new OUString( sPath ) ); + const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath ); + m_pPathLB->SetEntryData( nPos, new OUString( sPath ) ); + } + while (nIndex >= 0); } SelectHdl_Impl( NULL ); |