[Libreoffice-commits] core.git: 4 commits - basic/inc basic/source

Michael Stahl mstahl at redhat.com
Mon Oct 26 15:29:34 UTC 2015


 basic/inc/sbxbase.hxx            |    9 ++--
 basic/source/basmgr/basmgr.cxx   |   82 +++++++++++++++++++--------------------
 basic/source/classes/propacc.cxx |    6 +-
 basic/source/comp/symtbl.cxx     |   32 ++++++++-------
 basic/source/inc/propacc.hxx     |    5 +-
 basic/source/inc/symtbl.hxx      |    7 +--
 basic/source/sbx/sbxbase.cxx     |   26 ++++++------
 7 files changed, 87 insertions(+), 80 deletions(-)

New commits:
commit 51eb04a158a89cc2260d40e844ac7b9eca0cee0a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Oct 25 17:23:27 2015 +0100

    basic: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I98c4ac860fbdb55a61f9be0e9d2d5f29fb849e05

diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index db6b150..a0390af 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -107,33 +107,33 @@ SbiSymDef* SbiSymPool::First()
 
 SbiSymDef* SbiSymPool::Next()
 {
-    if( ++nCur >= aData.size() )
+    if (m_Data.size() <= ++nCur)
         return NULL;
     else
-        return &aData[ nCur ];
+        return m_Data[ nCur ].get();
 }
 
 
 SbiSymDef* SbiSymPool::AddSym( const OUString& rName )
 {
     SbiSymDef* p = new SbiSymDef( rName );
-    p->nPos    = aData.size();
+    p->nPos    = m_Data.size();
     p->nId     = rStrings.Add( rName );
     p->nProcId = nProcId;
     p->pIn     = this;
-    aData.insert( aData.begin() + p->nPos, p );
+    m_Data.insert( m_Data.begin() + p->nPos, std::unique_ptr<SbiSymDef>(p) );
     return p;
 }
 
 SbiProcDef* SbiSymPool::AddProc( const OUString& rName )
 {
     SbiProcDef* p = new SbiProcDef( pParser, rName );
-    p->nPos    = aData.size();
+    p->nPos    = m_Data.size();
     p->nId     = rStrings.Add( rName );
     // procs are always local
     p->nProcId = 0;
     p->pIn     = this;
-    aData.insert( aData.begin() + p->nPos, p );
+    m_Data.insert( m_Data.begin() + p->nPos, std::unique_ptr<SbiProcDef>(p) );
     return p;
 }
 
@@ -152,7 +152,7 @@ void SbiSymPool::Add( SbiSymDef* pDef )
             return;
         }
 
-        pDef->nPos = aData.size();
+        pDef->nPos = m_Data.size();
         if( !pDef->nId )
         {
             // A unique name must be created in the string pool
@@ -172,17 +172,17 @@ void SbiSymPool::Add( SbiSymDef* pDef )
             pDef->nProcId = nProcId;
         }
         pDef->pIn = this;
