filter/source/msfilter/escherex.cxx | 38 ++++++++++++++--------------------- include/filter/msfilter/escherex.hxx | 15 ++++++++++--- 2 files changed, 27 insertions(+), 26 deletions(-)
New commits: commit 8f8a1e301c7f5b9e924e192ab68b7baa23dcc47a Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Oct 18 16:11:00 2017 +0200 use std::unique_ptr in EscherSolverContainer Change-Id: I46d10aec5b69d120dfca8fea076013664cbb3278 Reviewed-on: https://gerrit.libreoffice.org/43527 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 4efaa4fffcc6..7e5e3e1460df 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -19,6 +19,7 @@ #include "eschesdo.hxx" #include <o3tl/any.hxx> +#include <o3tl/make_unique.hxx> #include <svx/svdxcgv.hxx> #include <svx/svdomedia.hxx> #include <svx/xflftrit.hxx> @@ -3816,14 +3817,11 @@ EscherPersistTable::EscherPersistTable() EscherPersistTable::~EscherPersistTable() { - for(EscherPersistEntry* i : maPersistTable) { - delete i; - } } bool EscherPersistTable::PtIsID( sal_uInt32 nID ) { - for(EscherPersistEntry* pPtr : maPersistTable) { + for(auto const & pPtr : maPersistTable) { if ( pPtr->mnID == nID ) { return true; } @@ -3833,16 +3831,14 @@ bool EscherPersistTable::PtIsID( sal_uInt32 nID ) void EscherPersistTable::PtInsert( sal_uInt32 nID, sal_uInt32 nOfs ) { - maPersistTable.push_back( new EscherPersistEntry( nID, nOfs ) ); + maPersistTable.push_back( o3tl::make_unique<EscherPersistEntry>( nID, nOfs ) ); } void EscherPersistTable::PtDelete( sal_uInt32 nID ) { - ::std::vector< EscherPersistEntry* >::iterator it = maPersistTable.begin(); - for( ; it != maPersistTable.end() ; ++it ) + for(auto it = maPersistTable.begin(); it != maPersistTable.end() ; ++it) { if ( (*it)->mnID == nID ) { - delete *it; maPersistTable.erase( it ); break; } @@ -3851,7 +3847,7 @@ void EscherPersistTable::PtDelete( sal_uInt32 nID ) sal_uInt32 EscherPersistTable::PtGetOffsetByID( sal_uInt32 nID ) { - for(EscherPersistEntry* pPtr : maPersistTable) { + for(auto const & pPtr : maPersistTable) { if ( pPtr->mnID == nID ) { return pPtr->mnOffset; } @@ -3861,7 +3857,7 @@ sal_uInt32 EscherPersistTable::PtGetOffsetByID( sal_uInt32 nID ) void EscherPersistTable::PtReplace( sal_uInt32 nID, sal_uInt32 nOfs ) { - for(EscherPersistEntry* pPtr : maPersistTable) { + for(auto const & pPtr : maPersistTable) { if ( pPtr->mnID == nID ) { pPtr->mnOffset = nOfs; return; @@ -3871,7 +3867,7 @@ void EscherPersistTable::PtReplace( sal_uInt32 nID, sal_uInt32 nOfs ) void EscherPersistTable::PtReplaceOrInsert( sal_uInt32 nID, sal_uInt32 nOfs ) { - for(EscherPersistEntry* pPtr : maPersistTable) { + for(auto const & pPtr : maPersistTable) { if ( pPtr->mnID == nID ) { pPtr->mnOffset = nOfs; return; @@ -4673,19 +4669,17 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) return nRule; } +EscherSolverContainer::EscherSolverContainer() +{ +} + EscherSolverContainer::~EscherSolverContainer() { - for(EscherShapeListEntry* i : maShapeList) { - delete i; - } - for(EscherConnectorListEntry* i : maConnectorList) { - delete i; - } } void EscherSolverContainer::AddShape( const css::uno::Reference< css::drawing::XShape > & rXShape, sal_uInt32 nId ) { - maShapeList.push_back( new EscherShapeListEntry( rXShape, nId ) ); + maShapeList.push_back( o3tl::make_unique<EscherShapeListEntry>( rXShape, nId ) ); } void EscherSolverContainer::AddConnector( @@ -4696,12 +4690,12 @@ void EscherSolverContainer::AddConnector( css::uno::Reference< css::drawing::XShape > const & rConB ) { - maConnectorList.push_back( new EscherConnectorListEntry( rConnector, rPA, rConA, rPB, rConB ) ); + maConnectorList.push_back( o3tl::make_unique<EscherConnectorListEntry>( rConnector, rPA, rConA, rPB, rConB ) ); } sal_uInt32 EscherSolverContainer::GetShapeId( const css::uno::Reference< css::drawing::XShape > & rXShape ) const { - for (EscherShapeListEntry* pPtr : maShapeList) + for (auto const & pPtr : maShapeList) { if ( rXShape == pPtr->aXShape ) return pPtr->n_EscherId; @@ -4723,7 +4717,7 @@ void EscherSolverContainer::WriteSolver( SvStream& rStrm ) EscherConnectorRule aConnectorRule; aConnectorRule.nRuleId = 2; - for (EscherConnectorListEntry* pPtr : maConnectorList) + for (auto const & pPtr : maConnectorList) { aConnectorRule.ncptiA = aConnectorRule.ncptiB = 0xffffffff; aConnectorRule.nShapeC = GetShapeId( pPtr->mXConnector ); @@ -4966,7 +4960,7 @@ void EscherEx::InsertAtCurrentPos( sal_uInt32 nBytes ) sal_uInt32 nSize, nType, nSource, nBufSize, nToCopy, nCurPos = mpOutStrm->Tell(); // adjust persist table - for(EscherPersistEntry* pPtr : maPersistTable) { + for(auto const & pPtr : maPersistTable) { sal_uInt32 nOfs = pPtr->mnOffset; if ( nOfs >= nCurPos ) { pPtr->mnOffset += nBytes; diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index 3c125649e9d1..28055688f974 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -606,6 +606,7 @@ public: EscherGraphicProvider( EscherGraphicProviderFlags nFlags = EscherGraphicProviderFlags::NONE ); virtual ~EscherGraphicProvider(); + EscherGraphicProvider& operator=( EscherGraphicProvider const & ) = delete; // MSVC2015 workaround EscherGraphicProvider( EscherGraphicProvider const & ) = delete; // MSVC2015 workaround }; @@ -614,8 +615,8 @@ struct EscherShapeListEntry; class MSFILTER_DLLPUBLIC EscherSolverContainer { - ::std::vector< EscherShapeListEntry* > maShapeList; - ::std::vector< EscherConnectorListEntry* > maConnectorList; + ::std::vector< std::unique_ptr<EscherShapeListEntry> > maShapeList; + ::std::vector< std::unique_ptr<EscherConnectorListEntry> > maConnectorList; public: @@ -638,8 +639,11 @@ public: void WriteSolver( SvStream& ); - EscherSolverContainer(){}; + EscherSolverContainer(); ~EscherSolverContainer(); + + EscherSolverContainer& operator=( EscherSolverContainer const & ) = delete; // MSVC2015 workaround + EscherSolverContainer( EscherSolverContainer const & ) = delete; // MSVC2015 workaround }; @@ -856,7 +860,7 @@ class MSFILTER_DLLPUBLIC EscherPersistTable { public: - ::std::vector< EscherPersistEntry* > maPersistTable; + ::std::vector< std::unique_ptr<EscherPersistEntry> > maPersistTable; bool PtIsID( sal_uInt32 nID ); void PtInsert( sal_uInt32 nID, sal_uInt32 nOfs ); @@ -867,6 +871,9 @@ public: EscherPersistTable(); virtual ~EscherPersistTable(); + + EscherPersistTable& operator=( EscherPersistTable const & ) = delete; // MSVC2015 workaround + EscherPersistTable( EscherPersistTable const & ) = delete; // MSVC2015 workaround }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits