[Libreoffice-commits] core.git: sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 25 09:09:12 UTC 2018


 sw/inc/view.hxx                      |   20 ++++++++++----------
 sw/source/uibase/docvw/edtwin.cxx    |    5 +++--
 sw/source/uibase/uiview/view.cxx     |   17 ++++++++---------
 sw/source/uibase/uiview/view1.cxx    |    2 +-
 sw/source/uibase/uiview/viewdraw.cxx |   29 ++++++++++++++---------------
 sw/source/uibase/wrtsh/move.cxx      |    1 +
 6 files changed, 37 insertions(+), 37 deletions(-)

New commits:
commit 16ebb85eef0656482207f8030a3abead37cea867
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jul 24 12:08:44 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 25 11:08:47 2018 +0200

    loplugin:useuniqueptr in SwView
    
    Change-Id: Ifcb8320dff5e596afe1240280f64099480a6721c
    Reviewed-on: https://gerrit.libreoffice.org/57947
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index cb32b2180a32..7f8b78e674f4 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -184,7 +184,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
     SfxShell            *m_pShell;        // current SubShell at the dispatcher
     FmFormShell         *m_pFormShell;    // DB-FormShell
 
-    SwView_Impl         *m_pViewImpl;     // Impl-data for UNO + Basic
+    std::unique_ptr<SwView_Impl> m_pViewImpl;     // Impl-data for UNO + Basic
 
     VclPtr<SwScrollbar>  m_pHScrollbar,   // MDI control elements
                          m_pVScrollbar;
@@ -199,14 +199,14 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
                         m_pVRuler;
     VclPtr<ImageButton> m_pTogglePageBtn;
 
-    SwGlossaryHdl       *m_pGlosHdl;          // handle text block
-    SwDrawBase          *m_pDrawActual;
+    std::unique_ptr<SwGlossaryHdl> m_pGlosHdl;          // handle text block
+    std::unique_ptr<SwDrawBase>    m_pDrawActual;
 
     const SwFrameFormat      *m_pLastTableFormat;
 
-    SwFormatClipboard   *m_pFormatClipboard; //holds data for format paintbrush
+    std::unique_ptr<SwFormatClipboard> m_pFormatClipboard; //holds data for format paintbrush
 
-    SwPostItMgr         *m_pPostItMgr;
+    std::unique_ptr<SwPostItMgr> m_pPostItMgr;
 
     SelectionType       m_nSelectionType;
     VclPtr<FloatingWindow> m_pFieldPopup;
@@ -334,7 +334,7 @@ public: // #i123922# Needs to be called from a 2nd place now as a helper method
 
 protected:
 
-    SwView_Impl*    GetViewImpl() {return m_pViewImpl;}
+    SwView_Impl*    GetViewImpl() {return m_pViewImpl.get();}
 
     void ImpSetVerb( SelectionType nSelType );
 
@@ -512,8 +512,8 @@ public:
     void            ExecNumberingOutline(SfxItemPool &);
 
     // functions for drawing
-    void            SetDrawFuncPtr(SwDrawBase* pFuncPtr);
-    SwDrawBase* GetDrawFuncPtr() const  { return m_pDrawActual; }
+    void            SetDrawFuncPtr(std::unique_ptr<SwDrawBase> pFuncPtr);
+    SwDrawBase*     GetDrawFuncPtr() const  { return m_pDrawActual.get(); }
     void            GetDrawState(SfxItemSet &rSet);
     void            ExitDraw();
     bool     IsDrawRotate()      { return m_bDrawRotate; }
@@ -620,8 +620,8 @@ public:
 
     void ExecuteScan( SfxRequest& rReq );
 
-    SwPostItMgr* GetPostItMgr() { return m_pPostItMgr;}
-    const SwPostItMgr* GetPostItMgr() const { return m_pPostItMgr;}
+    SwPostItMgr* GetPostItMgr() { return m_pPostItMgr.get();}
+    const SwPostItMgr* GetPostItMgr() const { return m_pPostItMgr.get();}
 
     // exhibition hack (MA,MBA)
     void SelectShellForDrop();
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index bd468aa41d5c..14011cbb7b38 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -157,6 +157,7 @@
 #include <i18nlangtag/mslangid.hxx>
 #include <salhelper/singletonref.hxx>
 #include <sfx2/event.hxx>
+#include <o3tl/make_unique.hxx>
 #include <memory>
 
 using namespace sw::mark;
@@ -711,9 +712,9 @@ void SwEditWin::StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect )
     SetSdrDrawMode( eSdrObjectKind );
 
     if (bObjSelect)
