diff options
Diffstat (limited to 'basic/source/basmgr/basicmanagerrepository.cxx')
-rwxr-xr-x[-rw-r--r--] | basic/source/basmgr/basicmanagerrepository.cxx | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index 2057a065e96c..f94155d67808 100644..100755 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -138,9 +138,17 @@ namespace basic impl_getLocationForModel( const Reference< XModel >& _rxDocumentModel ); /** creates a new BasicManager instance for the given model + + @param _out_rpBasicManager + reference to the pointer variable that will hold the new + BasicManager. + + @param _rxDocumentModel + the model whose BasicManager will be created. Must not be <NULL/>. */ - BasicManagerPointer - impl_createManagerForModel( const Reference< XModel >& _rxDocumentModel ); + void impl_createManagerForModel( + BasicManagerPointer& _out_rpBasicManager, + const Reference< XModel >& _rxDocumentModel ); /** creates the application-wide BasicManager */ @@ -243,9 +251,17 @@ namespace basic { ::osl::MutexGuard aGuard( m_aMutex ); + /* #163556# (DR) - This function may be called recursively while + constructing the Basic manager and loading the Basic storage. By + passing the map entry received from impl_getLocationForModel() to + the function impl_createManagerForModel(), the new Basic manager + will be put immediately into the map of existing Basic managers, + thus a recursive call of this function will find and return it + without creating another instance. + */ BasicManagerPointer& pBasicManager = impl_getLocationForModel( _rxDocumentModel ); if ( pBasicManager == NULL ) - pBasicManager = impl_createManagerForModel( _rxDocumentModel ); + impl_createManagerForModel( pBasicManager, _rxDocumentModel ); return pBasicManager; } @@ -407,21 +423,21 @@ namespace basic } //-------------------------------------------------------------------- - BasicManagerPointer ImplRepository::impl_createManagerForModel( const Reference< XModel >& _rxDocumentModel ) + void ImplRepository::impl_createManagerForModel( BasicManagerPointer& _out_rpBasicManager, const Reference< XModel >& _rxDocumentModel ) { StarBASIC* pAppBasic = impl_getDefaultAppBasicLibrary(); - BasicManager* pBasicManager( NULL ); + _out_rpBasicManager = 0; Reference< XStorage > xStorage; if ( !impl_getDocumentStorage_nothrow( _rxDocumentModel, xStorage ) ) // the document is not able to provide the storage it is based on. - return pBasicManager; + return; Reference< XPersistentLibraryContainer > xBasicLibs; Reference< XPersistentLibraryContainer > xDialogLibs; if ( !impl_getDocumentLibraryContainers_nothrow( _rxDocumentModel, xBasicLibs, xDialogLibs ) ) // the document does not have BasicLibraries and DialogLibraries - return pBasicManager; + return; if ( xStorage.is() ) { @@ -432,24 +448,24 @@ namespace basic // Storage and BaseURL are only needed by binary documents! SotStorageRef xDummyStor = new SotStorage( ::rtl::OUString() ); - pBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */, + _out_rpBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */, pAppBasic, - &aAppBasicDir, TRUE ); - if ( pBasicManager->HasErrors() ) + &aAppBasicDir, sal_True ); + if ( _out_rpBasicManager->HasErrors() ) { // handle errors - BasicError* pErr = pBasicManager->GetFirstError(); + BasicError* pErr = _out_rpBasicManager->GetFirstError(); while ( pErr ) { // show message to user if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( pErr->GetErrorId() ) ) { // user wants to break loading of BASIC-manager - BasicManagerCleaner::deleteBasicManager( pBasicManager ); + BasicManagerCleaner::deleteBasicManager( _out_rpBasicManager ); xStorage.clear(); break; } - pErr = pBasicManager->GetNextError(); + pErr = _out_rpBasicManager->GetNextError(); } } } @@ -460,14 +476,14 @@ namespace basic // create new BASIC-manager StarBASIC* pBasic = new StarBASIC( pAppBasic ); pBasic->SetFlag( SBX_EXTSEARCH ); - pBasicManager = new BasicManager( pBasic, NULL, TRUE ); + _out_rpBasicManager = new BasicManager( pBasic, NULL, sal_True ); } // knit the containers with the BasicManager LibraryContainerInfo aInfo( xBasicLibs, xDialogLibs, dynamic_cast< OldBasicPassword* >( xBasicLibs.get() ) ); OSL_ENSURE( aInfo.mpOldBasicPassword, "ImplRepository::impl_createManagerForModel: wrong BasicLibraries implementation!" ); - pBasicManager->SetLibraryContainerInfo( aInfo ); - //pBasicCont->setBasicManager( pBasicManager ); + _out_rpBasicManager->SetLibraryContainerInfo( aInfo ); + //pBasicCont->setBasicManager( _out_rpBasicManager ); // that's not needed anymore today. The containers will retrieve their associated // BasicManager from the BasicManagerRepository, when needed. @@ -475,13 +491,13 @@ namespace basic impl_initDocLibraryContainers_nothrow( xBasicLibs, xDialogLibs ); // so that also dialogs etc. could be 'qualified' addressed - pBasicManager->GetLib(0)->SetParent( pAppBasic ); + _out_rpBasicManager->GetLib(0)->SetParent( pAppBasic ); // global properties in the document's Basic - pBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxDocumentModel ) ); + _out_rpBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxDocumentModel ) ); // notify - impl_notifyCreationListeners( _rxDocumentModel, *pBasicManager ); + impl_notifyCreationListeners( _rxDocumentModel, *_out_rpBasicManager ); // register as listener for this model being disposed/closed Reference< XComponent > xDocumentComponent( _rxDocumentModel, UNO_QUERY ); @@ -489,9 +505,14 @@ namespace basic startComponentListening( xDocumentComponent ); // register as listener for the BasicManager being destroyed - StartListening( *pBasicManager ); + StartListening( *_out_rpBasicManager ); + + // #i104876: Library container must not be modified just after + // creation. This happens as side effect when creating default + // "Standard" libraries and needs to be corrected here + xBasicLibs->setModified( sal_False ); + xDialogLibs->setModified( sal_False ); - return pBasicManager; } //-------------------------------------------------------------------- |