Kaydet (Commit) 8692fc43 authored tarafından Noel Grandin's avatar Noel Grandin

convert sw/inc/swunohelper.hxx from String to OUString

and simplify GetFileListOfFolder to take a vector<OUString>
instead of vector<OUString*>

Change-Id: Ie2871bc01880c35b88d9e693a3d8d8c9b92055fb
üst 781751b3
...@@ -33,7 +33,6 @@ namespace com { namespace sun { namespace star { ...@@ -33,7 +33,6 @@ namespace com { namespace sun { namespace star {
namespace rtl {class OUString;} namespace rtl {class OUString;}
class String;
class DateTime; class DateTime;
namespace SWUnoHelper { namespace SWUnoHelper {
...@@ -45,17 +44,17 @@ sal_Int32 GetEnumAsInt32( const com::sun::star::uno::Any& rVal ); ...@@ -45,17 +44,17 @@ sal_Int32 GetEnumAsInt32( const com::sun::star::uno::Any& rVal );
// methods for UCB actions: // methods for UCB actions:
// delete the file under this URL // delete the file under this URL
SW_DLLPUBLIC sal_Bool UCB_DeleteFile( const String& rURL ); SW_DLLPUBLIC sal_Bool UCB_DeleteFile( const OUString& rURL );
// copy/move the file to a new location // copy/move the file to a new location
sal_Bool UCB_CopyFile( const String& rURL, const String& rNewURL, sal_Bool UCB_CopyFile( const OUString& rURL, const OUString& rNewURL,
sal_Bool bCopyIsMove = sal_False ); sal_Bool bCopyIsMove = sal_False );
// is the URL on the current system case sentive? // is the URL on the current system case sentive?
SW_DLLPUBLIC sal_Bool UCB_IsCaseSensitiveFileName( const String& rURL ); SW_DLLPUBLIC sal_Bool UCB_IsCaseSensitiveFileName( const OUString& rURL );
// is the URL readonly? // is the URL readonly?
SW_DLLPUBLIC sal_Bool UCB_IsReadOnlyFileName( const String& rURL ); SW_DLLPUBLIC sal_Bool UCB_IsReadOnlyFileName( const OUString& rURL );
// get a list of files from the folder of the URL // get a list of files from the folder of the URL
// options: pExtension = 0 -> all, else this specific extension // options: pExtension = 0 -> all, else this specific extension
...@@ -63,15 +62,15 @@ SW_DLLPUBLIC sal_Bool UCB_IsReadOnlyFileName( const String& rURL ); ...@@ -63,15 +62,15 @@ SW_DLLPUBLIC sal_Bool UCB_IsReadOnlyFileName( const String& rURL );
// the files in a vector --> // the files in a vector -->
// !! objects must be deleted from the caller!! // !! objects must be deleted from the caller!!
bool UCB_GetFileListOfFolder( const OUString& rURL, bool UCB_GetFileListOfFolder( const OUString& rURL,
std::vector<OUString*>& rList, std::vector<OUString>& rList,
const OUString* pExtension = 0, const OUString* pExtension = 0,
std::vector<DateTime*>* pDateTimeList = 0 ); std::vector<DateTime*>* pDateTimeList = 0 );
// is the URL an existing file? // is the URL an existing file?
SW_DLLPUBLIC sal_Bool UCB_IsFile( const String& rURL ); SW_DLLPUBLIC sal_Bool UCB_IsFile( const OUString& rURL );
// is the URL a existing directory? // is the URL a existing directory?
sal_Bool UCB_IsDirectory( const String& rURL ); sal_Bool UCB_IsDirectory( const OUString& rURL );
} }
#endif #endif
......
...@@ -56,7 +56,7 @@ sal_Int32 GetEnumAsInt32( const ::com::sun::star::uno::Any& rVal ) ...@@ -56,7 +56,7 @@ sal_Int32 GetEnumAsInt32( const ::com::sun::star::uno::Any& rVal )
// methods for UCB actions // methods for UCB actions
sal_Bool UCB_DeleteFile( const String& rURL ) sal_Bool UCB_DeleteFile( const OUString& rURL )
{ {
sal_Bool bRemoved; sal_Bool bRemoved;
try try
...@@ -76,7 +76,7 @@ sal_Bool UCB_DeleteFile( const String& rURL ) ...@@ -76,7 +76,7 @@ sal_Bool UCB_DeleteFile( const String& rURL )
return bRemoved; return bRemoved;
} }
sal_Bool UCB_CopyFile( const String& rURL, const String& rNewURL, sal_Bool bCopyIsMove ) sal_Bool UCB_CopyFile( const OUString& rURL, const OUString& rNewURL, sal_Bool bCopyIsMove )
{ {
sal_Bool bCopyCompleted = sal_True; sal_Bool bCopyCompleted = sal_True;
try try
...@@ -108,7 +108,7 @@ sal_Bool UCB_CopyFile( const String& rURL, const String& rNewURL, sal_Bool bCopy ...@@ -108,7 +108,7 @@ sal_Bool UCB_CopyFile( const String& rURL, const String& rNewURL, sal_Bool bCopy
return bCopyCompleted; return bCopyCompleted;
} }
sal_Bool UCB_IsCaseSensitiveFileName( const String& rURL ) sal_Bool UCB_IsCaseSensitiveFileName( const OUString& rURL )
{ {
sal_Bool bCaseSensitive; sal_Bool bCaseSensitive;
try try
...@@ -136,7 +136,7 @@ sal_Bool UCB_IsCaseSensitiveFileName( const String& rURL ) ...@@ -136,7 +136,7 @@ sal_Bool UCB_IsCaseSensitiveFileName( const String& rURL )
return bCaseSensitive; return bCaseSensitive;
} }
sal_Bool UCB_IsReadOnlyFileName( const String& rURL ) sal_Bool UCB_IsReadOnlyFileName( const OUString& rURL )
{ {
sal_Bool bIsReadOnly = sal_False; sal_Bool bIsReadOnly = sal_False;
try try
...@@ -154,7 +154,7 @@ sal_Bool UCB_IsReadOnlyFileName( const String& rURL ) ...@@ -154,7 +154,7 @@ sal_Bool UCB_IsReadOnlyFileName( const String& rURL )
return bIsReadOnly; return bIsReadOnly;
} }
sal_Bool UCB_IsFile( const String& rURL ) sal_Bool UCB_IsFile( const OUString& rURL )
{ {
sal_Bool bExists = sal_False; sal_Bool bExists = sal_False;
try try
...@@ -168,7 +168,7 @@ sal_Bool UCB_IsFile( const String& rURL ) ...@@ -168,7 +168,7 @@ sal_Bool UCB_IsFile( const String& rURL )
return bExists; return bExists;
} }
sal_Bool UCB_IsDirectory( const String& rURL ) sal_Bool UCB_IsDirectory( const OUString& rURL )
{ {
sal_Bool bExists = sal_False; sal_Bool bExists = sal_False;
try try
...@@ -188,7 +188,7 @@ sal_Bool UCB_IsDirectory( const String& rURL ) ...@@ -188,7 +188,7 @@ sal_Bool UCB_IsDirectory( const String& rURL )
// the files in a std::vector<String*> --> // the files in a std::vector<String*> -->
// !! objects must be deleted from the caller!! // !! objects must be deleted from the caller!!
bool UCB_GetFileListOfFolder( const OUString& rURL, bool UCB_GetFileListOfFolder( const OUString& rURL,
std::vector<OUString*>& rList, std::vector<OUString>& rList,
const OUString* pExtension, const OUString* pExtension,
std::vector< ::DateTime* >* pDateTimeList ) std::vector< ::DateTime* >* pDateTimeList )
{ {
...@@ -228,7 +228,7 @@ bool UCB_GetFileListOfFolder( const OUString& rURL, ...@@ -228,7 +228,7 @@ bool UCB_GetFileListOfFolder( const OUString& rURL,
( sTitle.getLength() > nExtLen && ( sTitle.getLength() > nExtLen &&
sTitle.endsWith( *pExtension )) ) sTitle.endsWith( *pExtension )) )
{ {
rList.push_back( new OUString(sTitle) ); rList.push_back( sTitle );
if( pDateTimeList ) if( pDateTimeList )
{ {
......
...@@ -342,19 +342,16 @@ std::vector<OUString> & SwGlossaries::GetNameList() ...@@ -342,19 +342,16 @@ std::vector<OUString> & SwGlossaries::GetNameList()
const OUString sExt( SwGlossaries::GetExtension() ); const OUString sExt( SwGlossaries::GetExtension() );
for (size_t i = 0; i < m_PathArr.size(); ++i) for (size_t i = 0; i < m_PathArr.size(); ++i)
{ {
std::vector<OUString*> aFiles; std::vector<OUString> aFiles;
SWUnoHelper::UCB_GetFileListOfFolder(m_PathArr[i], aFiles, &sExt); SWUnoHelper::UCB_GetFileListOfFolder(m_PathArr[i], aFiles, &sExt);
for( std::vector<OUString*>::const_iterator filesIt(aFiles.begin()); for( std::vector<OUString>::const_iterator filesIt(aFiles.begin());
filesIt != aFiles.end(); ++filesIt) filesIt != aFiles.end(); ++filesIt)
{ {
const OUString *pTitle = *filesIt; const OUString aTitle = *filesIt;
const OUString sName( pTitle->copy( 0, pTitle->getLength() - sExt.getLength() ) const OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() )
+ OUString(GLOS_DELIM) + OUString::number( static_cast<sal_Int16>(i) )); + OUString(GLOS_DELIM) + OUString::number( static_cast<sal_Int16>(i) ));
m_GlosArr.push_back(sName); m_GlosArr.push_back(sName);
// don't need any more these pointers
delete pTitle;
} }
} }
if (m_GlosArr.empty()) if (m_GlosArr.empty())
......
...@@ -278,17 +278,17 @@ void SwGlossaryList::Update() ...@@ -278,17 +278,17 @@ void SwGlossaryList::Update()
for( size_t nPath = 0; nPath < rPathArr.size(); nPath++ ) for( size_t nPath = 0; nPath < rPathArr.size(); nPath++ )
{ {
std::vector<String> aFoundGroupNames; std::vector<String> aFoundGroupNames;
std::vector<OUString*> aFiles; std::vector<OUString> aFiles;
std::vector<DateTime*> aDateTimeArr; std::vector<DateTime*> aDateTimeArr;
SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles, SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles,
&sExt, &aDateTimeArr ); &sExt, &aDateTimeArr );
for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles ) for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles )
{ {
const OUString* pTitle = aFiles[ nFiles ]; const OUString aTitle = aFiles[ nFiles ];
::DateTime* pDT = (::DateTime*) aDateTimeArr[ static_cast<sal_uInt16>(nFiles) ]; ::DateTime* pDT = (::DateTime*) aDateTimeArr[ static_cast<sal_uInt16>(nFiles) ];
OUString sName( pTitle->copy( 0, pTitle->getLength() - sExt.getLength() )); OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() ));
aFoundGroupNames.push_back(sName); aFoundGroupNames.push_back(sName);
sName += OUString(GLOS_DELIM) + OUString::number( static_cast<sal_uInt16>(nPath) ); sName += OUString(GLOS_DELIM) + OUString::number( static_cast<sal_uInt16>(nPath) );
...@@ -309,7 +309,6 @@ void SwGlossaryList::Update() ...@@ -309,7 +309,6 @@ void SwGlossaryList::Update()
} }
// don't need any more these pointers // don't need any more these pointers
delete pTitle;
delete pDT; delete pDT;
} }
......
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