-        aData.insert( aData.begin() + pDef->nPos, pDef );
+        m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) );
     }
 }
 
 
 SbiSymDef* SbiSymPool::Find( const OUString& rName )
 {
-    sal_uInt16 nCount = aData.size();
+    sal_uInt16 nCount = m_Data.size();
     for( sal_uInt16 i = 0; i < nCount; i++ )
     {
-        SbiSymDef &r = aData[ nCount - i - 1 ];
+        SbiSymDef &r = *m_Data[ nCount - i - 1 ];
         if( ( !r.nProcId || ( r.nProcId == nProcId)) &&
             ( r.aName.equalsIgnoreAsciiCase(rName)))
         {
@@ -204,13 +204,13 @@ SbiSymDef* SbiSymPool::Find( const OUString& rName )
 
 SbiSymDef* SbiSymPool::Get( sal_uInt16 n )
 {
-    if( n >= aData.size() )
+    if (m_Data.size() <= n)
     {
         return NULL;
     }
     else
     {
-        return &aData[ n ];
+        return m_Data[ n ].get();
     }
 }
 
@@ -246,9 +246,9 @@ sal_uInt32 SbiSymPool::Reference( const OUString& rName )
 
 void SbiSymPool::CheckRefs()
 {
-    for( size_t i = 0; i < aData.size(); i++ )
+    for (size_t i = 0; i < m_Data.size(); ++i)
     {
-        SbiSymDef &r = aData[ i ];
+        SbiSymDef &r = *m_Data[ i ];
         if( !r.IsDefined() )
         {
             pParser->Error( ERRCODE_BASIC_UNDEF_LABEL, r.GetName() );
@@ -459,7 +459,9 @@ void SbiProcDef::Match( SbiProcDef* pOld )
         nPos = pOld->nPos;
         nId  = pOld->nId;
         pIn  = pOld->pIn;
-        pIn->aData.replace( nPos, this ).release();
+        std::unique_ptr<SbiSymDef> tmp(this);
+        std::swap(pIn->m_Data[nPos], tmp);
+        tmp.release();
     }
     delete pOld;
 }
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index d9e279d..2f75fa8 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -20,8 +20,8 @@
 #ifndef INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
 #define INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
 
+#include <memory>
 #include <vector>
-#include <boost/ptr_container/ptr_vector.hpp>
 
 class SbiConstDef;
 class SbiParser;
@@ -54,8 +54,7 @@ class SbiSymPool {
     friend class SbiProcDef;
 protected:
     SbiStringPool& rStrings;
-    boost::ptr_vector<SbiSymDef>
-                   aData;
+    std::vector<std::unique_ptr<SbiSymDef>> m_Data;
     SbiSymPool*    pParent;
     SbiParser*     pParser;
     SbiSymScope    eScope;
@@ -67,7 +66,7 @@ public:
 
     void   SetParent( SbiSymPool* p )   { pParent = p;      }
     void   SetProcId( short n )         { nProcId = n;      }
-    sal_uInt16 GetSize() const              { return aData.size(); }
+    sal_uInt16 GetSize() const          { return m_Data.size(); }
     SbiSymScope GetScope() const        { return eScope;    }
     void   SetScope( SbiSymScope s )    { eScope = s;       }
     SbiParser* GetParser()              { return pParser;   }
commit 71f6aab077f30f8b0eb6c7458cb0646dea892148
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Oct 25 16:54:21 2015 +0100

    basic: replace boot::ptr_vector with std::vector
    
    Change-Id: I4967ad8345cd74c39edbea1df513978b62996b90

diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index dac042e..2a0b49a 100644
--- a/basic/source/classes/propacc.cxx
+++ b/basic/source/classes/propacc.cxx
@@ -26,6 +26,7 @@
 
 #include <comphelper/propertysetinfo.hxx>
 
+#include <algorithm>
 #include <limits.h>
 
 using com::sun::star::uno::Reference;
@@ -178,14 +179,13 @@ void SbPropertyValues::setPropertyValues(const Sequence< PropertyValue >& rPrope
                      css::lang::WrappedTargetException,
                      css::uno::RuntimeException, std::exception)
 {
-    if ( !m_aPropVals.empty() )
+    if (!m_aPropVals.empty())
         throw IllegalArgumentException();
 
     const PropertyValue *pPropVals = rPropertyValues.getConstArray();
     for (sal_Int32 n = 0; n < rPropertyValues.getLength(); ++n)
     {
-        PropertyValue *pPropVal = new PropertyValue(pPropVals[n]);
-        m_aPropVals.push_back( pPropVal );
+        m_aPropVals.push_back(pPropVals[n]);
     }
 }
 
diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx
index 325976e..ec227a4 100644
--- a/basic/source/inc/propacc.hxx
+++ b/basic/source/inc/propacc.hxx
@@ -25,9 +25,10 @@
 #include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 #include <cppuhelper/implbase.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
 
-typedef ::boost::ptr_vector< css::beans::PropertyValue >  SbPropertyValueArr_Impl;
+#include <vector>
+
+typedef ::std::vector<css::beans::PropertyValue> SbPropertyValueArr_Impl;
 
 typedef ::cppu::WeakImplHelper< css::beans::XPropertySet,
                                 css::beans::XPropertyAccess > SbPropertyValuesHelper;
commit 79a7cf54244ffd112bea4d754e494d261ce3f061
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Oct 25 11:23:39 2015 +0100

    basic: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I0bd3a5182d62432a8f0caf4bbae11bbce56a363c

diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index f6b9f14..46e43eb 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -43,8 +43,8 @@
 #include "sbintern.hxx"
 #include <sb.hrc>
 
+#include <memory>
 #include <vector>
-#include <boost/ptr_container/ptr_vector.hpp>
 
 #define LIB_SEP         0x01
 #define LIBINFO_SEP     0x02
@@ -111,7 +111,7 @@ struct BasicManagerImpl
     SvMemoryStream** mppLibStreams;
     sal_Int32        mnLibStreamCount;
 
-    boost::ptr_vector<BasicLibInfo> aLibs;
+    std::vector<std::unique_ptr<BasicLibInfo>> aLibs;
     OUString         aBasicLibPath;
 
     BasicManagerImpl()
@@ -510,7 +510,7 @@ BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, Star
             if (mpImpl->aLibs.empty())
                 CreateLibInfo();
 
-            BasicLibInfo& rStdLibInfo = mpImpl->aLibs.front();
+            BasicLibInfo& rStdLibInfo = *mpImpl->aLibs.front();
 
             rStdLibInfo.SetLib( pStdLib );
             StarBASICRef xStdLib = rStdLibInfo.GetLib();
@@ -550,7 +550,7 @@ BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, Star
             mpImpl->mppLibStreams = new SvMemoryStream*[ nLibs ];
             for( sal_uInt16 nL = 0; nL < nLibs; nL++ )
             {
-                BasicLibInfo& rInfo = mpImpl->aLibs[nL];
+                BasicLibInfo& rInfo = *mpImpl->aLibs[nL];
                 tools::SvRef<SotStorageStream> xBasicStream = xBasicStorage->OpenSotStream( rInfo.GetLibName(), eStreamReadMode );
                 mpImpl->mppLibStreams[nL] = new SvMemoryStream();
                 static_cast<SvStream*>(&xBasicStream)->ReadStream( *( mpImpl->mppLibStreams[nL] ) );
@@ -644,27 +644,27 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo )
         else
         {
             // No libs? Maybe an 5.2 document already loaded
-            for( BasicLibInfo& rBasLibInfo: mpImpl->aLibs )
+            for (auto const& rpBasLibInfo : mpImpl->aLibs)
             {
-                StarBASIC* pLib = rBasLibInfo.GetLib();
+                StarBASIC* pLib = rpBasLibInfo->GetLib();
                 if( !pLib )
                 {
-                    bool bLoaded = ImpLoadLibrary( &rBasLibInfo, NULL );
+                    bool bLoaded = ImpLoadLibrary( rpBasLibInfo.get(), NULL );
                     if( bLoaded )
-                        pLib = rBasLibInfo.GetLib();
+                        pLib = rpBasLibInfo->GetLib();
                 }
                 if( pLib )
                 {
                     copyToLibraryContainer( pLib, mpImpl->maContainerInfo );
-                    if( rBasLibInfo.HasPassword() )
+                    if (rpBasLibInfo->HasPassword())
                     {
                         OldBasicPassword* pOldBasicPassword =
                             mpImpl->maContainerInfo.mpOldBasicPassword;
                         if( pOldBasicPassword )
                         {
-                            pOldBasicPassword->setLibraryPassword
-                                ( pLib->GetName(), rBasLibInfo.GetPassword() );
-                            rBasLibInfo.SetPasswordVerified();
+                            pOldBasicPassword->setLibraryPassword(
+                                pLib->GetName(), rpBasLibInfo->GetPassword() );
+                            rpBasLibInfo->SetPasswordVerified();
                         }
                     }
                 }
@@ -801,7 +801,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const OUString& rBase
             }
         }
 
-        mpImpl->aLibs.push_back( pInfo );
+        mpImpl->aLibs.push_back(std::unique_ptr<BasicLibInfo>(pInfo));
         // Libs from external files should be loaded only when necessary.
         // But references are loaded at once, otherwise some big customers get into trouble
         if ( bLoadLibs && pInfo->DoLoad() &&
@@ -838,7 +838,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
     DBG_ASSERT( !xManagerStream->GetError(), "Invalid Manager-Stream!" );
 
     xManagerStream->Seek( nBasicStartOff );
-    if( !ImplLoadBasic( *xManagerStream, mpImpl->aLibs.front().GetLibRef() ) )
+    if (!ImplLoadBasic( *xManagerStream, mpImpl->aLibs.front()->GetLibRef() ))
     {
         StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, aStorName, ERRCODE_BUTTON_OK );
         aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENMGRSTREAM, aStorName));
@@ -938,8 +938,8 @@ void BasicManager::Init()
 
 BasicLibInfo* BasicManager::CreateLibInfo()
 {
-    BasicLibInfo* pInf = new BasicLibInfo;
-    mpImpl->aLibs.push_back( pInf );
+    BasicLibInfo* pInf(new BasicLibInfo);
+    mpImpl->aLibs.push_back(std::unique_ptr<BasicLibInfo>(pInf));
     return pInf;
 }
 
@@ -1190,7 +1190,7 @@ bool BasicManager::IsReference( sal_uInt16 nLib )
     DBG_ASSERT( nLib < mpImpl->aLibs.size(), "Lib does not exist!" );
     if ( nLib < mpImpl->aLibs.size() )
     {
-        return mpImpl->aLibs[nLib].IsReference();
+        return mpImpl->aLibs[nLib]->IsReference();
     }
     return false;
 }
@@ -1214,23 +1214,23 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
         return false;
     }
 
-    boost::ptr_vector<BasicLibInfo>::iterator itLibInfo = mpImpl->aLibs.begin() + nLib;
+    auto const itLibInfo = mpImpl->aLibs.begin() + nLib;
 
     // If one of the streams cannot be opened, this is not an error,
     // because BASIC was never written before...
-    if ( bDelBasicFromStorage && !itLibInfo->IsReference() &&
-            ( !itLibInfo->IsExtern() || SotStorage::IsStorageFile( itLibInfo->GetStorageName() ) ) )
+    if (bDelBasicFromStorage && !(*itLibInfo)->IsReference() &&
+           (!(*itLibInfo)->IsExtern() || SotStorage::IsStorageFile((*itLibInfo)->GetStorageName())))
     {
         tools::SvRef<SotStorage> xStorage;
         try
         {
-            if (!itLibInfo->IsExtern())
+            if (!(*itLibInfo)->IsExtern())
             {
                 xStorage = new SotStorage(false, GetStorageName());
             }
             else
             {
-                xStorage = new SotStorage(false, itLibInfo->GetStorageName());
+                xStorage = new SotStorage(false, (*itLibInfo)->GetStorageName());
             }
         }
         catch (const css::ucb::ContentCreationException& e)
@@ -1246,11 +1246,11 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
             if ( !xBasicStorage.Is() || xBasicStorage->GetError() )
             {
                 StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, OUString(), ERRCODE_BUTTON_OK );
-                aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENLIBSTORAGE, itLibInfo->GetLibName()));
+                aErrors.push_back(BasicError(*pErrInf, BasicErrorReason::OPENLIBSTORAGE, (*itLibInfo)->GetLibName()));
             }
