summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 16:30:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-20 12:35:50 +0100
commita60265f07bdd62d810cae3c7e64b1ad4fb02bbaa (patch)
treef7535ff8309be9571e7b90dc857bc5dcead3f545 /ucb
parent9ac86f914e6086c4bb2f5214c73d21ee308c24c4 (diff)
use unique_ptr in ucb
Change-Id: I613069e9a04b2afa06486507c857c9135694ac23 Reviewed-on: https://gerrit.libreoffice.org/65445 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/core/FileAccess.cxx25
-rw-r--r--ucb/source/ucp/file/filtask.cxx21
2 files changed, 13 insertions, 33 deletions
diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index 649234bfca2c..98ac5260817d 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -20,6 +20,7 @@
#include <uno/mapping.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -434,7 +435,7 @@ Sequence< OUString > OFileAccess::getFolderContents( const OUString& FolderURL,
{
// SfxContentHelper::GetFolderContents
- StringList_Impl* pFiles = nullptr;
+ std::vector<OUString> aFiles;
INetURLObject aFolderObj( FolderURL, INetProtocol::File );
ucbhelper::Content aCnt( aFolderObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
@@ -454,35 +455,17 @@ Sequence< OUString > OFileAccess::getFolderContents( const OUString& FolderURL,
if ( xResultSet.is() )
{
- pFiles = new StringList_Impl;
Reference< css::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
while ( xResultSet->next() )
{
OUString aId = xContentAccess->queryContentIdentifierString();
INetURLObject aURL( aId, INetProtocol::File );
- OUString* pFile = new OUString( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
- pFiles->push_back( pFile );
+ aFiles.push_back( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
}
}
- if ( pFiles )
- {
- size_t nCount = pFiles->size();
- Sequence < OUString > aRet( nCount );
- OUString* pRet = aRet.getArray();
- for ( size_t i = 0; i < nCount; ++i )
- {
- OUString* pFile = pFiles->at( i );
- pRet[i] = *pFile;
- delete pFile;
- }
- pFiles->clear();
- delete pFiles;
- return aRet;
- }
- else
- return Sequence < OUString > ();
+ return comphelper::containerToSequence(aFiles);
}
sal_Bool OFileAccess::exists( const OUString& FileURL )
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index c8996afedf0b..39004e13eb39 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -718,7 +718,7 @@ TaskManager::open( sal_Int32 CommandId,
const OUString& aUnqPath,
bool bLock )
{
- XInputStream_impl* pInputStream = new XInputStream_impl( aUnqPath, bLock ); // from filinpstr.hxx
+ std::unique_ptr<XInputStream_impl> pInputStream(new XInputStream_impl( aUnqPath, bLock )); // from filinpstr.hxx
sal_Int32 ErrorCode = pInputStream->CtorSuccess();
@@ -728,11 +728,10 @@ TaskManager::open( sal_Int32 CommandId,
ErrorCode,
pInputStream->getMinorError() );
- delete pInputStream;
- pInputStream = nullptr;
+ pInputStream.reset();
}
- return uno::Reference< io::XInputStream >( pInputStream );
+ return uno::Reference< io::XInputStream >( pInputStream.release() );
}
@@ -751,7 +750,7 @@ TaskManager::open_rw( sal_Int32 CommandId,
const OUString& aUnqPath,
bool bLock )
{
- XStream_impl* pStream = new XStream_impl( aUnqPath, bLock ); // from filstr.hxx
+ std::unique_ptr<XStream_impl> pStream(new XStream_impl( aUnqPath, bLock )); // from filstr.hxx
sal_Int32 ErrorCode = pStream->CtorSuccess();
@@ -761,10 +760,9 @@ TaskManager::open_rw( sal_Int32 CommandId,
ErrorCode,
pStream->getMinorError() );
- delete pStream;
- pStream = nullptr;
+ pStream.reset();
}
- return uno::Reference< io::XStream >( pStream );
+ return uno::Reference< io::XStream >( pStream.release() );
}
@@ -785,7 +783,7 @@ TaskManager::ls( sal_Int32 CommandId,
const uno::Sequence< beans::Property >& seq,
const uno::Sequence< NumberedSortingInfo >& seqSort )
{
- XResultSet_impl* p = new XResultSet_impl( this,aUnqPath,OpenMode,seq,seqSort );
+ std::unique_ptr<XResultSet_impl> p(new XResultSet_impl( this,aUnqPath,OpenMode,seq,seqSort ));
sal_Int32 ErrorCode = p->CtorSuccess();
@@ -795,11 +793,10 @@ TaskManager::ls( sal_Int32 CommandId,
ErrorCode,
p->getMinorError() );
- delete p;
- p = nullptr;
+ p.reset();
}
- return uno::Reference< XDynamicResultSet > ( p );
+ return uno::Reference< XDynamicResultSet > ( p.release() );
}