diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-10-25 10:02:24 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-10-26 16:09:19 +0100 |
commit | 192ca71f07390af6528531c0c4c9254c97a98cfc (patch) | |
tree | 5fa1b7dfd7100e4426fd18926806c2c3f46bf04a /basic | |
parent | c791bef561dcf38a4b47dd06534914f7c28ae67e (diff) |
basic: replace boost::ptr_vector with std::vector<std::unqiue_ptr>
Change-Id: Ieba2fb34e0279871d36b4fe80d9de76e614b5cde
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/sbxbase.hxx | 9 | ||||
-rw-r--r-- | basic/source/sbx/sbxbase.cxx | 26 |
2 files changed, 20 insertions, 15 deletions
diff --git a/basic/inc/sbxbase.hxx b/basic/inc/sbxbase.hxx index 21bb7d4a3686..81776435c852 100644 --- a/basic/inc/sbxbase.hxx +++ b/basic/inc/sbxbase.hxx @@ -23,21 +23,24 @@ #include <i18nlangtag/lang.h> #include <basic/sbxdef.hxx> #include <basic/basicdllapi.h> -#include <boost/ptr_container/ptr_vector.hpp> + #include <boost/noncopyable.hpp> +#include <memory> +#include <vector> + class SbxFactory; class SbxVariable; class SbxBasicFormater; -typedef boost::ptr_vector<SbxFactory> SbxFacs; +typedef std::vector<std::unique_ptr<SbxFactory>> SbxFactories; // AppData structure for SBX: struct SbxAppData : private ::boost::noncopyable { SbxError eSbxError; // Error code - SbxFacs aFacs; // Factories + SbxFactories m_Factories; SbxBasicFormater *pBasicFormater; // Pointer to Format()-Command helper class LanguageType eBasicFormaterLangType; diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index 086d399c8f6d..80b56c3eebf3 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -44,7 +44,7 @@ SbxAppData::~SbxAppData() SolarMutexGuard g; delete pBasicFormater; - aFacs.clear(); + m_Factories.clear(); } SbxBase::SbxBase() @@ -124,25 +124,27 @@ void SbxBase::AddFactory( SbxFactory* pFac ) SbxAppData& r = GetSbxData_Impl(); // From 1996-03-06: take the HandleLast-Flag into account - sal_uInt16 nPos = r.aFacs.size(); // Insert position + sal_uInt16 nPos = r.m_Factories.size(); // Insert position if( !pFac->IsHandleLast() ) // Only if not self HandleLast { // Rank new factory in front of factories with HandleLast - while( nPos > 0 && - r.aFacs[ nPos-1 ].IsHandleLast() ) + while (nPos > 0 && r.m_Factories[ nPos-1 ]->IsHandleLast()) nPos--; } - r.aFacs.insert( r.aFacs.begin() + nPos, pFac ); + r.m_Factories.insert(r.m_Factories.begin() + nPos, std::unique_ptr<SbxFactory>(pFac)); } void SbxBase::RemoveFactory( SbxFactory* pFac ) { SbxAppData& r = GetSbxData_Impl(); - for(SbxFacs::iterator it = r.aFacs.begin(); it != r.aFacs.end(); ++it) + for (auto it = r.m_Factories.begin(); it != r.m_Factories.end(); ++it) { - if( &(*it) == pFac ) + if ((*it).get() == pFac) { - r.aFacs.release( it ).release(); break; + std::unique_ptr<SbxFactory> tmp(std::move(*it)); + r.m_Factories.erase( it ); + tmp.release(); + break; } } } @@ -173,9 +175,9 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) // Unknown type: go over the factories! SbxAppData& r = GetSbxData_Impl(); SbxBase* pNew = NULL; - for( SbxFactory& rFac : r.aFacs ) + for (auto const& rpFac : r.m_Factories) { - pNew = rFac.Create( nSbxId, nCreator ); + pNew = rpFac->Create( nSbxId, nCreator ); if( pNew ) break; } @@ -187,9 +189,9 @@ SbxObject* SbxBase::CreateObject( const OUString& rClass ) { SbxAppData& r = GetSbxData_Impl(); SbxObject* pNew = NULL; - for( SbxFactory& rFac : r.aFacs ) + for (auto const& rpFac : r.m_Factories) { - pNew = rFac.CreateObject( rClass ); + pNew = rpFac->CreateObject( rClass ); if( pNew ) break; } |