summaryrefslogtreecommitdiff
path: root/sd/inc/customshowlist.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/inc/customshowlist.hxx')
-rw-r--r--sd/inc/customshowlist.hxx34
1 files changed, 19 insertions, 15 deletions
diff --git a/sd/inc/customshowlist.hxx b/sd/inc/customshowlist.hxx
index 1d30473e5050..5c70f8a63522 100644
--- a/sd/inc/customshowlist.hxx
+++ b/sd/inc/customshowlist.hxx
@@ -20,14 +20,15 @@
#ifndef INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
#define INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
+#include "sddllapi.h"
#include <vector>
class SdCustomShow;
-class SdCustomShowList
+class SD_DLLPUBLIC SdCustomShowList
{
private:
- std::vector<SdCustomShow*> mShows;
+ std::vector<std::unique_ptr<SdCustomShow>> mShows;
sal_uInt16 mnCurPos;
public:
SdCustomShowList()
@@ -35,17 +36,20 @@ public:
{
}
+ SdCustomShowList& operator=( SdCustomShowList const & ) = delete; // MSVC2017 workaround
+ SdCustomShowList( SdCustomShowList const & ) = delete; // MSVC2017 workaround
+
bool empty() const {return mShows.empty();}
size_t size() const {return mShows.size();}
- SdCustomShow* &operator[](size_t i) {return mShows[i];}
+ std::unique_ptr<SdCustomShow>& operator[](size_t i) {return mShows[i];}
- std::vector<SdCustomShow*>::iterator begin() {return mShows.begin();}
+ std::vector<std::unique_ptr<SdCustomShow>>::iterator begin() {return mShows.begin();}
- void erase(std::vector<SdCustomShow*>::iterator it) {mShows.erase(it);}
+ void erase(std::vector<std::unique_ptr<SdCustomShow>>::iterator it);
- void push_back(SdCustomShow* p) {mShows.push_back(p);}
+ void push_back(std::unique_ptr<SdCustomShow> p) {mShows.push_back(std::move(p));}
sal_uInt16 GetCurPos() const { return mnCurPos; }
void Seek(sal_uInt16 nNewPos) { mnCurPos = nNewPos; }
@@ -55,12 +59,12 @@ public:
if( mShows.empty() )
return nullptr;
mnCurPos = 0;
- return mShows[mnCurPos];
+ return mShows[mnCurPos].get();
}
SdCustomShow* Next()
{
++mnCurPos;
- return mnCurPos >= mShows.size() ? nullptr : mShows[mnCurPos];
+ return mnCurPos >= mShows.size() ? nullptr : mShows[mnCurPos].get();
}
void Last()
{
@@ -69,15 +73,15 @@ public:
}
SdCustomShow* GetCurObject()
{
- return mShows.empty() ? nullptr : mShows[mnCurPos];
+ return mShows.empty() ? nullptr : mShows[mnCurPos].get();
}
- SdCustomShow* Remove(SdCustomShow* p)
+ void erase(SdCustomShow* p)
{
- std::vector<SdCustomShow*>::iterator it = std::find(mShows.begin(), mShows.end(), p);
- if( it == mShows.end() )
- return nullptr;
- mShows.erase(it);
- return p;
+ auto it = std::find_if(mShows.begin(), mShows.end(),
+ [&] (std::unique_ptr<SdCustomShow> const &i) { return i.get() == p; });
+ assert( it != mShows.end() );
+ if( it != mShows.end() )
+ mShows.erase(it);
}
};