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

loplugin:useuniqueptr in GraphCtrl

Change-Id: I47299326467e31b72094a4fa7de6dbe8dd3ced7e
Reviewed-on: https://gerrit.libreoffice.org/55515Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5fc92b92
......@@ -58,7 +58,7 @@ class SVX_DLLPUBLIC GraphCtrl : public Control
MapMode aMap100;
Size aGraphSize;
Point aMousePos;
GraphCtrlUserCall* pUserCall;
std::unique_ptr<GraphCtrlUserCall> pUserCall;
SdrObjKind eObjKind;
sal_uInt16 nPolyEdit;
bool bEditMode;
......@@ -71,8 +71,8 @@ class SVX_DLLPUBLIC GraphCtrl : public Control
protected:
SdrModel* pModel;
SdrView* pView;
std::unique_ptr<SdrModel> pModel;
std::unique_ptr<SdrView> pView;
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
virtual void Resize() override;
......@@ -87,7 +87,7 @@ protected:
virtual void SdrObjChanged( const SdrObject& rObj );
virtual void MarkListHasChanged();
SdrObjUserCall* GetSdrUserCall() { return pUserCall; }
SdrObjUserCall* GetSdrUserCall() { return pUserCall.get(); }
public:
......@@ -108,8 +108,8 @@ public:
void SetObjKind( const SdrObjKind eObjKind );
SdrModel* GetSdrModel() const { return pModel; }
SdrView* GetSdrView() const { return pView; }
SdrModel* GetSdrModel() const { return pModel.get(); }
SdrView* GetSdrView() const { return pView.get(); }
SdrObject* GetSelectedSdrObject() const;
bool IsChanged() const { return mbSdrMode && pModel->IsChanged(); }
......
......@@ -65,7 +65,7 @@ GraphCtrl::GraphCtrl( vcl::Window* pParent, WinBits nStyle ) :
pModel ( nullptr ),
pView ( nullptr )
{
pUserCall = new GraphCtrlUserCall( *this );
pUserCall.reset(new GraphCtrlUserCall( *this ));
aUpdateIdle.SetPriority( TaskPriority::LOWEST );
aUpdateIdle.SetInvokeHandler( LINK( this, GraphCtrl, UpdateHdl ) );
aUpdateIdle.Start();
......@@ -88,12 +88,9 @@ void GraphCtrl::dispose()
mpAccContext->disposing();
mpAccContext.clear();
}
delete pView;
pView = nullptr;
delete pModel;
pModel = nullptr;
delete pUserCall;
pUserCall = nullptr;
pView.reset();
pModel.reset();
pUserCall.reset();
Control::dispose();
}
......@@ -105,11 +102,8 @@ void GraphCtrl::SetSdrMode(bool bSdrMode)
SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
SetMapMode( aMap100 );
delete pView;
pView = nullptr;
delete pModel;
pModel = nullptr;
pView.reset();
pModel.reset();
if ( mbSdrMode )
InitSdrModel();
......@@ -124,11 +118,11 @@ void GraphCtrl::InitSdrModel()
SdrPage* pPage;
// destroy old junk
delete pView;
delete pModel;
pView.reset();
pModel.reset();
// Creating a Model
pModel = new SdrModel();
pModel.reset(new SdrModel());
pModel->GetItemPool().FreezeIdRanges();
pModel->SetScaleUnit( aMap100.GetMapUnit() );
pModel->SetScaleFraction( Fraction( 1, 1 ) );
......@@ -142,7 +136,7 @@ void GraphCtrl::InitSdrModel()
pModel->SetChanged( false );
// Creating a View
pView = new GraphCtrlView(*pModel, this);
pView.reset(new GraphCtrlView(*pModel, this));
pView->SetWorkArea( tools::Rectangle( Point(), aGraphSize ) );
pView->EnableExtendedMouseEventDispatcher( true );
pView->ShowSdrPage(pView->GetModel()->GetPage(0));
......@@ -157,7 +151,7 @@ void GraphCtrl::InitSdrModel()
// Tell the accessibility object about the changes.
if (mpAccContext.is())
mpAccContext->setModelAndView (pModel, pView);
mpAccContext->setModelAndView (pModel.get(), pView.get());
}
void GraphCtrl::SetGraphic( const Graphic& rGraphic, bool bNewModel )
......@@ -614,7 +608,7 @@ void GraphCtrl::MouseButtonDown( const MouseEvent& rMEvt )
// We want to realize the insert
if ( pCreateObj && !pCreateObj->GetUserCall() )
pCreateObj->SetUserCall( pUserCall );
pCreateObj->SetUserCall( pUserCall.get() );
SetPointer( pView->GetPreferredPointer( aLogPt, this ) );
}
......
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