summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-03 11:09:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-04 11:07:37 +0200
commitc7f762973d21118ce3f5b0baab8850dc89bc4765 (patch)
treef529705f98e69a94d4e731a8f824ef5afa0b9de1 /sc/source/ui/view
parent3e837f44fc88497f9b187e72d7a542acec00df4f (diff)
loplugin:useuniqueptr in ScTabView
and remove pDrawOld, was not being used for anything useful. Change-Id: I65ded5758ca5f7636bf7188012707410f59fb81d Reviewed-on: https://gerrit.libreoffice.org/56910 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/formatsh.cxx6
-rw-r--r--sc/source/ui/view/tabview.cxx1
-rw-r--r--sc/source/ui/view/tabview2.cxx9
-rw-r--r--sc/source/ui/view/tabview5.cxx38
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx24
5 files changed, 36 insertions, 42 deletions
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index b4a5fa80fddf..aa19eb2a0bfa 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2796,9 +2796,9 @@ void ScFormatShell::ExecFormatPaintbrush( const SfxRequest& rReq )
if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
pView->Unmark();
- ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
- pView->CopyToClip( pBrushDoc, false, true );
- pView->SetBrushDocument( pBrushDoc, bLock );
+ std::unique_ptr<ScDocument> pBrushDoc(new ScDocument( SCDOCMODE_CLIP ));
+ pView->CopyToClip( pBrushDoc.get(), false, true );
+ pView->SetBrushDocument( std::move(pBrushDoc), bLock );
}
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 3cb3ecd67edb..ce567a793310 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -25,6 +25,7 @@
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
+#include <pagedata.hxx>
#include <tabview.hxx>
#include <tabvwsh.hxx>
#include <document.hxx>
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 88a491eea54a..30868a8faee1 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -1446,7 +1446,7 @@ void ScTabView::ErrorMessage(const char* pGlobStrId)
void ScTabView::UpdatePageBreakData( bool bForcePaint )
{
- ScPageBreakData* pNewData = nullptr;
+ std::unique_ptr<ScPageBreakData> pNewData;
if (aViewData.IsPagebreakMode())
{
@@ -1457,9 +1457,9 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint )
sal_uInt16 nCount = rDoc.GetPrintRangeCount(nTab);
if (!nCount)
nCount = 1;
- pNewData = new ScPageBreakData(nCount);
+ pNewData.reset( new ScPageBreakData(nCount) );
- ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,nullptr, nullptr, pNewData );
+ ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,nullptr, nullptr, pNewData.get() );
// ScPrintFunc fills the PageBreakData in ctor
if ( nCount > 1 )
{
@@ -1472,8 +1472,7 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint )
PaintGrid();
}
- delete pPageBreakData;
- pPageBreakData = pNewData;
+ pPageBreakData = std::move(pNewData);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 058bedd5b1d0..6900ce9fc430 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -28,6 +28,7 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/objsh.hxx>
+#include <o3tl/make_unique.hxx>
#include <tabview.hxx>
#include <tabvwsh.hxx>
@@ -130,7 +131,6 @@ void ScTabView::Init()
// UpdateShow is done during resize or a copy of an existing view from ctor
pDrawActual = nullptr;
- pDrawOld = nullptr;
// DrawView cannot be create in the TabView - ctor
// when the ViewShell isn't constructed yet...
@@ -153,13 +153,12 @@ ScTabView::~ScTabView()
TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
}
- DELETEZ(pBrushDocument);
- DELETEZ(pDrawBrushSet);
+ pBrushDocument.reset();
+ pDrawBrushSet.reset();
- DELETEZ(pPageBreakData);
+ pPageBreakData.reset();
- DELETEZ(pDrawOld);
- DELETEZ(pDrawActual);
+ pDrawActual.reset();
if (comphelper::LibreOfficeKit::isActive())
{
@@ -247,7 +246,7 @@ void ScTabView::MakeDrawView( TriState nForceDesignMode )
// so that immediately can be drawn
}
SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool());
- SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView,
+ SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*aViewData.GetViewShell(), GetActiveWin(), pDrawView,
pLayer,aSfxRequest));
// used when switching back from page preview: restore saved design mode state
@@ -613,26 +612,20 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect )
}
}
-void ScTabView::SetBrushDocument( ScDocument* pNew, bool bLock )
+void ScTabView::SetBrushDocument( std::unique_ptr<ScDocument> pNew, bool bLock )
{
- delete pBrushDocument;
- delete pDrawBrushSet;
-
- pBrushDocument = pNew;
- pDrawBrushSet = nullptr;
+ pDrawBrushSet.reset();
+ pBrushDocument = std::move(pNew);
bLockPaintBrush = bLock;
aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
}
-void ScTabView::SetDrawBrushSet( SfxItemSet* pNew, bool bLock )
+void ScTabView::SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock )
{
- delete pBrushDocument;
- delete pDrawBrushSet;
-
- pBrushDocument = nullptr;
- pDrawBrushSet = pNew;
+ pBrushDocument.reset();
+ pDrawBrushSet = std::move(pNew);
bLockPaintBrush = bLock;
@@ -691,4 +684,11 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote)
}
}
+void ScTabView::SetDrawFuncPtr(std::unique_ptr<FuPoor> pNew)
+{
+ if (pDrawActual)
+ pDrawActual->Deactivate();
+ pDrawActual = std::move(pNew);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index 58ecae85f7ff..c93c46970727 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -24,6 +24,7 @@
#include <unotools/moduleoptions.hxx>
#include <svl/languageoptions.hxx>
#include <sfx2/dispatch.hxx>
+#include <o3tl/make_unique.hxx>
#include <tabvwsh.hxx>
#include <drawsh.hxx>
@@ -198,14 +199,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
}
if (pTabView->GetDrawFuncPtr())
- {
- if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr())
- delete pTabView->GetDrawFuncOldPtr();
-
- pTabView->GetDrawFuncPtr()->Deactivate();
- pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr());
pTabView->SetDrawFuncPtr(nullptr);
- }
SfxRequest aNewReq(rReq);
aNewReq.SetSlot(nDrawSfxId);
@@ -217,7 +211,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_OBJECT_SELECT:
// not always switch back
if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx);
- pTabView->SetDrawFuncPtr(new FuSelection(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_LINE:
@@ -232,12 +226,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAW_RECT:
case SID_DRAW_ELLIPSE:
case SID_DRAW_MEASURELINE:
- pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL:
- pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq));
pView->SetFrameDragSingles( false );
rBindings.Invalidate( SID_BEZIER_EDIT );
break;
@@ -250,25 +244,25 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAW_BEZIER_FILL:
case SID_DRAW_FREELINE:
case SID_DRAW_FREELINE_NOFILL:
- pTabView->SetDrawFuncPtr(new FuConstPolygon(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstPolygon>(*this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_ARC:
case SID_DRAW_PIE:
case SID_DRAW_CIRCLECUT:
- pTabView->SetDrawFuncPtr(new FuConstArc(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstArc>(*this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_TEXT:
case SID_DRAW_TEXT_VERTICAL:
case SID_DRAW_TEXT_MARQUEE:
case SID_DRAW_NOTEEDIT:
- pTabView->SetDrawFuncPtr(new FuText(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuText>(*this, pWin, pView, pDoc, aNewReq));
break;
case SID_FM_CREATE_CONTROL:
SetDrawFormShell(true);
- pTabView->SetDrawFuncPtr(new FuConstUnoControl(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstUnoControl>(*this, pWin, pView, pDoc, aNewReq));
nFormSfxId = nNewFormId;
break;
@@ -280,7 +274,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAWTBX_CS_STAR :
case SID_DRAW_CS_ID :
{
- pTabView->SetDrawFuncPtr( new FuConstCustomShape(*this, pWin, pView, pDoc, aNewReq));
+ pTabView->SetDrawFuncPtr( o3tl::make_unique<FuConstCustomShape>(*this, pWin, pView, pDoc, aNewReq));
if ( nNewId != SID_DRAW_CS_ID )
{
const SfxStringItem* pEnumCommand = rReq.GetArg<SfxStringItem>(nNewId);