Kaydet (Commit) 45f0c58c authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in SdrPaintView

Change-Id: If4ae6eb38351a9d7dec547d02bbb5a700af5ec64
Reviewed-on: https://gerrit.libreoffice.org/65397
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 41ed5c2e
...@@ -138,9 +138,6 @@ public: ...@@ -138,9 +138,6 @@ public:
OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return *mpOutputDevice.get(); } OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return *mpOutputDevice.get(); }
}; };
// typedefs for a list of SdrPaintWindows
typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector;
#endif // INCLUDED_SVX_SDRPAINTWINDOW_HXX #endif // INCLUDED_SVX_SDRPAINTWINDOW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -87,10 +87,7 @@ public: ...@@ -87,10 +87,7 @@ public:
explicit SvxViewChangedHint(); explicit SvxViewChangedHint();
}; };
/// Typedefs for a list of SdrPaintWindows
class SdrPaintWindow; class SdrPaintWindow;
typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector;
/** /**
* Helper to convert any GDIMetaFile to a good quality BitmapEx, * Helper to convert any GDIMetaFile to a good quality BitmapEx,
...@@ -150,7 +147,7 @@ protected: ...@@ -150,7 +147,7 @@ protected:
// Container aPagV; // List of SdrPageViews // Container aPagV; // List of SdrPageViews
// All windows this view is displayed on // All windows this view is displayed on
SdrPaintWindowVector maPaintWindows; std::vector< std::unique_ptr<SdrPaintWindow> > maPaintWindows;
Size maGridBig; // FIXME: We need to get rid of this eventually Size maGridBig; // FIXME: We need to get rid of this eventually
Size maGridFin; // FIXME: We need to get rid of this eventually Size maGridFin; // FIXME: We need to get rid of this eventually
...@@ -228,7 +225,7 @@ protected: ...@@ -228,7 +225,7 @@ protected:
Color maGridColor; Color maGridColor;
// Interface to SdrPaintWindow // Interface to SdrPaintWindow
void RemovePaintWindow(SdrPaintWindow& rOld); void DeletePaintWindow(SdrPaintWindow& rOld);
void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, ConfigurationHints ) override; void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
public: public:
......
...@@ -68,26 +68,22 @@ using namespace ::com::sun::star; ...@@ -68,26 +68,22 @@ using namespace ::com::sun::star;
SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
{ {
auto a = std::find_if(maPaintWindows.begin(), maPaintWindows.end(), 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()) if (a != maPaintWindows.end())
return *a; return a->get();
return nullptr; return nullptr;
} }
SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const
{ {
if(nIndex < maPaintWindows.size()) return maPaintWindows[nIndex].get();
{
return maPaintWindows[nIndex];
}
return nullptr;
} }
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()) if(aFindResult != maPaintWindows.end())
{ {
...@@ -216,11 +212,7 @@ SdrPaintView::~SdrPaintView() ...@@ -216,11 +212,7 @@ SdrPaintView::~SdrPaintView()
#endif #endif
// delete existing SdrPaintWindows // delete existing SdrPaintWindows
while(!maPaintWindows.empty()) maPaintWindows.clear();
{
delete maPaintWindows.back();
maPaintWindows.pop_back();
}
} }
...@@ -424,7 +416,7 @@ void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window *pWin ...@@ -424,7 +416,7 @@ void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window *pWin
{ {
DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)"); DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)");
SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin, pWindow); SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin, pWindow);
maPaintWindows.push_back(pNewPaintWindow); maPaintWindows.emplace_back(pNewPaintWindow);
if(mpPageView) if(mpPageView)
{ {
...@@ -449,8 +441,7 @@ void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin) ...@@ -449,8 +441,7 @@ void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
mpPageView->RemovePaintWindowFromPageView(*pCandidate); mpPageView->RemovePaintWindowFromPageView(*pCandidate);
} }
RemovePaintWindow(*pCandidate); DeletePaintWindow(*pCandidate);
delete pCandidate;
} }
#ifdef DBG_UTIL #ifdef DBG_UTIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment