diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-03 12:17:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-04 12:59:44 +0200 |
commit | 6203c2b73db2de239498b517a222c38433fd9168 (patch) | |
tree | 2c2f282e995d60ce73a51d77caa4cbc217dc15f2 /sw/source | |
parent | 55f78bcb63e552559ec6a18e39ae982dd925974a (diff) |
loplugin:useuniqueptr in SwInsDBColumns
Change-Id: Idd159cfd29d487773e478a0cca352fcb77f88a33
Reviewed-on: https://gerrit.libreoffice.org/61340
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/dbui/dbinsdlg.cxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/inc/dbinsdlg.hxx | 4 |
2 files changed, 7 insertions, 10 deletions
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 97d86afa71dc..353474ab236c 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -256,7 +256,7 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, sal_Int32 nCount = aColNames.getLength(); for (sal_Int32 n = 0; n < nCount; ++n) { - SwInsDBColumn* pNew = new SwInsDBColumn( pColNames[n] ); + std::unique_ptr<SwInsDBColumn> pNew(new SwInsDBColumn( pColNames[n] )); Any aCol = xCols->getByName(pColNames[n]); Reference <XPropertySet> xCol; aCol >>= xCol; @@ -319,10 +319,9 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, } break; } - if( !aDBColumns.insert( pNew ).second ) + if( !aDBColumns.insert( std::move(pNew) ).second ) { OSL_ENSURE( false, "Spaltenname mehrfach vergeben?" ); - delete pNew; } } } @@ -1013,7 +1012,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, SwInsDBColumn aSrch( m_pLbTableCol->GetEntry( n ) ); SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch ); if (it != aDBColumns.end()) - aColFields.push_back(*it); + aColFields.push_back(it->get()); else { OSL_ENSURE( false, "database column not found" ); } @@ -1603,7 +1602,7 @@ void SwInsertDBColAutoPilot::ImplCommit() SvNumberFormatter& rNFormatr = *pView->GetWrtShell().GetNumberFormatter(); for(size_t nCol = 0; nCol < aDBColumns.size(); nCol++) { - SwInsDBColumn* pColumn = aDBColumns[nCol]; + SwInsDBColumn* pColumn = aDBColumns[nCol].get(); OUString sColumnInsertNode(sNewNode + "/__"); if( nCol < 10 ) sColumnInsertNode += "00"; @@ -1711,7 +1710,7 @@ void SwInsertDBColAutoPilot::Load() continue; sal_Int16 nIndex = 0; pSubProps[1] >>= nIndex; - SwInsDBColumn* pInsDBColumn = new SwInsDBColumn(sColumn); + std::unique_ptr<SwInsDBColumn> pInsDBColumn(new SwInsDBColumn(sColumn)); if(pSubProps[2].hasValue()) pInsDBColumn->bHasFormat = *o3tl::doAccess<bool>(pSubProps[2]); if(pSubProps[3].hasValue()) @@ -1734,7 +1733,7 @@ void SwInsertDBColAutoPilot::Load() pInsDBColumn->nUsrNumFormat = rNFormatr.GetEntryKey( pInsDBColumn->sUsrNumFormat, pInsDBColumn->eUsrNumFormatLng ); - pNewData->aDBColumns.insert(pInsDBColumn); + pNewData->aDBColumns.insert(std::move(pInsDBColumn)); } OUString sTmp( pNewData->sTableList ); if( !sTmp.isEmpty() ) diff --git a/sw/source/uibase/inc/dbinsdlg.hxx b/sw/source/uibase/inc/dbinsdlg.hxx index c260b2b07c23..e727af3dd5e3 100644 --- a/sw/source/uibase/inc/dbinsdlg.hxx +++ b/sw/source/uibase/inc/dbinsdlg.hxx @@ -78,10 +78,8 @@ struct SwInsDBColumn bool operator<( const SwInsDBColumn& rCmp ) const; }; -class SwInsDBColumns : public o3tl::sorted_vector<SwInsDBColumn*, o3tl::less_ptr_to<SwInsDBColumn> > +class SwInsDBColumns : public o3tl::sorted_vector<std::unique_ptr<SwInsDBColumn>, o3tl::less_uniqueptr_to<SwInsDBColumn> > { -public: - ~SwInsDBColumns() { DeleteAndDestroyAll(); } }; class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem |