[Libreoffice-commits] core.git: 2 commits - include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 19 06:12:41 UTC 2018


 include/svx/linectrl.hxx              |    5 +++--
 svx/source/table/tablertfimporter.cxx |   26 ++++++++++----------------
 svx/source/tbxctrls/linectrl.cxx      |    8 ++------
 3 files changed, 15 insertions(+), 24 deletions(-)

New commits:
commit 55dd09e3e5867a0dbaca53b8a3425839e5210234
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Feb 6 15:01:33 2018 +0200

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

diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx
index 3860bf1759b2..46f43cd6b377 100644
--- a/svx/source/table/tablertfimporter.cxx
+++ b/svx/source/table/tablertfimporter.cxx
@@ -81,7 +81,6 @@ class SdrTableRTFParser
 {
 public:
     explicit SdrTableRTFParser( SdrTableObj& rTableObj );
-    ~SdrTableRTFParser();
 
     void Read( SvStream& rStream );
 
@@ -100,7 +99,7 @@ public:
 
 private:
     SdrTableObj&    mrTableObj;
-    SdrOutliner*    mpOutliner;
+    std::unique_ptr<SdrOutliner> mpOutliner;
     SfxItemPool&    mrItemPool;
 
     RTFCellDefaultVector maDefaultList;
@@ -119,7 +118,7 @@ private:
     std::vector< sal_Int32 >::iterator maLastEdge;
     std::vector< RTFColumnVectorPtr > maRows;
 
-    RTFCellDefault* mpInsDefault;
+    std::unique_ptr<RTFCellDefault> mpInsDefault;
     RTFCellDefault* mpActDefault;
     RTFCellDefault* mpDefMerge;
 
@@ -148,13 +147,7 @@ SdrTableRTFParser::SdrTableRTFParser( SdrTableObj& rTableObj )
 {
     mpOutliner->SetUpdateMode(true);
     mpOutliner->SetStyleSheet( 0, mrTableObj.GetStyleSheet() );
-    mpInsDefault = new RTFCellDefault( &mrItemPool );
-}
-
-SdrTableRTFParser::~SdrTableRTFParser()
-{
-    delete mpOutliner;
-    delete mpInsDefault;
+    mpInsDefault.reset( new RTFCellDefault( &mrItemPool ) );
 }
 
 void SdrTableRTFParser::Read( SvStream& rStream )
@@ -402,7 +395,7 @@ void SdrTableRTFParser::ProcToken( RtfImportInfo* pInfo )
         break;
         case RTF_CLMGF:         // The first cell of cells to be merged
         {
-            mpDefMerge = mpInsDefault;
+            mpDefMerge = mpInsDefault.get();
             mnLastToken = pInfo->nToken;
         }
         break;
@@ -431,19 +424,20 @@ void SdrTableRTFParser::ProcToken( RtfImportInfo* pInfo )
         case RTF_CELLX:         // closes cell default
         {
             mbNewDef = true;
-            maDefaultList.push_back( std::shared_ptr< RTFCellDefault >( mpInsDefault ) );
+            std::shared_ptr<RTFCellDefault> pDefault( mpInsDefault.release() );
+            maDefaultList.push_back( pDefault );
 
 
             const sal_Int32 nSize = TwipsToHundMM( pInfo->nTokenValue );
             if ( nSize > mnLastEdge )
                 InsertColumnEdge( nSize );
 
-            mpInsDefault->mnCellX = nSize;
+            pDefault->mnCellX = nSize;
             // Record cellx in the first merged cell.
-            if ( mpDefMerge && mpInsDefault->mnColSpan == 0 )
+            if ( mpDefMerge && pDefault->mnColSpan == 0 )
                 mpDefMerge->mnCellX = nSize;
 
-            mpInsDefault = new RTFCellDefault( &mrItemPool );
+            mpInsDefault.reset( new RTFCellDefault( &mrItemPool ) );
 
             mnLastToken = pInfo->nToken;
         }
@@ -463,7 +457,7 @@ void SdrTableRTFParser::ProcToken( RtfImportInfo* pInfo )
             if ( mbNewDef || !mpActDefault )
                 NewCellRow();
             if ( !mpActDefault )
-                mpActDefault = mpInsDefault;
+                mpActDefault = mpInsDefault.get();
             if ( mpActDefault->mnColSpan > 0 )
             {
                 InsertCell(pInfo);
commit e7d2ebe2fdb05ccdc742cc7c3d910880ba73ceef
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Feb 6 14:56:30 2018 +0200

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

diff --git a/include/svx/linectrl.hxx b/include/svx/linectrl.hxx
index 2c476118d446..a2b1a484e18a 100644
--- a/include/svx/linectrl.hxx
+++ b/include/svx/linectrl.hxx
@@ -25,6 +25,7 @@
 #include <sfx2/tbxctrl.hxx>
 #include <svx/svxdllapi.h>
 #include <svx/xtable.hxx>
+#include <memory>
 
 class XLineStyleItem;
 class XLineDashItem;
@@ -38,8 +39,8 @@ class SvxMetricField;
 class SVX_DLLPUBLIC SvxLineStyleToolBoxControl : public SfxToolBoxControl
 {
 private:
-    XLineStyleItem*     pStyleItem;
-    XLineDashItem*      pDashItem;
+    std::unique_ptr<XLineStyleItem>  pStyleItem;
+    std::unique_ptr<XLineDashItem>   pDashItem;
 
     bool                bUpdate;
 
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index d562abf9b4ca..4360b8155156 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -69,8 +69,6 @@ SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId,
 
 SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl()
 {
-    delete pStyleItem;
-    delete pDashItem;
 }
 
 
@@ -95,13 +93,11 @@ void SvxLineStyleToolBoxControl::StateChanged (
         {
             if( nSID == SID_ATTR_LINE_STYLE )
             {
-                delete pStyleItem;
-                pStyleItem = static_cast<XLineStyleItem*>(pState->Clone());
+                pStyleItem.reset( static_cast<XLineStyleItem*>(pState->Clone()) );
             }
             else if( nSID == SID_ATTR_LINE_DASH )
             {
-                delete pDashItem;
-                pDashItem = static_cast<XLineDashItem*>(pState->Clone());
+                pDashItem.reset( static_cast<XLineDashItem*>(pState->Clone()) );
             }
 
             bUpdate = true;


More information about the Libreoffice-commits mailing list