-            else if ( xBasicStorage->IsStream( itLibInfo->GetLibName() ) )
+            else if (xBasicStorage->IsStream((*itLibInfo)->GetLibName()))
             {
-                xBasicStorage->Remove( itLibInfo->GetLibName() );
+                xBasicStorage->Remove((*itLibInfo)->GetLibName());
                 xBasicStorage->Commit();
 
                 // If no further stream available,
@@ -1278,9 +1278,9 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
             }
         }
     }
-    if ( itLibInfo->GetLib().Is() )
+    if ((*itLibInfo)->GetLib().Is())
     {
-        GetStdLib()->Remove( itLibInfo->GetLib() );
+        GetStdLib()->Remove( (*itLibInfo)->GetLib() );
     }
     mpImpl->aLibs.erase(itLibInfo);
     return true;    // Remove was successful, del unimportant
@@ -1296,7 +1296,7 @@ StarBASIC* BasicManager::GetLib( sal_uInt16 nLib ) const
     DBG_ASSERT( nLib < mpImpl->aLibs.size(), "Lib does not exist!" );
     if ( nLib < mpImpl->aLibs.size() )
     {
-        return mpImpl->aLibs[nLib].GetLib();
+        return mpImpl->aLibs[nLib]->GetLib();
     }
     return 0;
 }
