[Libreoffice-commits] core.git: unotools/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jul 6 09:59:47 UTC 2017


 unotools/source/ucbhelper/localfilehelper.cxx |   29 +++-----------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

New commits:
commit 6a76b4c9c52ab9f4cd67fa9bf9468258f375dce2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jul 6 10:30:48 2017 +0200

    simplify LocalFileHelper::GetFolderContents
    
    Change-Id: Iaab871f0ec87fadb54fe0a2cb3b92052de9434b8
    Reviewed-on: https://gerrit.libreoffice.org/39621
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx
index 45668518c19e..4b0a69336a33 100644
--- a/unotools/source/ucbhelper/localfilehelper.cxx
+++ b/unotools/source/ucbhelper/localfilehelper.cxx
@@ -21,6 +21,7 @@
 #include <com/sun/star/ucb/XContentAccess.hpp>
 #include <com/sun/star/ucb/CommandAbortedException.hpp>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <sal/log.hxx>
 #include <unotools/localfilehelper.hxx>
 #include <rtl/ustring.hxx>
@@ -36,11 +37,9 @@ using namespace ::com::sun::star::ucb;
 namespace utl
 {
 
-typedef ::std::vector< OUString* > StringList_Impl;
-
 css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder )
 {
-    StringList_Impl* pFiles = nullptr;
+    std::vector< OUString > vFiles;
     try
     {
         ::ucbhelper::Content aCnt(
@@ -63,16 +62,11 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri
 
         if ( xResultSet.is() )
         {
-            pFiles = new StringList_Impl;
             Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
             try
             {
                 while ( xResultSet->next() )
-                {
-                    OUString aId = xContentAccess->queryContentIdentifierString();
-                    OUString* pFile = new OUString( aId );
-                    pFiles->push_back( pFile );
-                }
+                    vFiles.push_back( xContentAccess->queryContentIdentifierString() );
             }
             catch( css::ucb::CommandAbortedException& )
             {
@@ -86,22 +80,7 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri
     {
     }
 
-    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)[ i ];
-            pRet[i] = *( pFile );
-            delete pFile;
-        }
-        delete pFiles;
-        return aRet;
-    }
-    else
-        return Sequence < OUString > ();
+    return comphelper::containerToSequence(vFiles);
 }
 
 void removeTree(OUString const & url) {


More information about the Libreoffice-commits mailing list