[Libreoffice-commits] core.git: 2 commits - idlc/inc idlc/source sd/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Mar 23 06:25:24 UTC 2018


 idlc/inc/aststruct.hxx           |    4 -
 idlc/source/aststruct.cxx        |    8 ---
 sd/source/ui/inc/OutlineView.hxx |    4 -
 sd/source/ui/view/outlview.cxx   |   87 +++++++++++++++------------------------
 4 files changed, 40 insertions(+), 63 deletions(-)

New commits:
commit 5053b8cd3f18cb5baa039c343e20b1b87e7b25a5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 22 12:21:56 2018 +0200

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

diff --git a/idlc/inc/aststruct.hxx b/idlc/inc/aststruct.hxx
index 52981cf2b791..bb5ef15152e2 100644
--- a/idlc/inc/aststruct.hxx
+++ b/idlc/inc/aststruct.hxx
@@ -40,7 +40,7 @@ public:
               AstScope* pScope);
     virtual ~AstStruct() override;
 
-    DeclList::size_type getTypeParameterCount() const
+    std::size_t getTypeParameterCount() const
     { return m_typeParameters.size(); }
 
     AstDeclaration const * findTypeParameter(OString const & name) const;
@@ -50,7 +50,7 @@ public:
     virtual bool dump(RegistryKey& rKey) override;
 private:
     AstStruct const* m_pBaseType;
-    DeclList m_typeParameters;
+    std::vector<std::unique_ptr<AstDeclaration>> m_typeParameters;
 };
 
 #endif // INCLUDED_IDLC_INC_ASTSTRUCT_HXX
diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx
index a7db14faaf7f..e06adc2b2bd1 100644
--- a/idlc/source/aststruct.cxx
+++ b/idlc/source/aststruct.cxx
@@ -32,7 +32,7 @@ AstStruct::AstStruct(
 {
     for (auto const& elem : typeParameters)
     {
-        m_typeParameters.push_back(
+        m_typeParameters.emplace_back(
             new AstType(NT_type_parameter, elem, nullptr));
     }
 }
@@ -49,10 +49,6 @@ AstStruct::AstStruct(const NodeType type,
 
 AstStruct::~AstStruct()
 {
-    for (auto const& elem : m_typeParameters)
-    {
-        delete elem;
-    }
 }
 
 AstDeclaration const * AstStruct::findTypeParameter(OString const & name)
@@ -61,7 +57,7 @@ AstDeclaration const * AstStruct::findTypeParameter(OString const & name)
     for (auto const& elem : m_typeParameters)
     {
         if (elem->getLocalName() == name) {
-            return elem;
+            return elem.get();
         }
     }
     return nullptr;
commit 2925ded06627fb7e5408f15288490db7c9f0ebb0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Mar 20 15:40:19 2018 +0200

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

diff --git a/sd/source/ui/inc/OutlineView.hxx b/sd/source/ui/inc/OutlineView.hxx
index 60dc8569e17b..72d2cbee2701 100644
--- a/sd/source/ui/inc/OutlineView.hxx
+++ b/sd/source/ui/inc/OutlineView.hxx
@@ -173,7 +173,7 @@ private:
 
     OutlineViewShell&   mrOutlineViewShell;
     SdrOutliner&        mrOutliner;
-    OutlinerView*       mpOutlinerView[MAX_OUTLINERVIEWS];
+    std::unique_ptr<OutlinerView> mpOutlinerViews[MAX_OUTLINERVIEWS];
 
     std::vector<Paragraph*> maOldParaOrder;
     std::vector<Paragraph*> maSelectedParas;
@@ -185,7 +185,7 @@ private:
 
     sal_uLong               mnPaperWidth;
 
-    SfxProgress*        mpProgress;
+    std::unique_ptr<SfxProgress> mpProgress;
 
     /** stores the last used document color.
         this is changed in onUpdateStyleSettings()
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 ) );


More information about the Libreoffice-commits mailing list