From 48c4460d414dd6f60c630af2fc13e1c3db2c3653 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 Jun 2018 15:41:40 +0200 Subject: loplugin:useuniqueptr in SvxNumberFormatTabPage Change-Id: If0fefe4a1e7af7331c708e7e944483ec3ce07614 Reviewed-on: https://gerrit.libreoffice.org/56190 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/inc/numfmt.hxx | 4 ++-- cui/source/tabpages/numfmt.cxx | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'cui') 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 pNumItem; + std::unique_ptr pNumFmtShell; sal_uLong nInitFormat; Link 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(pItem->Clone()); + pNumItem.reset( static_cast(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(SID_ATTR_NUMBERFORMAT_INFO, false); const SfxLinkItem* pLinkItem = aSet.GetItem(SID_LINK_TYPE, false); if (pNumberInfoItem && !pNumItem) - pNumItem = static_cast(pNumberInfoItem->Clone()); + pNumItem.reset( static_cast(pNumberInfoItem->Clone()) ); if (pLinkItem) fnOkHdl = pLinkItem->GetValue(); } -- cgit