[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Oct 4 11:00:15 UTC 2018
sw/source/ui/dbui/dbinsdlg.cxx | 13 ++++++-------
sw/source/uibase/inc/dbinsdlg.hxx | 4 +---
2 files changed, 7 insertions(+), 10 deletions(-)
New commits:
commit 6203c2b73db2de239498b517a222c38433fd9168
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Oct 3 12:17:54 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 4 12:59:44 2018 +0200
loplugin:useuniqueptr in SwInsDBColumns
Change-Id: Idd159cfd29d487773e478a0cca352fcb77f88a33
Reviewed-on: https://gerrit.libreoffice.org/61340
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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
More information about the Libreoffice-commits
mailing list