summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/gallery1.hxx9
-rw-r--r--svx/source/gallery2/gallery1.cxx25
2 files changed, 14 insertions, 20 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index 932e7c4dc8d5..66474d17180b 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -26,6 +26,7 @@
#include <tools/urlobj.hxx>
#include <cstdio>
+#include <memory>
#include <vector>
class SvStream;
@@ -78,8 +79,6 @@ public:
void SetId( sal_uInt32 nNewId, bool bResetThemeName );
};
-typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
-
class SfxListener;
class GalleryTheme;
class GalleryThemeCacheEntry;
@@ -95,7 +94,7 @@ class SVX_DLLPUBLIC Gallery : public SfxBroadcaster
private:
- GalleryThemeList aThemeList;
+ std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
GalleryCacheThemeList aThemeCache;
INetURLObject aRelURL;
INetURLObject aUserURL;
@@ -111,6 +110,8 @@ private:
Gallery( const OUString& rMultiPath );
virtual ~Gallery() override;
+ Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
+ Gallery( Gallery const & ) = delete; // MSVC2015 workaround
public:
@@ -118,7 +119,7 @@ public:
SAL_DLLPRIVATE size_t GetThemeCount() const { return aThemeList.size(); }
SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
- { return nPos < aThemeList.size() ? aThemeList[ nPos ] : nullptr; }
+ { return nPos < aThemeList.size() ? aThemeList[ nPos ].get() : nullptr; }
SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( const OUString& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
bool HasTheme( const OUString& rThemeName );
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 219ced254d44..3d3107296a9b 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -259,10 +259,6 @@ Gallery::Gallery( const OUString& rMultiPath )
Gallery::~Gallery()
{
- // erase theme list
- for (GalleryThemeEntry* p : aThemeList)
- delete p;
- aThemeList.clear();
}
Gallery* Gallery::GetGalleryInstance()
@@ -478,7 +474,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO
GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
if( pEntry )
- aThemeList.push_back( pEntry );
+ aThemeList.emplace_back( pEntry );
}
}
catch( const ucb::ContentCreationException& )
@@ -508,16 +504,14 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO
GalleryThemeEntry* Gallery::ImplGetThemeEntry( const OUString& rThemeName )
{
- GalleryThemeEntry* pFound = nullptr;
-
if( !rThemeName.isEmpty() )
{
- for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
+ for ( size_t i = 0, n = aThemeList.size(); i < n; ++i )
if( rThemeName == aThemeList[ i ]->GetThemeName() )
- pFound = aThemeList[ i ];
+ return aThemeList[ i ].get();
}
- return pFound;
+ return nullptr;
}
OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const
@@ -526,7 +520,7 @@ OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const
for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
{
- GalleryThemeEntry* pEntry = aThemeList[ i ];
+ GalleryThemeEntry* pEntry = aThemeList[ i ].get();
if( nThemeId == pEntry->GetId() )
pFound = pEntry;
}
@@ -616,7 +610,7 @@ bool Gallery::CreateTheme( const OUString& rThemeName )
true, aURL, rThemeName,
false, true, 0, false );
- aThemeList.push_back( pNewEntry );
+ aThemeList.emplace_back( pNewEntry );
delete new GalleryTheme( this, pNewEntry );
Broadcast( GalleryHint( GalleryHintType::THEME_CREATED, rThemeName ) );
bRet = true;
@@ -673,11 +667,10 @@ bool Gallery::RemoveTheme( const OUString& rThemeName )
KillFile( aStrURL );
}
- GalleryThemeList::const_iterator aEnd = aThemeList.end();
- for ( GalleryThemeList::iterator it = aThemeList.begin(); it != aEnd; ++it )
+ auto aEnd = aThemeList.end();
+ for ( auto it = aThemeList.begin(); it != aEnd; ++it )
{
- if ( pThemeEntry == *it ) {
- delete pThemeEntry;
+ if ( pThemeEntry == it->get() ) {
aThemeList.erase( it );
break;
}