diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-09-17 15:28:21 +0200 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-09-17 15:28:21 +0200 |
commit | 8e74a57b6cf49cf5296ecc21a111d0119d7cac83 (patch) | |
tree | 6512e6f385c039ed2ed89ae3970fef61f5d3d9b4 /basic | |
parent | 39d31f1c3b54d7581b0f825ab3693873235d0486 (diff) |
mib19: #163556# preserve VBA compatibility in ODF roundtrip
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/basmgr/basicmanagerrepository.cxx | 56 | ||||
-rw-r--r-- | basic/source/uno/namecont.cxx | 17 | ||||
-rw-r--r-- | basic/source/uno/scriptcont.cxx | 33 |
3 files changed, 58 insertions, 48 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index f6a16ffa80c0..a5a1d4c8ca12 100644 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -139,9 +139,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 */ @@ -244,9 +252,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; } @@ -408,21 +424,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() ) { @@ -433,24 +449,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() ) + 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(); } } } @@ -461,14 +477,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, 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. @@ -476,13 +492,13 @@ namespace basic impl_initDocLibraryContainers_nothrow( xBasicLibs, xDialogLibs ); // damit auch Dialoge etc. 'qualifiziert' angesprochen werden k"onnen - 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 ); @@ -490,9 +506,7 @@ namespace basic startComponentListening( xDocumentComponent ); // register as listener for the BasicManager being destroyed - StartListening( *pBasicManager ); - - return pBasicManager; + StartListening( *_out_rpBasicManager ); } //-------------------------------------------------------------------- diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index c31aed1f8ef7..57fce665f976 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -2815,19 +2815,20 @@ OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) { - BasicManager* pBasMgr = getBasicManager(); - if( pBasMgr ) + /* The member variable mbVBACompat must be set first, the following call + to getBasicManager() may call getVBACompatibilityMode() which returns + this value. */ + mbVBACompat = _vbacompatmodeon; + if( BasicManager* pBasMgr = getBasicManager() ) { // get the standard library - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( pBasMgr->GetName().Len() ) - aLibName = pBasMgr->GetName(); + String aLibName = pBasMgr->GetName(); + if ( aLibName.Len() == 0 ) + aLibName = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - StarBASIC* pBasic = pBasMgr->GetLib( aLibName ); - if( pBasic ) + if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) ) pBasic->SetVBAEnabled( _vbacompatmodeon ); } - mbVBACompat = _vbacompatmodeon; } // Methods XServiceInfo diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index fa20add4f1fd..0b4649cd9690 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -311,26 +311,21 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement // aMod.aName ignored if( aMod.aModuleType.getLength() > 0 ) { - if( !getVBACompatibilityMode() ) + /* If in VBA compatibility mode, force creation of the VBA Globals + object. Each application will create an instance of its own + implementation and store it in its Basic manager. Implementations + will do all necessary additional initialization, such as + registering the global "This***Doc" UNO constant, starting the + document events processor etc. + */ + if( getVBACompatibilityMode() ) try + { + Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref + Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); + } + catch( Exception& ) { - setVBACompatibilityMode( sal_True ); - - /* Force creation of the VBA Globals object. Each application will - create an instance of its own implementation and store it in - its Basic manager. Implementations will do all necessary - additional initialization, such as registering the global - "This***Doc" UNO constant, starting the document events - processor etc. - */ - try - { - Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref - Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); - xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); - } - catch( Exception& ) - { - } } script::ModuleInfo aModInfo; |