[Libreoffice-commits] core.git: include/svx svx/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Dec 20 06:29:57 UTC 2018
include/svx/sdrpaintwindow.hxx | 3 ---
include/svx/svdpntv.hxx | 7 ++-----
svx/source/svdraw/svdpntv.cxx | 27 +++++++++------------------
3 files changed, 11 insertions(+), 26 deletions(-)
New commits:
commit 45f0c58c615e1caf2bc8630924e2e4c89ac7bc4d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 19 10:14:45 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Dec 20 07:29:33 2018 +0100
use unique_ptr in SdrPaintView
Change-Id: If4ae6eb38351a9d7dec547d02bbb5a700af5ec64
Reviewed-on: https://gerrit.libreoffice.org/65397
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/sdrpaintwindow.hxx b/include/svx/sdrpaintwindow.hxx
index c99c578f0da3..8c833d85926c 100644
--- a/include/svx/sdrpaintwindow.hxx
+++ b/include/svx/sdrpaintwindow.hxx
@@ -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: */
diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx
index 8af3d7710d04..2913850ed04b 100644
--- a/include/svx/svdpntv.hxx
+++ b/include/svx/svdpntv.hxx
@@ -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:
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
More information about the Libreoffice-commits
mailing list