diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-20 15:40:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-23 07:24:49 +0100 |
commit | 2925ded06627fb7e5408f15288490db7c9f0ebb0 (patch) | |
tree | 563d9171586f8339a592ef9e5c88be36e386d7aa /sd/source/ui/view/outlview.cxx | |
parent | fa1db85bc3cd49407a2f1cfa44433e2718a35baf (diff) |
loplugin:useuniqueptr in OutlineView
Change-Id: I6da98d8634076826cfdbe8d77fa72cb2b99ffe84
Reviewed-on: https://gerrit.libreoffice.org/51672
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui/view/outlview.cxx')
-rw-r--r-- | sd/source/ui/view/outlview.cxx | 87 |
1 files changed, 34 insertions, 53 deletions
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 28bfc4c3f510..5155581ac54c 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -105,16 +105,10 @@ OutlineView::OutlineView( DrawDocShell& rDocSh, vcl::Window* pWindow, OutlineVie mnPaperWidth = 19000; } - // insert View into Outliner - for (OutlinerView* & rp : mpOutlinerView) - { - rp = nullptr; - } - - mpOutlinerView[0] = new OutlinerView(&mrOutliner, pWindow); - mpOutlinerView[0]->SetOutputArea(::tools::Rectangle()); + mpOutlinerViews[0].reset( new OutlinerView(&mrOutliner, pWindow) ); + mpOutlinerViews[0]->SetOutputArea(::tools::Rectangle()); mrOutliner.SetUpdateMode(false); - mrOutliner.InsertView(mpOutlinerView[0], EE_APPEND); + mrOutliner.InsertView(mpOutlinerViews[0].get(), EE_APPEND); onUpdateStyleSettings( true ); @@ -163,16 +157,15 @@ OutlineView::~OutlineView() mrOutlineViewShell.GetViewShellBase().GetEventMultiplexer()->RemoveEventListener( aLink ); DisconnectFromApplication(); - delete mpProgress; + mpProgress.reset(); // unregister OutlinerViews and destroy them - for (OutlinerView* & rpView : mpOutlinerView) + for (auto & rpView : mpOutlinerViews) { - if (rpView != nullptr) + if (rpView) { - mrOutliner.RemoveView( rpView ); - delete rpView; - rpView = nullptr; + mrOutliner.RemoveView( rpView.get() ); + rpView.reset(); } } @@ -233,21 +226,21 @@ void OutlineView::AddWindowToPaintView(OutputDevice* pWin, vcl::Window* pWindow) while (nView < MAX_OUTLINERVIEWS && !bAdded) { - if (mpOutlinerView[nView] == nullptr) + if (mpOutlinerViews[nView] == nullptr) { - mpOutlinerView[nView] = new OutlinerView(&mrOutliner, dynamic_cast< ::sd::Window* >(pWin)); - mpOutlinerView[nView]->SetBackgroundColor( aWhiteColor ); - mrOutliner.InsertView(mpOutlinerView[nView], EE_APPEND); + mpOutlinerViews[nView].reset( new OutlinerView(&mrOutliner, dynamic_cast< ::sd::Window* >(pWin)) ); + mpOutlinerViews[nView]->SetBackgroundColor( aWhiteColor ); + mrOutliner.InsertView(mpOutlinerViews[nView].get(), EE_APPEND); bAdded = true; if (bValidArea) { - mpOutlinerView[nView]->SetOutputArea(aOutputArea); + mpOutlinerViews[nView]->SetOutputArea(aOutputArea); } } else if (!bValidArea) { - aOutputArea = mpOutlinerView[nView]->GetOutputArea(); + aOutputArea = mpOutlinerViews[nView]->GetOutputArea(); bValidArea = true; } @@ -268,15 +261,14 @@ void OutlineView::DeleteWindowFromPaintView(OutputDevice* pWin) while (nView < MAX_OUTLINERVIEWS && !bRemoved) { - if (mpOutlinerView[nView] != nullptr) + if (mpOutlinerViews[nView] != nullptr) { - pWindow = mpOutlinerView[nView]->GetWindow(); + pWindow = mpOutlinerViews[nView]->GetWindow(); if (pWindow == pWin) { - mrOutliner.RemoveView( mpOutlinerView[nView] ); - delete mpOutlinerView[nView]; - mpOutlinerView[nView] = nullptr; + mrOutliner.RemoveView( mpOutlinerViews[nView].get() ); + mpOutlinerViews[nView].reset(); bRemoved = true; } } @@ -293,13 +285,13 @@ void OutlineView::DeleteWindowFromPaintView(OutputDevice* pWin) OutlinerView* OutlineView::GetViewByWindow (vcl::Window const * pWin) const { OutlinerView* pOlView = nullptr; - for (OutlinerView* pView : mpOutlinerView) + for (std::unique_ptr<OutlinerView> const & pView : mpOutlinerViews) { if (pView != nullptr) { if ( pWin == pView->GetWindow() ) { - pOlView = pView; + pOlView = pView.get(); } } } @@ -529,11 +521,7 @@ IMPL_LINK( OutlineView, ParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, aPa if (mnPagesProcessed == mnPagesToProcess) { - if(mpProgress) - { - delete mpProgress; - mpProgress = nullptr; - } + mpProgress.reset(); mnPagesToProcess = 0; mnPagesProcessed = 0; } @@ -586,8 +574,7 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner::DepthChangeHdlParam, aParam if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD) { - delete mpProgress; - mpProgress = new SfxProgress( GetDocSh(), SdResId(STR_CREATE_PAGES), mnPagesToProcess ); + mpProgress.reset( new SfxProgress( GetDocSh(), SdResId(STR_CREATE_PAGES), mnPagesToProcess ) ); } else { @@ -611,8 +598,7 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner::DepthChangeHdlParam, aParam { if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD && mpProgress) { - delete mpProgress; - mpProgress = nullptr; + mpProgress.reset(); } else mpDocSh->SetWaitCursor( false ); @@ -662,11 +648,7 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner::DepthChangeHdlParam, aParam if (mnPagesProcessed == mnPagesToProcess) { - if(mpProgress) - { - delete mpProgress; - mpProgress = nullptr; - } + mpProgress.reset(); mnPagesToProcess = 0; mnPagesProcessed = 0; } @@ -802,7 +784,7 @@ IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner, void ) OutlineViewPageChangesGuard aGuard(this); // list of selected title paragraphs - mpOutlinerView[0]->CreateSelectionList(maSelectedParas); + mpOutlinerViews[0]->CreateSelectionList(maSelectedParas); for (std::vector<Paragraph*>::iterator it = maSelectedParas.begin(); it != maSelectedParas.end();) { @@ -1135,12 +1117,12 @@ void OutlineView::FillOutliner() // place cursor at the start Paragraph* pFirstPara = mrOutliner.GetParagraph( 0 ); - mpOutlinerView[0]->Select( pFirstPara ); - mpOutlinerView[0]->Select( pFirstPara, false ); + mpOutlinerViews[0]->Select( pFirstPara ); + mpOutlinerViews[0]->Select( pFirstPara, false ); // select title of slide that was selected if (pTitleToSelect) - mpOutlinerView[0]->Select(pTitleToSelect); + mpOutlinerViews[0]->Select(pTitleToSelect); SetLinks(); @@ -1164,8 +1146,7 @@ IMPL_LINK_NOARG(OutlineView, RemovingPagesHdl, OutlinerView*, bool) if (mnPagesToProcess) { - delete mpProgress; - mpProgress = new SfxProgress( GetDocSh(), SdResId(STR_DELETE_PAGES), mnPagesToProcess ); + mpProgress.reset( new SfxProgress( GetDocSh(), SdResId(STR_DELETE_PAGES), mnPagesToProcess ) ); } mrOutliner.UpdateFields(); @@ -1259,7 +1240,7 @@ void OutlineView::SetActualPage( SdPage const * pActual ) // if we found a paragraph, select its text at the outliner view Paragraph* pPara = GetParagraphForPage( mrOutliner, pActual ); if( pPara ) - mpOutlinerView[0]->Select( pPara ); + mpOutlinerViews[0]->Select( pPara ); } } @@ -1281,7 +1262,7 @@ void OutlineView::SetSelectedPages() { // list of selected title paragraphs std::vector<Paragraph*> aSelParas; - mpOutlinerView[0]->CreateSelectionList(aSelParas); + mpOutlinerViews[0]->CreateSelectionList(aSelParas); for (std::vector<Paragraph*>::iterator it = aSelParas.begin(); it != aSelParas.end();) { @@ -1391,11 +1372,11 @@ void OutlineView::onUpdateStyleSettings( bool bForceUpdate /* = false */ ) sal_uInt16 nView; for( nView = 0; nView < MAX_OUTLINERVIEWS; nView++ ) { - if (mpOutlinerView[nView] != nullptr) + if (mpOutlinerViews[nView] != nullptr) { - mpOutlinerView[nView]->SetBackgroundColor( aDocColor ); + mpOutlinerViews[nView]->SetBackgroundColor( aDocColor ); - vcl::Window* pWindow = mpOutlinerView[nView]->GetWindow(); + vcl::Window* pWindow = mpOutlinerViews[nView]->GetWindow(); if( pWindow ) pWindow->SetBackground( Wallpaper( aDocColor ) ); |