diff options
Diffstat (limited to 'basic/source/uno/scriptcont.cxx')
-rwxr-xr-x[-rw-r--r--] | basic/source/uno/scriptcont.cxx | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index d6bd191cd0da..ebfc68863ea0 100644..100755 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -61,7 +61,7 @@ #include <basic/basmgr.hxx> #include <basic/sbmod.hxx> #include <basic/basicmanagerrepository.hxx> -#include "modsizeexceeded.hxx" +#include "basic/modsizeexceeded.hxx" #include <xmlscript/xmlmod_imexp.hxx> #include <cppuhelper/factory.hxx> #include <com/sun/star/util/VetoException.hpp> @@ -82,7 +82,7 @@ using namespace com::sun::star; using namespace cppu; using namespace osl; -using com::sun::star::uno::Reference; +using ::rtl::OUString; using ::rtl::OUString; @@ -300,7 +300,7 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement catch( Exception& ) { SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aFile ); - ULONG nErrorCode = ERRCODE_IO_GENERAL; + sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL; ErrorHandler::HandleError( nErrorCode ); } @@ -311,24 +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 ); - - Any aGlobs; - Sequence< Any > aArgs(1); - Reference<frame::XModel > xModel( mxOwnerDocument ); - aArgs[ 0 ] <<= xModel; - - BasicManager* pBasicMgr = getBasicManager(); - if( pBasicMgr ) - { - aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); - pBasicMgr->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); - } - pBasicMgr = BasicManagerRepository::getApplicationBasicManager( sal_False ); - if( pBasicMgr ) - pBasicMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[0] ); } script::ModuleInfo aModInfo; @@ -353,25 +350,21 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement RTL_CONSTASCII_STRINGPARAM("document") )) { aModInfo.ModuleType = ModuleType::DOCUMENT; - Reference<frame::XModel > xModel( mxOwnerDocument ); - Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY); - Reference< container::XNameAccess > xVBACodeNameAccess; - if( xSF.is() ) + + // #163691# use the same codename access instance for all document modules + if( !mxCodeNameAccess.is() ) try { - try - { - xVBACodeNameAccess.set( xSF->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "ooo.vba.VBAObjectModuleObjectProvider"))), - UNO_QUERY ); - } - catch(uno::Exception&) {} + Reference<frame::XModel > xModel( mxOwnerDocument ); + Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY_THROW ); + mxCodeNameAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider" ) ) ), UNO_QUERY ); } - if( xVBACodeNameAccess.is() ) + catch( Exception& ) {} + + if( mxCodeNameAccess.is() ) { try { - aModInfo.ModuleObject.set( xVBACodeNameAccess->getByName( aElementName), uno::UNO_QUERY ); + aModInfo.ModuleObject.set( mxCodeNameAccess->getByName( aElementName), uno::UNO_QUERY ); } catch(uno::Exception&) { @@ -661,7 +654,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, throw uno::RuntimeException(); SvMemoryStream aMemStream; - /*BOOL bStore = */pMod->StoreBinaryData( aMemStream ); + /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream ); sal_Int32 nSize = (sal_Int32)aMemStream.Tell(); Sequence< sal_Int8 > aBinSeq( nSize ); @@ -802,7 +795,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ); SvMemoryStream aMemStream; - /*BOOL bStore = */pMod->StoreBinaryData( aMemStream ); + /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream ); sal_Int32 nSize = (sal_Int32)aMemStream.Tell(); Sequence< sal_Int8 > aBinSeq( nSize ); @@ -959,7 +952,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary if( !pMod ) { pMod = pBasicLib->MakeModule( aElementName, String() ); - pBasicLib->SetModified( FALSE ); + pBasicLib->SetModified( sal_False ); } //OUString aCodeStreamName( RTL_CONSTASCII_USTRINGPARAM("code.bin") ); @@ -981,7 +974,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nError ); } - /*BOOL bRet = */pMod->LoadBinaryData( *pStream ); + /*sal_Bool bRet = */pMod->LoadBinaryData( *pStream ); // TODO: Check return value delete pStream; @@ -1071,7 +1064,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary if( !pMod ) { pMod = pBasicLib->MakeModule( aElementName, String() ); - pBasicLib->SetModified( FALSE ); + pBasicLib->SetModified( sal_False ); } try { @@ -1090,7 +1083,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary nError ); } - /*BOOL bRet = */pMod->LoadBinaryData( *pStream ); + /*sal_Bool bRet = */pMod->LoadBinaryData( *pStream ); // TODO: Check return value delete pStream; |