diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-19 10:14:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-20 07:29:33 +0100 |
commit | 45f0c58c615e1caf2bc8630924e2e4c89ac7bc4d (patch) | |
tree | 98392a0266dafaceccbd14b962f59badf8bf68df /svx | |
parent | 41ed5c2e61a040b674444088b15c8bdea30a45b0 (diff) |
use unique_ptr in SdrPaintView
Change-Id: If4ae6eb38351a9d7dec547d02bbb5a700af5ec64
Reviewed-on: https://gerrit.libreoffice.org/65397
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdpntv.cxx | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index e03397d8d285..967215a3822b 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -68,26 +68,22 @@ using namespace ::com::sun::star; SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const { auto a = std::find_if(maPaintWindows.begin(), maPaintWindows.end(), - [&rOut](const SdrPaintWindow* pWindow) { return &(pWindow->GetOutputDevice()) == &rOut; }); + [&rOut](const std::unique_ptr<SdrPaintWindow>& pWindow) { return &(pWindow->GetOutputDevice()) == &rOut; }); if (a != maPaintWindows.end()) - return *a; + return a->get(); return nullptr; } SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const { - if(nIndex < maPaintWindows.size()) - { - return maPaintWindows[nIndex]; - } - - return nullptr; + return maPaintWindows[nIndex].get(); } -void SdrPaintView::RemovePaintWindow(SdrPaintWindow& rOld) +void SdrPaintView::DeletePaintWindow(SdrPaintWindow& rOld) { - const SdrPaintWindowVector::iterator aFindResult = ::std::find(maPaintWindows.begin(), maPaintWindows.end(), &rOld); + auto aFindResult = ::std::find_if(maPaintWindows.begin(), maPaintWindows.end(), + [&](const std::unique_ptr<SdrPaintWindow>& p) { return p.get() == &rOld; }); if(aFindResult != maPaintWindows.end()) { @@ -216,11 +212,7 @@ SdrPaintView::~SdrPaintView() #endif // delete existing SdrPaintWindows - while(!maPaintWindows.empty()) - { - delete maPaintWindows.back(); - maPaintWindows.pop_back(); - } + maPaintWindows.clear(); } @@ -424,7 +416,7 @@ void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window *pWin { DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)"); SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin, pWindow); - maPaintWindows.push_back(pNewPaintWindow); + maPaintWindows.emplace_back(pNewPaintWindow); if(mpPageView) { @@ -449,8 +441,7 @@ void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin) mpPageView->RemovePaintWindowFromPageView(*pCandidate); } - RemovePaintWindow(*pCandidate); - delete pCandidate; + DeletePaintWindow(*pCandidate); } #ifdef DBG_UTIL |