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:
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
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -87,10 +87,7 @@ public:
explicit SvxViewChangedHint();
};
/// Typedefs for a list of SdrPaintWindows
class SdrPaintWindow;
typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector;
/**
* Helper to convert any GDIMetaFile to a good quality BitmapEx,
......@@ -150,7 +147,7 @@ protected:
// Container aPagV; // List of SdrPageViews
// 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 maGridFin; // FIXME: We need to get rid of this eventually
......@@ -228,7 +225,7 @@ protected:
Color maGridColor;
// Interface to SdrPaintWindow
void RemovePaintWindow(SdrPaintWindow& rOld);
void DeletePaintWindow(SdrPaintWindow& rOld);
void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
public:
......
......@@ -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
......
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