Kaydet (Commit) a37535e3 authored tarafından Matteo Casalin's avatar Matteo Casalin

Avoid getTokenCount

in SvxMultiPathDialog::SetPath and SvxPathSelectDialog::SetPath

Change-Id: I4d360caacf438949ccd9a90c4fec14a7e7d1c009
üst c488f3fc
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <cuires.hrc> #include <cuires.hrc>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
...@@ -304,25 +303,26 @@ OUString SvxPathSelectDialog::GetPath() const ...@@ -304,25 +303,26 @@ OUString SvxPathSelectDialog::GetPath() const
void SvxMultiPathDialog::SetPath( const OUString& rPath ) void SvxMultiPathDialog::SetPath( const OUString& rPath )
{ {
sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; if ( !rPath.isEmpty() )
sal_uInt16 nCount = comphelper::string::getTokenCount(rPath, cDelim); {
const sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER;
for ( sal_uInt16 i = 0; i < nCount; ++i ) sal_uLong nCount = 0;
sal_Int32 nIndex = 0;
do
{ {
OUString sPath = rPath.getToken( i, cDelim ); const OUString sPath = rPath.getToken( 0, cDelim, nIndex );
OUString sSystemPath; OUString sSystemPath;
bool bIsSystemPath = bool bIsSystemPath =
osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
OUString sEntry( '\t' ); const OUString sEntry( "\t" + bIsSystemPath ? sSystemPath : sPath);
sEntry += (bIsSystemPath ? sSystemPath : OUString(sPath));
SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry ); SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry );
OUString* pURL = new OUString( sPath ); OUString* pURL = new OUString( sPath );
pEntry->SetUserData( pURL ); pEntry->SetUserData( pURL );
++nCount;
} }
while (nIndex >= 0);
if (nCount > 0)
{
SvTreeListEntry* pEntry = m_pRadioLB->GetEntry( nCount - 1 ); SvTreeListEntry* pEntry = m_pRadioLB->GetEntry( nCount - 1 );
if ( pEntry ) if ( pEntry )
{ {
...@@ -337,11 +337,13 @@ void SvxMultiPathDialog::SetPath( const OUString& rPath ) ...@@ -337,11 +337,13 @@ void SvxMultiPathDialog::SetPath( const OUString& rPath )
void SvxPathSelectDialog::SetPath(const OUString& rPath) void SvxPathSelectDialog::SetPath(const OUString& rPath)
{ {
sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; 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() )
{
sal_Int32 nIndex = 0;
do
{ {
OUString sPath = rPath.getToken( i, cDelim ); const OUString sPath = rPath.getToken( 0, cDelim, nIndex );
OUString sSystemPath; OUString sSystemPath;
bool bIsSystemPath = bool bIsSystemPath =
osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
...@@ -349,6 +351,8 @@ void SvxPathSelectDialog::SetPath(const OUString& rPath) ...@@ -349,6 +351,8 @@ void SvxPathSelectDialog::SetPath(const OUString& rPath)
const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath ); const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath );
m_pPathLB->SetEntryData( nPos, new OUString( sPath ) ); m_pPathLB->SetEntryData( nPos, new OUString( sPath ) );
} }
while (nIndex >= 0);
}
SelectHdl_Impl( NULL ); SelectHdl_Impl( NULL );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment