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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jul 26 06:33:12 UTC 2018


 sw/inc/AnnotationWin.hxx                       |    8 ++++----
 sw/source/uibase/docvw/AnchorOverlayObject.cxx |    8 ++++----
 sw/source/uibase/docvw/AnchorOverlayObject.hxx |    2 +-
 sw/source/uibase/docvw/AnnotationWin.cxx       |    9 ++-------
 sw/source/uibase/docvw/ShadowOverlayObject.cxx |    8 ++++----
 sw/source/uibase/docvw/ShadowOverlayObject.hxx |    2 +-
 6 files changed, 16 insertions(+), 21 deletions(-)

New commits:
commit 0e714e412c9831e4cd710fd9d250615bf3e1547c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 25 11:57:59 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 26 08:32:42 2018 +0200

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

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 54136b22faf5..8579cfb8db6a 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -108,8 +108,8 @@ class SwAnnotationWin : public vcl::Window
         bool HasScrollbar() const;
         bool IsScrollbarVisible() const;
         ScrollBar* Scrollbar() { return mpVScrollbar; }
-        ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;}
-        ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;}
+        ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor.get();}
+        ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow.get();}
         ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();}
 
         long            GetPostItTextHeight();
@@ -221,8 +221,8 @@ class SwAnnotationWin : public vcl::Window
         VclPtr<Edit>           mpMetadataDate;
         VclPtr<MenuButton>     mpMenuButton;
 
-        sw::sidebarwindows::AnchorOverlayObject* mpAnchor;
-        sw::sidebarwindows::ShadowOverlayObject* mpShadow;
+        std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor;
+        std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow;
         std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay;
 
         Color           mColorAnchor;
diff --git a/sw/source/uibase/docvw/AnchorOverlayObject.cxx b/sw/source/uibase/docvw/AnchorOverlayObject.cxx
index e89a79daacd8..0a60d4afff30 100644
--- a/sw/source/uibase/docvw/AnchorOverlayObject.cxx
+++ b/sw/source/uibase/docvw/AnchorOverlayObject.cxx
@@ -172,7 +172,7 @@ bool AnchorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive
 
 ImplPrimitive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
 
-/*static*/ AnchorOverlayObject* AnchorOverlayObject::CreateAnchorOverlayObject(
+/*static*/ std::unique_ptr<AnchorOverlayObject> AnchorOverlayObject::CreateAnchorOverlayObject(
                                                        SwView const & rDocView,
                                                        const SwRect& aAnchorRect,
                                                        long aPageBorder,
@@ -180,7 +180,7 @@ ImplPrimitive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
                                                        const Point& aLineEnd,
                                                        const Color& aColorAnchor )
 {
-    AnchorOverlayObject* pAnchorOverlayObject( nullptr );
+    std::unique_ptr<AnchorOverlayObject> pAnchorOverlayObject;
     if ( rDocView.GetDrawView() )
     {
         SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
@@ -190,7 +190,7 @@ ImplPrimitive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
 
             if ( xOverlayManager.is() )
             {
-                pAnchorOverlayObject = new AnchorOverlayObject(
+                pAnchorOverlayObject.reset(new AnchorOverlayObject(
                     basegfx::B2DPoint( aAnchorRect.Left() , aAnchorRect.Bottom()-5*15),
                     basegfx::B2DPoint( aAnchorRect.Left()-5*15 , aAnchorRect.Bottom()+5*15),
                     basegfx::B2DPoint( aAnchorRect.Left()+5*15 , aAnchorRect.Bottom()+5*15),
@@ -198,7 +198,7 @@ ImplPrimitive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
                     basegfx::B2DPoint( aPageBorder ,aAnchorRect.Bottom()+2*15),
                     basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
                     basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
-                    aColorAnchor);
+                    aColorAnchor));
                 xOverlayManager->add(*pAnchorOverlayObject);
             }
         }
diff --git a/sw/source/uibase/docvw/AnchorOverlayObject.hxx b/sw/source/uibase/docvw/AnchorOverlayObject.hxx
index d249a220c7b7..94f9d48bdd07 100644
--- a/sw/source/uibase/docvw/AnchorOverlayObject.hxx
+++ b/sw/source/uibase/docvw/AnchorOverlayObject.hxx
@@ -40,7 +40,7 @@ enum class AnchorState
 class AnchorOverlayObject final : public sdr::overlay::OverlayObjectWithBasePosition
 {
     public:
-        static AnchorOverlayObject* CreateAnchorOverlayObject( SwView const & rDocView,
+        static std::unique_ptr<AnchorOverlayObject> CreateAnchorOverlayObject( SwView const & rDocView,
                                                                const SwRect& aAnchorRect,
                                                                long aPageBorder,
                                                                const Point& aLineStart,
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index e2fc68e8761d..1cb721e4f4dc 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -78,8 +78,6 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
     , mpMetadataAuthor(nullptr)
     , mpMetadataDate(nullptr)
     , mpMenuButton(nullptr)
-    , mpAnchor(nullptr)
-    , mpShadow(nullptr)
     , mpTextRangeOverlay(nullptr)
     , mColorAnchor()
     , mColorDark()
@@ -166,11 +164,8 @@ void SwAnnotationWin::dispose()
 
     RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) );
 
-    delete mpAnchor;
-    mpAnchor = nullptr;
-
-    delete mpShadow;
-    mpShadow = nullptr;
+    mpAnchor.reset();
+    mpShadow.reset();
 
     mpTextRangeOverlay.reset();
 
diff --git a/sw/source/uibase/docvw/ShadowOverlayObject.cxx b/sw/source/uibase/docvw/ShadowOverlayObject.cxx
index 2f7385d235ec..38bffa2218f9 100644
--- a/sw/source/uibase/docvw/ShadowOverlayObject.cxx
+++ b/sw/source/uibase/docvw/ShadowOverlayObject.cxx
@@ -156,9 +156,9 @@ bool ShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive
 
 ImplPrimitive2DIDBlock(ShadowPrimitive, PRIMITIVE2D_ID_SWSIDEBARSHADOWPRIMITIVE)
 
-/* static */ ShadowOverlayObject* ShadowOverlayObject::CreateShadowOverlayObject( SwView const & rDocView )
+/* static */ std::unique_ptr<ShadowOverlayObject> ShadowOverlayObject::CreateShadowOverlayObject( SwView const & rDocView )
 {
-    ShadowOverlayObject* pShadowOverlayObject( nullptr );
+    std::unique_ptr<ShadowOverlayObject> pShadowOverlayObject;
 
     if ( rDocView.GetDrawView() )
     {
@@ -169,9 +169,9 @@ ImplPrimitive2DIDBlock(ShadowPrimitive, PRIMITIVE2D_ID_SWSIDEBARSHADOWPRIMITIVE)
 
             if ( xOverlayManager.is() )
             {
-                pShadowOverlayObject = new ShadowOverlayObject( basegfx::B2DPoint(0,0),
+                pShadowOverlayObject.reset( new ShadowOverlayObject( basegfx::B2DPoint(0,0),
                                                                 basegfx::B2DPoint(0,0),
-                                                                Color(0,0,0) );
+                                                                Color(0,0,0) ) );
                 xOverlayManager->add(*pShadowOverlayObject);
             }
         }
diff --git a/sw/source/uibase/docvw/ShadowOverlayObject.hxx b/sw/source/uibase/docvw/ShadowOverlayObject.hxx
index 5c4582cbeaf8..637d088eab7b 100644
--- a/sw/source/uibase/docvw/ShadowOverlayObject.hxx
+++ b/sw/source/uibase/docvw/ShadowOverlayObject.hxx
@@ -56,7 +56,7 @@ public:
         void SetPosition( const basegfx::B2DPoint& rPoint1,
                           const basegfx::B2DPoint& rPoint2 );
 
-        static ShadowOverlayObject* CreateShadowOverlayObject( SwView const & rDocView );
+        static std::unique_ptr<ShadowOverlayObject> CreateShadowOverlayObject( SwView const & rDocView );
 };
 
 } } // end of namespace sw::sidebarwindows


More information about the Libreoffice-commits mailing list