@@ -1309,11 +1309,11 @@ StarBASIC* BasicManager::GetStdLib() const
 
 StarBASIC* BasicManager::GetLib( const OUString& rName ) const
 {
-    for(const BasicLibInfo& rLib: mpImpl->aLibs)
+    for (auto const& rpLib : mpImpl->aLibs)
     {
-        if ( rLib.GetLibName().equalsIgnoreAsciiCase( rName ))// Check if available...
+        if (rpLib->GetLibName().equalsIgnoreAsciiCase(rName)) // Check if available...
         {
-            return rLib.GetLib();
+            return rpLib->GetLib();
         }
     }
     return 0;
@@ -1323,7 +1323,7 @@ sal_uInt16 BasicManager::GetLibId( const OUString& rName ) const
 {
     for (size_t i = 0; i < mpImpl->aLibs.size(); i++)
     {
-        if ( mpImpl->aLibs[i].GetLibName().equalsIgnoreAsciiCase( rName ))
+        if (mpImpl->aLibs[i]->GetLibName().equalsIgnoreAsciiCase( rName ))
         {
             return (sal_uInt16)i;
         }
@@ -1333,9 +1333,9 @@ sal_uInt16 BasicManager::GetLibId( const OUString& rName ) const
 
 bool BasicManager::HasLib( const OUString& rName ) const
 {
-    for(const BasicLibInfo& rLib: mpImpl->aLibs)
+    for (const auto& rpLib : mpImpl->aLibs)
     {
-        if ( rLib.GetLibName().equalsIgnoreAsciiCase( rName ))// Check if available...
+        if (rpLib->GetLibName().equalsIgnoreAsciiCase(rName)) // Check if available...
         {
             return true;
         }
@@ -1348,7 +1348,7 @@ OUString BasicManager::GetLibName( sal_uInt16 nLib )
     DBG_ASSERT(  nLib < mpImpl->aLibs.size(), "Lib?!" );
     if ( nLib < mpImpl->aLibs.size() )
     {
-        return mpImpl->aLibs[nLib].GetLibName();
+        return mpImpl->aLibs[nLib]->GetLibName();
     }
     return OUString();
 }
@@ -1359,7 +1359,7 @@ bool BasicManager::LoadLib( sal_uInt16 nLib )
     DBG_ASSERT( nLib < mpImpl->aLibs.size() , "Lib?!" );
     if ( nLib < mpImpl->aLibs.size() )
     {
-        BasicLibInfo& rLibInfo = mpImpl->aLibs[nLib];
+        BasicLibInfo& rLibInfo = *mpImpl->aLibs[nLib];
         uno::Reference< script::XLibraryContainer > xLibContainer = rLibInfo.GetLibraryContainer();
         if( xLibContainer.is() )
         {
@@ -1461,11 +1461,11 @@ StarBASIC* BasicManager::CreateLibForLibContainer( const OUString& rLibName,
 
 BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic )
 {
-    for(BasicLibInfo& rLib: mpImpl->aLibs)
+    for (auto const& rpLib : mpImpl->aLibs)
     {
-        if ( rLib.GetLib() == pBasic )
+        if (rpLib->GetLib() == pBasic)
         {
-            return &rLib;
+            return rpLib.get();
         }
     }
     return NULL;
@@ -1474,9 +1474,9 @@ BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic )
 
 bool BasicManager::IsBasicModified() const
 {
-    for(const BasicLibInfo& rLib: mpImpl->aLibs)
+    for (auto const& rpLib : mpImpl->aLibs)
     {
-        if ( rLib.GetLib().Is() && rLib.GetLib()->IsModified() )
+        if (rpLib->GetLib().Is() && rpLib->GetLib()->IsModified())
         {
             return true;
         }
commit 192ca71f07390af6528531c0c4c9254c97a98cfc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Oct 25 10:02:24 2015 +0100

    basic: replace boost::ptr_vector with std::vector<std::unqiue_ptr>
    
    Change-Id: Ieba2fb34e0279871d36b4fe80d9de76e614b5cde

diff --git a/basic/inc/sbxbase.hxx b/basic/inc/sbxbase.hxx
index 21bb7d4..8177643 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 086d399..80b56c3 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;
     }


More information about the Libreoffice-commits mailing list