From 3ea8ee202832294adc09c0b1fd1c26cb87ca7cbf Mon Sep 17 00:00:00 2001 From: August Sodora Date: Wed, 11 Jan 2012 23:44:05 -0500 Subject: SvStringsDtor->std::vector --- sfx2/source/appl/appopen.cxx | 15 +++++----- sfx2/source/dialog/filedlghelper.cxx | 54 ++++++++++++------------------------ sfx2/source/dialog/filedlgimpl.hxx | 4 +-- 3 files changed, 27 insertions(+), 46 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 7bb7a5c42bbd..3b45dc69585b 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -715,7 +715,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if ( !pFileNameItem ) { // get FileName from dialog - SvStringsDtor* pURLList = NULL; + std::vector pURLList; String aFilter; SfxItemSet* pSet = NULL; String aPath; @@ -757,7 +757,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if ( nErr == ERRCODE_ABORT ) { - delete pURLList; + pURLList.clear(); return; } @@ -768,7 +768,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) rReq.AppendItem( SfxStringItem( SID_REFERER, String::CreateFromAscii(SFX_REFERER_USER) ) ); delete pSet; - if ( pURLList->Count() ) + if(!pURLList.empty()) { if ( nSID == SID_OPENTEMPLATE ) rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, sal_False ) ); @@ -799,11 +799,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) ::framework::PreventDuplicateInteraction::InteractionInfo aRule (aInteraction, 1); pHandler->addInteractionRule(aRule); - for ( sal_uInt16 i = 0; i < pURLList->Count(); ++i ) + for(std::vector::const_iterator i = pURLList.begin(); i != pURLList.end(); ++i) { - String aURL = *(pURLList->GetObject(i)); rReq.RemoveItem( SID_FILE_NAME ); - rReq.AppendItem( SfxStringItem( SID_FILE_NAME, aURL ) ); + rReq.AppendItem( SfxStringItem( SID_FILE_NAME, *i ) ); // Run synchronous, so that not the next document is loaded // when rescheduling @@ -832,10 +831,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) } } - delete pURLList; + pURLList.clear(); return; } - delete pURLList; + pURLList.clear(); } sal_Bool bHyperlinkUsed = sal_False; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index bacc37a38b36..f09ad4de2d66 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1366,22 +1366,18 @@ void FileDialogHelper_Impl::implStartExecute() } // ------------------------------------------------------------------------ -void lcl_saveLastURLs(SvStringsDtor*& rpURLList , +void lcl_saveLastURLs(std::vector& rpURLList, ::comphelper::SequenceAsVector< ::rtl::OUString >& lLastURLs ) { lLastURLs.clear(); - sal_uInt16 c = rpURLList->Count(); - sal_uInt16 i = 0; - for (i=0; iGetObject(i))); + for(std::vector::iterator i = rpURLList.begin(); i != rpURLList.end(); ++i) + lLastURLs.push_back(*i); } // ------------------------------------------------------------------------ -void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker , - SvStringsDtor*& rpURLList, - const SfxFilter* pFilter ) +void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector& rpURLList, const SfxFilter* pFilter) { - rpURLList = NULL; + rpURLList.clear(); rtl::OUString sExtension; if (pFilter) @@ -1395,14 +1391,10 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac uno::Reference< XFilePicker2 > xPickNew(xPicker, UNO_QUERY); if (xPickNew.is()) { - rpURLList = new SvStringsDtor; Sequence< OUString > lFiles = xPickNew->getSelectedFiles(); ::sal_Int32 nFiles = lFiles.getLength(); - for (::sal_Int32 i = 0; i < nFiles; i++) - { - String* pURL = new String(lFiles[i]); - rpURLList->Insert( pURL, rpURLList->Count() ); - } + for(sal_Int32 i = 0; i < nFiles; ++i) + rpURLList.push_back(lFiles[i]); } // b) the olde way ... non optional. @@ -1413,15 +1405,10 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac ::sal_Int32 nFiles = lFiles.getLength(); if ( nFiles == 1 ) { - rpURLList = new SvStringsDtor; - String* pURL = new String(lFiles[0]); - rpURLList->Insert( pURL, 0 ); + rpURLList.push_back(lFiles[0]); } - else - if ( nFiles > 1 ) + else if ( nFiles > 1 ) { - rpURLList = new SvStringsDtor; - INetURLObject aPath( lFiles[0] ); aPath.setFinalSlash(); @@ -1432,8 +1419,7 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac else aPath.setName( lFiles[i] ); - String* pURL = new String(aPath.GetMainURL( INetURLObject::NO_DECODE ) ); - rpURLList->Insert( pURL, rpURLList->Count() ); + rpURLList.push_back(aPath.GetMainURL(INetURLObject::NO_DECODE)); } } } @@ -1442,7 +1428,7 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac } // ------------------------------------------------------------------------ -ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, +ErrCode FileDialogHelper_Impl::execute( std::vector& rpURLList, SfxItemSet *& rpSet, String& rFilter ) { @@ -1489,7 +1475,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, aSecOpt.IsOptionSet( SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD ) ); } - rpURLList = NULL; + rpURLList.clear(); if ( ! mxFileDlg.is() ) return ERRCODE_ABORT; @@ -1560,7 +1546,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // fill the rpURLList implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); - if ( rpURLList == NULL || rpURLList->GetObject(0) == NULL ) + if ( rpURLList.empty() ) return ERRCODE_ABORT; // check, wether or not we have to display a password box @@ -1573,7 +1559,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( ( aValue >>= bPassWord ) && bPassWord ) { // ask for a password - rtl::OUString aDocName(*(rpURLList->GetObject(0))); + rtl::OUString aDocName(rpURLList[0]); ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet); if (errCode != ERRCODE_NONE) return errCode; @@ -2326,7 +2312,7 @@ IMPL_LINK( FileDialogHelper, ExecuteSystemFilePicker, void*, EMPTYARG ) // ------------------------------------------------------------------------ // rDirPath has to be a directory -ErrCode FileDialogHelper::Execute( SvStringsDtor*& rpURLList, +ErrCode FileDialogHelper::Execute( std::vector& rpURLList, SfxItemSet *& rpSet, String& rFilter, const String& rDirPath ) @@ -2347,12 +2333,8 @@ ErrCode FileDialogHelper::Execute( SfxItemSet *& rpSet, String& rFilter ) { ErrCode nRet; - SvStringsDtor* pURLList; - - nRet = mpImp->execute( pURLList, rpSet, rFilter ); - - delete pURLList; - + std::vector rURLList; + nRet = mpImp->execute(rURLList, rpSet, rFilter); return nRet; } @@ -2638,7 +2620,7 @@ void SAL_CALL FileDialogHelper::DialogClosed( const DialogClosedEvent& _rEvent ) ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType, sal_Int64 nFlags, const String& rFact, - SvStringsDtor *& rpURLList, + std::vector& rpURLList, String& rFilter, SfxItemSet *& rpSet, const String* pPath, diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index 1da12fb4f827..5bfce3c8db42 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -153,7 +153,7 @@ namespace sfx2 void implInitializeFileName( ); void implGetAndCacheFiles( const ::com::sun::star::uno::Reference< XInterface >& xPicker , - SvStringsDtor*& rpURLList, + std::vector& rpURLList, const SfxFilter* pFilter ); DECL_LINK( TimeOutHdl_Impl, Timer* ); @@ -193,7 +193,7 @@ namespace sfx2 ); virtual ~FileDialogHelper_Impl(); - ErrCode execute( SvStringsDtor*& rpURLList, + ErrCode execute( std::vector& rpURLList, SfxItemSet *& rpSet, String& rFilter ); ErrCode execute(); -- cgit