From 818b837790c0807e508fc1246df3d2e07520529f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 27 Jul 2018 09:37:11 +0200 Subject: loplugin:useuniqueptr in SwInsertDBColAutoPilot Change-Id: Ida2be4abdeb6788ec9074a81c927e99e633ce394 Reviewed-on: https://gerrit.libreoffice.org/58247 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/ui/dbui/dbinsdlg.cxx | 23 ++++++++++------------- sw/source/uibase/inc/dbinsdlg.hxx | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 42d6728c880c..33ab1ede2128 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -416,8 +416,8 @@ SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot() void SwInsertDBColAutoPilot::dispose() { - delete pTableSet; - delete pRep; + pTableSet.reset(); + pRep.reset(); m_xTAutoFormat.reset(); m_pRbAsTable.clear(); @@ -659,7 +659,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, TableFormatHdl, Button*, pButton, void ) if( !pTableSet ) { bNewSet = true; - pTableSet = new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() ); + pTableSet.reset(new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() )); // At first acquire the simple attributes pTableSet->Put( SfxStringItem( FN_PARAM_TABLE_NAME, rSh.GetUniqueTableName() )); @@ -721,12 +721,12 @@ IMPL_LINK( SwInsertDBColAutoPilot, TableFormatHdl, Button*, pButton, void ) SwTabCols aTabCols; aTabCols.SetRight( nWidth ); aTabCols.SetRightMax( nWidth ); - pRep = new SwTableRep( aTabCols ); + pRep.reset(new SwTableRep( aTabCols )); pRep->SetAlign( text::HoriOrientation::NONE ); pRep->SetSpace( nWidth ); pRep->SetWidth( nWidth ); pRep->SetWidthPercent( 100 ); - pTableSet->Put( SwPtrItem( FN_TABLE_REP, pRep )); + pTableSet->Put( SwPtrItem( FN_TABLE_REP, pRep.get() )); pTableSet->Put( SfxUInt16Item( SID_HTML_MODE, ::GetHtmlMode( pView->GetDocShell() ))); @@ -749,27 +749,24 @@ IMPL_LINK( SwInsertDBColAutoPilot, TableFormatHdl, Button*, pButton, void ) aTabCols.Insert( nStep*(n+1), false, n ); } } - delete pRep; - pRep = new SwTableRep( aTabCols ); + pRep.reset(new SwTableRep( aTabCols )); pRep->SetAlign( text::HoriOrientation::NONE ); pRep->SetSpace( nWidth ); pRep->SetWidth( nWidth ); pRep->SetWidthPercent( 100 ); - pTableSet->Put( SwPtrItem( FN_TABLE_REP, pRep )); + pTableSet->Put( SwPtrItem( FN_TABLE_REP, pRep.get() )); } SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - ScopedVclPtr pDlg(pFact->CreateSwTableTabDlg(pButton, pTableSet, &rSh)); + ScopedVclPtr pDlg(pFact->CreateSwTableTabDlg(pButton, pTableSet.get(), &rSh)); if( RET_OK == pDlg->Execute() ) pTableSet->Put( *pDlg->GetOutputItemSet() ); else if( bNewSet ) { - delete pTableSet; - pTableSet = nullptr; - delete pRep; - pRep = nullptr; + pTableSet.reset(); + pRep.reset(); } } diff --git a/sw/source/uibase/inc/dbinsdlg.hxx b/sw/source/uibase/inc/dbinsdlg.hxx index 2ed40956a68d..c3362a52686c 100644 --- a/sw/source/uibase/inc/dbinsdlg.hxx +++ b/sw/source/uibase/inc/dbinsdlg.hxx @@ -128,8 +128,8 @@ class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem SwView* pView; std::unique_ptr m_xTAutoFormat; - SfxItemSet* pTableSet; - SwTableRep* pRep; + std::unique_ptr pTableSet; + std::unique_ptr pRep; sal_Int32 nGBFormatLen; DECL_LINK( PageHdl, Button*, void ); -- cgit