include/svx/svdetc.hxx | 2 +- sfx2/source/doc/doctemplates.cxx | 20 +++++++++----------- svx/source/svdraw/svdedxv.cxx | 6 +++--- svx/source/svdraw/svdetc.cxx | 6 +++--- 4 files changed, 16 insertions(+), 18 deletions(-)
New commits: commit a064fb2008e69c20595f60b6d55dd9d691e2e9e2 Author: Noel Grandin <[email protected]> AuthorDate: Tue Dec 18 14:50:59 2018 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Dec 19 07:04:41 2018 +0100 use unique_ptr in RemoveWhichRange Change-Id: I6c0f07f0dc4a7f6bfa15c0ea720f349894559429 Reviewed-on: https://gerrit.libreoffice.org/65340 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx index abd5c886ef2b..94d3db0240ee 100644 --- a/include/svx/svdetc.hxx +++ b/include/svx/svdetc.hxx @@ -103,7 +103,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl /** * @returns a new WhichTable, which we need to squash at some point with a delete */ -sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd); +std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd); /** * Helper class for the communication between the dialog diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index d2a4cff5710d..be6e6897576a 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -2129,9 +2129,9 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) // Otherwise split Set, if necessary. // Now we build an ItemSet aSet that doesn't contain EE_Items from // *pSet (otherwise it would be a copy). - sal_uInt16* pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END); - SfxItemSet aSet(mpModel->GetItemPool(),pNewWhichTable); - delete[] pNewWhichTable; + std::unique_ptr<sal_uInt16[]> pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END); + SfxItemSet aSet(mpModel->GetItemPool(),pNewWhichTable.get()); + pNewWhichTable.reset(); SfxWhichIter aIter(aSet); sal_uInt16 nWhich=aIter.FirstWhich(); while (nWhich!=0) diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 46efe26887d2..3e73c8a282fc 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -377,7 +377,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl return bHas; } -sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd) +std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd) { // Six possible cases (per range): // [Beg..End] Range, to delete @@ -403,8 +403,8 @@ sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRange else /* nCase=6 */ nAlloc+=2; } - sal_uInt16* pNewWhichTable=new sal_uInt16[nAlloc]; - memcpy(pNewWhichTable,pOldWhichTable,nAlloc*sizeof(sal_uInt16)); + std::unique_ptr<sal_uInt16[]> pNewWhichTable(new sal_uInt16[nAlloc]); + memcpy(pNewWhichTable.get(), pOldWhichTable, nAlloc*sizeof(sal_uInt16)); pNewWhichTable[nAlloc-1]=0; // in case 3, there's no 0 at the end. // now remove the unwanted ranges nNum=nAlloc-1; commit 6774e3cebf5937f8771cc0f0850696a5154ca283 Author: Noel Grandin <[email protected]> AuthorDate: Tue Dec 18 14:41:18 2018 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Dec 19 07:04:33 2018 +0100 store GroupData_Impl using unique_ptr Change-Id: Ib2f00c10b91ced44c7476290360485c8550ec718 Reviewed-on: https://gerrit.libreoffice.org/65339 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index bd17b7b9e78a..c6027ffbd92f 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -158,7 +158,7 @@ struct NamePair_Impl class DocTemplates_EntryData_Impl; class GroupData_Impl; -typedef vector< GroupData_Impl* > GroupList_Impl; +typedef vector< std::unique_ptr<GroupData_Impl> > GroupList_Impl; class TplTaskEnvironment : public ::cppu::WeakImplHelper< ucb::XCommandEnvironment > @@ -1162,7 +1162,7 @@ void SfxDocTplService_Impl::doUpdate() } // now check the list - for(GroupData_Impl* pGroup : aGroupList) + for(std::unique_ptr<GroupData_Impl>& pGroup : aGroupList) { if ( pGroup->getInUse() ) { @@ -1183,7 +1183,7 @@ void SfxDocTplService_Impl::doUpdate() if ( pData->getInHierarchy() ) removeFromHierarchy( pData ); // delete entry in hierarchy else - addToHierarchy( pGroup, pData ); // add entry to hierarchy + addToHierarchy( pGroup.get(), pData ); // add entry to hierarchy } else if ( pData->getUpdateType() || pData->getUpdateLink() ) @@ -1194,13 +1194,11 @@ void SfxDocTplService_Impl::doUpdate() } else { - addGroupToHierarchy( pGroup ); // add group to hierarchy + addGroupToHierarchy( pGroup.get() ); // add group to hierarchy } } else - removeFromHierarchy( pGroup ); // delete group from hierarchy - - delete pGroup; + removeFromHierarchy( pGroup.get() ); // delete group from hierarchy } aGroupList.clear(); @@ -2343,7 +2341,7 @@ void SfxDocTplService_Impl::addHierGroup( GroupList_Impl& rList, GroupData_Impl *pGroup = new GroupData_Impl( rTitle ); pGroup->setHierarchy( true ); pGroup->setHierarchyURL( rOwnURL ); - rList.push_back( pGroup ); + rList.push_back( std::unique_ptr<GroupData_Impl>(pGroup) ); uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); @@ -2405,11 +2403,11 @@ void SfxDocTplService_Impl::addFsysGroup( GroupList_Impl& rList, return; GroupData_Impl* pGroup = nullptr; - for (GroupData_Impl* i : rList) + for (std::unique_ptr<GroupData_Impl>& i : rList) { if ( i->getTitle() == aTitle ) { - pGroup = i; + pGroup = i.get(); break; } } @@ -2417,7 +2415,7 @@ void SfxDocTplService_Impl::addFsysGroup( GroupList_Impl& rList, if ( !pGroup ) { pGroup = new GroupData_Impl( aTitle ); - rList.push_back( pGroup ); + rList.push_back( std::unique_ptr<GroupData_Impl>(pGroup) ); } if ( bWriteableGroup ) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