-        m_rView.SetDrawFuncPtr(new DrawSelection( &m_rView.GetWrtShell(), this, &m_rView ));
+        m_rView.SetDrawFuncPtr(o3tl::make_unique<DrawSelection>( &m_rView.GetWrtShell(), this, &m_rView ));
     else
-        m_rView.SetDrawFuncPtr(new SwDrawBase( &m_rView.GetWrtShell(), this, &m_rView ));
+        m_rView.SetDrawFuncPtr(o3tl::make_unique<SwDrawBase>( &m_rView.GetWrtShell(), this, &m_rView ));
 
     m_rView.SetSelDrawSlot();
     SetSdrDrawMode( eSdrObjectKind );
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 17de503f2082..2dbf557bc291 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -771,7 +771,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     CreateScrollbar( true );
     CreateScrollbar( false );
 
-    m_pViewImpl = new SwView_Impl(this);
+    m_pViewImpl.reset(new SwView_Impl(this));
     SetName("View");
     SetWindow( m_pEditWin );
 
@@ -925,7 +925,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
 
     // Set DocShell
     m_xGlueDocShell.reset(new SwViewGlueDocShell(*this, rDocSh));
-    m_pPostItMgr = new SwPostItMgr(this);
+    m_pPostItMgr.reset(new SwPostItMgr(this));
 
     // Check and process the DocSize. Via the handler, the shell could not
     // be found, because the shell is not known in the SFX management
@@ -1070,8 +1070,7 @@ SwView::~SwView()
     SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
 
     GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener ) );
-    delete m_pPostItMgr;
-    m_pPostItMgr = nullptr;
+    m_pPostItMgr.reset();
 
     m_bInDtor = true;
     m_pEditWin->Hide(); // prevent problems with painting
@@ -1099,8 +1098,8 @@ SwView::~SwView()
     m_pHRuler.disposeAndClear();
     m_pVRuler.disposeAndClear();
     m_pTogglePageBtn.disposeAndClear();
-    delete m_pGlosHdl;
-    delete m_pViewImpl;
+    m_pGlosHdl.reset();
+    m_pViewImpl.reset();
 
     // If this was enabled in the ctor for the frame, then disable it here.
     static bool bRequestDoubleBuffering = getenv("VCL_DOUBLEBUFFERING_ENABLE");
@@ -1108,7 +1107,7 @@ SwView::~SwView()
         m_pEditWin->RequestDoubleBuffering(false);
     m_pEditWin.disposeAndClear();
 
-    delete m_pFormatClipboard;
+    m_pFormatClipboard.reset();
 }
 
 SwDocShell* SwView::GetDocShell()
@@ -1608,8 +1607,8 @@ OUString SwView::GetSelectionTextParam( bool bCompleteWrds, bool bEraseTrail )
 SwGlossaryHdl* SwView::GetGlosHdl()
 {
     if(!m_pGlosHdl)
-        m_pGlosHdl = new SwGlossaryHdl(GetViewFrame(), m_pWrtShell.get());
-    return m_pGlosHdl;
+        m_pGlosHdl.reset(new SwGlossaryHdl(GetViewFrame(), m_pWrtShell.get()));
+    return m_pGlosHdl.get();
 }
 
 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
diff --git a/sw/source/uibase/uiview/view1.cxx b/sw/source/uibase/uiview/view1.cxx
index 404b2e726bf9..e985721e78e5 100644
--- a/sw/source/uibase/uiview/view1.cxx
+++ b/sw/source/uibase/uiview/view1.cxx
@@ -182,7 +182,7 @@ void SwView::ExecFormatPaintbrush(SfxRequest const & rReq)
         m_pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
 
         SwApplyTemplate aTemplate;
-        aTemplate.m_pFormatClipboard = m_pFormatClipboard;
+        aTemplate.m_pFormatClipboard = m_pFormatClipboard.get();
         GetEditWin().SetApplyTemplate(aTemplate);
     }
     GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index 3e6ef6324ec6..4e665239616c 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -234,13 +234,13 @@ void SwView::ExecDraw(SfxRequest& rReq)
     if (m_pWrtShell->IsFrameSelected())
         m_pWrtShell->EnterStdMode();  // because bug #45639
 
-    SwDrawBase* pFuncPtr = nullptr;
+    std::unique_ptr<SwDrawBase> pFuncPtr;
 
     switch (nSlotId)
     {
         case SID_OBJECT_SELECT:
         case SID_DRAW_SELECT:
-            pFuncPtr = new DrawSelection(m_pWrtShell.get(), m_pEditWin, this);
+            pFuncPtr.reset( new DrawSelection(m_pWrtShell.get(), m_pEditWin, this) );
             m_nDrawSfxId = m_nFormSfxId = SID_OBJECT_SELECT;
             m_sDrawCustom.clear();
             break;
@@ -262,7 +262,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
         case SID_DRAW_TEXT_MARQUEE:
         case SID_DRAW_CAPTION:
         case SID_DRAW_CAPTION_VERTICAL:
-            pFuncPtr = new ConstRectangle(m_pWrtShell.get(), m_pEditWin, this);
+            pFuncPtr.reset( new ConstRectangle(m_pWrtShell.get(), m_pEditWin, this) );
             m_nDrawSfxId = nSlotId;
             m_sDrawCustom.clear();
             break;
@@ -275,7 +275,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
         case SID_DRAW_BEZIER_FILL:
         case SID_DRAW_FREELINE_NOFILL:
         case SID_DRAW_FREELINE:
-            pFuncPtr = new ConstPolygon(m_pWrtShell.get(), m_pEditWin, this);
+            pFuncPtr.reset( new ConstPolygon(m_pWrtShell.get(), m_pEditWin, this) );
             m_nDrawSfxId = nSlotId;
             m_sDrawCustom.clear();
             break;
@@ -283,7 +283,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
         case SID_DRAW_ARC:
         case SID_DRAW_PIE:
         case SID_DRAW_CIRCLECUT:
-            pFuncPtr = new ConstArc(m_pWrtShell.get(), m_pEditWin, this);
+            pFuncPtr.reset( new ConstArc(m_pWrtShell.get(), m_pEditWin, this) );
             m_nDrawSfxId = nSlotId;
             m_sDrawCustom.clear();
             break;
@@ -293,7 +293,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
             const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
             if( pIdentifierItem )
                 nSlotId = pIdentifierItem->GetValue();
-            pFuncPtr = new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this);
+            pFuncPtr.reset( new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this) );
             m_nFormSfxId = nSlotId;
         }
         break;
@@ -306,7 +306,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
         case SID_DRAWTBX_CS_STAR :
         case SID_DRAW_CS_ID :
         {
-            pFuncPtr = new ConstCustomShape(m_pWrtShell.get(), m_pEditWin, this, rReq );
+            pFuncPtr.reset( new ConstCustomShape(m_pWrtShell.get(), m_pEditWin, this, rReq ) );
             m_nDrawSfxId = nSlotId;
             if ( nSlotId != SID_DRAW_CS_ID )
             {
@@ -333,13 +333,13 @@ void SwView::ExecDraw(SfxRequest& rReq)
         if (GetDrawFuncPtr())
         {
             GetDrawFuncPtr()->Deactivate();
-            SetDrawFuncPtr(nullptr);
         }
 
-        SetDrawFuncPtr(pFuncPtr);
+        auto pTempFuncPtr = pFuncPtr.get();
+        SetDrawFuncPtr(std::move(pFuncPtr));
         AttrChangedNotify(m_pWrtShell.get());
 
-        pFuncPtr->Activate(nSlotId);
+        pTempFuncPtr->Activate(nSlotId);
         NoRotate();
         if(rReq.GetModifier() == KEY_MOD1)
         {
@@ -349,8 +349,8 @@ void SwView::ExecDraw(SfxRequest& rReq)
             }
             else
             {
-                pFuncPtr->CreateDefaultObject();
-                pFuncPtr->Deactivate();
+                pTempFuncPtr->CreateDefaultObject();
+                pTempFuncPtr->Deactivate();
                 SetDrawFuncPtr(nullptr);
                 LeaveDrawCreate();
                 m_pWrtShell->EnterStdMode();
@@ -633,10 +633,9 @@ bool SwView::IsFormMode() const
     return AreOnlyFormsSelected();
 }
 
-void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
+void SwView::SetDrawFuncPtr(std::unique_ptr<SwDrawBase> pFuncPtr)
 {
-    delete m_pDrawActual;
-    m_pDrawActual = pFuncPtr;
+    m_pDrawActual = std::move(pFuncPtr);
 }
 
 void SwView::SetSelDrawSlot()
diff --git a/sw/source/uibase/wrtsh/move.cxx b/sw/source/uibase/wrtsh/move.cxx
index 91f629cddb25..a848e1d18dc2 100644
--- a/sw/source/uibase/wrtsh/move.cxx
+++ b/sw/source/uibase/wrtsh/move.cxx
@@ -21,6 +21,7 @@
 #include <wrtsh.hxx>
 #include <view.hxx>
 #include <viewopt.hxx>
+#include <drawbase.hxx>
 
 /**
    Always:


More information about the Libreoffice-commits mailing list