diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-14 10:11:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-15 06:57:19 +0100 |
commit | f7214c70676b35baff427d986ffb85b8c79c0ca8 (patch) | |
tree | 34695fcbf1af151fc837cb276d98a92de62f1998 | |
parent | 6018adfabc30ee68939c2d974aa612757bbca938 (diff) |
simplify UCB_GetFileListOfFolder
no need to use heap objects here
Change-Id: Iadc35b019da7b9446ede79c96a9d8ce8c6db81ef
Reviewed-on: https://gerrit.libreoffice.org/66315
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/inc/swunohelper.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/swunohelper.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/utlui/gloslst.cxx | 13 |
3 files changed, 9 insertions, 13 deletions
diff --git a/sw/inc/swunohelper.hxx b/sw/inc/swunohelper.hxx index 35459bdcfa31..b87d7dda833e 100644 --- a/sw/inc/swunohelper.hxx +++ b/sw/inc/swunohelper.hxx @@ -56,11 +56,10 @@ SW_DLLPUBLIC bool UCB_IsReadOnlyFileName( const OUString& rURL ); // options: pExtension = 0 -> all, else this specific extension // pDateTime != 0 -> returns also the modified date/time of // the files in a vector --> - // !! objects must be deleted from the caller!! bool UCB_GetFileListOfFolder( const OUString& rURL, std::vector<OUString>& rList, const OUString* pExtension, - std::vector<DateTime*>* pDateTimeList = nullptr ); + std::vector<DateTime>* pDateTimeList = nullptr ); // is the URL an existing file? SW_DLLPUBLIC bool UCB_IsFile( const OUString& rURL ); diff --git a/sw/source/core/unocore/swunohelper.cxx b/sw/source/core/unocore/swunohelper.cxx index e2fcdcf0724f..29e76e9bd554 100644 --- a/sw/source/core/unocore/swunohelper.cxx +++ b/sw/source/core/unocore/swunohelper.cxx @@ -184,7 +184,7 @@ bool UCB_IsDirectory( const OUString& rURL ) bool UCB_GetFileListOfFolder( const OUString& rURL, std::vector<OUString>& rList, const OUString* pExtension, - std::vector< ::DateTime* >* pDateTimeList ) + std::vector< ::DateTime >* pDateTimeList ) { bool bOk = false; try @@ -227,7 +227,7 @@ bool UCB_GetFileListOfFolder( const OUString& rURL, if( pDateTimeList ) { css::util::DateTime aStamp = xRow->getTimestamp(2); - ::DateTime* pDateTime = new ::DateTime( + ::DateTime aDateTime( ::Date( aStamp.Day, aStamp.Month, aStamp.Year ), @@ -235,7 +235,7 @@ bool UCB_GetFileListOfFolder( const OUString& rURL, aStamp.Minutes, aStamp.Seconds, aStamp.NanoSeconds )); - pDateTimeList->push_back( pDateTime ); + pDateTimeList->push_back( aDateTime ); } } diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx index 0a05aa8acaf3..2c92c4a5acbb 100644 --- a/sw/source/uibase/utlui/gloslst.cxx +++ b/sw/source/uibase/utlui/gloslst.cxx @@ -270,14 +270,14 @@ void SwGlossaryList::Update() { std::vector<OUString> aFoundGroupNames; std::vector<OUString> aFiles; - std::vector<DateTime*> aDateTimeArr; + std::vector<DateTime> aDateTimeArr; SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles, &sExt, &aDateTimeArr ); for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles ) { const OUString aTitle = aFiles[ nFiles ]; - ::DateTime* pDT = aDateTimeArr[ nFiles ]; + ::DateTime& rDT = aDateTimeArr[ nFiles ]; OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() )); @@ -289,18 +289,15 @@ void SwGlossaryList::Update() pFound = new AutoTextGroup; pFound->sName = sName; FillGroup( pFound, pGlossaries ); - pFound->aDateModified = *pDT; + pFound->aDateModified = rDT; aGroupArr.push_back(std::unique_ptr<AutoTextGroup>(pFound)); } - else if( pFound->aDateModified < *pDT ) + else if( pFound->aDateModified < rDT ) { FillGroup(pFound, pGlossaries); - pFound->aDateModified = *pDT; + pFound->aDateModified = rDT; } - - // don't need any more these pointers - delete pDT; } for( size_t i = aGroupArr.size(); i>0; ) |