diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-02-08 17:16:40 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-02-09 09:22:31 +0000 |
commit | 49c007b394126de2f1292e7ede17499c568f9bfa (patch) | |
tree | f314dda04a37ea4a682f9d08cb2a893ebd2c8350 /basic | |
parent | f5e330abbf3d8cd9625b29fcc228a742b35aa657 (diff) |
split getApplicationBasicManager into get and getOrCreate
Change-Id: I8e35594104ba85470eda387bc227e88bf77ccffd
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/basmgr/basicmanagerrepository.cxx | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index 500f31489e7b..9635fb2e3ddc 100644 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -49,8 +49,6 @@ namespace basic { - - using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::frame::XModel; @@ -83,7 +81,8 @@ namespace basic static ImplRepository& Instance(); BasicManager* getDocumentBasicManager( const Reference< XModel >& _rxDocumentModel ); - BasicManager* getApplicationBasicManager( bool _bCreate ); + BasicManager* getOrCreateApplicationBasicManager(); + BasicManager* getApplicationBasicManager() const; void setApplicationBasicManager( BasicManager* _pBasicManager ); void registerCreationListener( BasicManagerCreationListener& _rListener ); void revokeCreationListener( BasicManagerCreationListener& _rListener ); @@ -238,23 +237,28 @@ namespace basic return nullptr; } - BasicManager* ImplRepository::getApplicationBasicManager( bool _bCreate ) + BasicManager* ImplRepository::getOrCreateApplicationBasicManager() { SolarMutexGuard g; BasicManager* pAppManager = GetSbData()->pAppBasMgr; - if ( ( pAppManager == nullptr ) && _bCreate ) + if (pAppManager == nullptr) pAppManager = impl_createApplicationBasicManager(); - return pAppManager; } + BasicManager* ImplRepository::getApplicationBasicManager() const + { + SolarMutexGuard g; + + return GetSbData()->pAppBasMgr; + } void ImplRepository::setApplicationBasicManager( BasicManager* _pBasicManager ) { SolarMutexGuard g; - BasicManager* pPreviousManager = getApplicationBasicManager( false ); + BasicManager* pPreviousManager = getApplicationBasicManager(); delete pPreviousManager; GetSbData()->pAppBasMgr = _pBasicManager; @@ -265,7 +269,7 @@ namespace basic { SolarMutexGuard g; - OSL_PRECOND( getApplicationBasicManager( false ) == nullptr, "ImplRepository::impl_createApplicationBasicManager: there already is one!" ); + OSL_PRECOND(getApplicationBasicManager() == nullptr, "ImplRepository::impl_createApplicationBasicManager: there already is one!"); // Determine Directory SvtPathOptions aPathCFG; @@ -356,7 +360,7 @@ namespace basic StarBASIC* ImplRepository::impl_getDefaultAppBasicLibrary() { - BasicManager* pAppManager = getApplicationBasicManager( true ); + BasicManager* pAppManager = getOrCreateApplicationBasicManager(); StarBASIC* pAppBasic = pAppManager ? pAppManager->GetLib(0) : nullptr; DBG_ASSERT( pAppBasic != nullptr, "impl_getApplicationBasic: unable to determine the default application's Basic library!" ); @@ -601,37 +605,31 @@ namespace basic } } - BasicManager* BasicManagerRepository::getDocumentBasicManager( const Reference< XModel >& _rxDocumentModel ) { return ImplRepository::Instance().getDocumentBasicManager( _rxDocumentModel ); } - BasicManager* BasicManagerRepository::getApplicationBasicManager() { - return ImplRepository::Instance().getApplicationBasicManager( true/*_bCreate*/ ); + return ImplRepository::Instance().getOrCreateApplicationBasicManager(); } - void BasicManagerRepository::resetApplicationBasicManager() { ImplRepository::Instance().setApplicationBasicManager( nullptr ); } - void BasicManagerRepository::registerCreationListener( BasicManagerCreationListener& _rListener ) { ImplRepository::Instance().registerCreationListener( _rListener ); } - void BasicManagerRepository::revokeCreationListener( BasicManagerCreationListener& _rListener ) { ImplRepository::Instance().revokeCreationListener( _rListener ); } - } // namespace basic |