[Libreoffice-commits] core.git: cui/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 21 06:25:50 UTC 2018


 cui/source/inc/numfmt.hxx      |    4 ++--
 cui/source/tabpages/numfmt.cxx |   20 +++++++++-----------
 2 files changed, 11 insertions(+), 13 deletions(-)

New commits:
commit 48c4460d414dd6f60c630af2fc13e1c3db2c3653
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jun 20 15:41:40 2018 +0200

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

diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index 80a3f296cba2..a3ff4a070e40 100644
--- a/cui/source/inc/numfmt.hxx
+++ b/cui/source/inc/numfmt.hxx
@@ -115,8 +115,8 @@ private:
     Timer                   aResetWinTimer;
 
 
-    SvxNumberInfoItem*      pNumItem;
-    SvxNumberFormatShell*   pNumFmtShell;
+    std::unique_ptr<SvxNumberInfoItem>    pNumItem;
+    std::unique_ptr<SvxNumberFormatShell> pNumFmtShell;
     sal_uLong               nInitFormat;
     Link<SfxPoolItem const *,void> fnOkHdl;
 
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index ecfa8ff6f7ab..2aa9505507e6 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -286,10 +286,8 @@ SvxNumberFormatTabPage::~SvxNumberFormatTabPage()
 
 void SvxNumberFormatTabPage::dispose()
 {
-    delete pNumFmtShell;
-    pNumFmtShell = nullptr;
-    delete pNumItem;
-    pNumItem = nullptr;
+    pNumFmtShell.reset();
+    pNumItem.reset();
     m_pFtCategory.clear();
     m_pLbCategory.clear();
     m_pFtFormat.clear();
@@ -430,7 +428,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
         if(pNumItem==nullptr)
         {
             bNumItemFlag=true;
-            pNumItem= static_cast<SvxNumberInfoItem *>(pItem->Clone());
+            pNumItem.reset( static_cast<SvxNumberInfoItem *>(pItem->Clone()) );
         }
         else
         {
@@ -502,7 +500,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
             break;
     }
 
-    delete pNumFmtShell;   // delete old shell if applicable (== reset)
+    pNumFmtShell.reset();   // delete old shell if applicable (== reset)
 
     nInitFormat = pValFmtAttr                   // memorize init key
                     ? pValFmtAttr->GetValue()   // (for FillItemSet())
@@ -510,18 +508,18 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
 
 
     if ( eValType == SvxNumberValueType::String )
-        pNumFmtShell =SvxNumberFormatShell::Create(
+        pNumFmtShell.reset( SvxNumberFormatShell::Create(
                                 pNumItem->GetNumberFormatter(),
                                 pValFmtAttr ? nInitFormat : 0,
                                 eValType,
-                                aValString );
+                                aValString ) );
     else
-        pNumFmtShell =SvxNumberFormatShell::Create(
+        pNumFmtShell.reset( SvxNumberFormatShell::Create(
                                 pNumItem->GetNumberFormatter(),
                                 pValFmtAttr ? nInitFormat : 0,
                                 eValType,
                                 nValDouble,
-                                &aValString );
+                                &aValString ) );
 
 
     bool bUseStarFormat = false;
@@ -1822,7 +1820,7 @@ void SvxNumberFormatTabPage::PageCreated(const SfxAllItemSet& aSet)
     const SvxNumberInfoItem* pNumberInfoItem = aSet.GetItem<SvxNumberInfoItem>(SID_ATTR_NUMBERFORMAT_INFO, false);
     const SfxLinkItem* pLinkItem = aSet.GetItem<SfxLinkItem>(SID_LINK_TYPE, false);
     if (pNumberInfoItem && !pNumItem)
-        pNumItem = static_cast<SvxNumberInfoItem*>(pNumberInfoItem->Clone());
+        pNumItem.reset( static_cast<SvxNumberInfoItem*>(pNumberInfoItem->Clone()) );
     if (pLinkItem)
         fnOkHdl = pLinkItem->GetValue();
 }


More information about the Libreoffice-commits mailing list