diff options
author | Andreas Bregas <ab@openoffice.org> | 2010-07-05 13:58:36 +0200 |
---|---|---|
committer | Andreas Bregas <ab@openoffice.org> | 2010-07-05 13:58:36 +0200 |
commit | 8805c94e559a34256ae37b29576078d2b1cdde18 (patch) | |
tree | 7bf9a0f7569cf1ef5a5a0ef5735c9ec568ce644c /basic | |
parent | 237858a658c46a24d45fe75f44c6b770367790a7 (diff) |
mib17: #i100659# Changed module variable handling
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/basic/sbmod.hxx | 5 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 28 | ||||
-rw-r--r-- | basic/source/comp/sbcomp.cxx | 1 | ||||
-rw-r--r-- | basic/source/runtime/step2.cxx | 23 |
4 files changed, 50 insertions, 7 deletions
diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index cdf0a2361c..fb9dd38a70 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -33,6 +33,7 @@ #include <basic/sbxobj.hxx> #include <basic/sbxdef.hxx> #include <rtl/ustring.hxx> +#include <vector> class SbMethod; class SbProperty; @@ -56,6 +57,7 @@ class SbModule : public SbxObject friend class SbClassModuleObject; SbModuleImpl* mpSbModuleImpl; // Impl data + std::vector< String > mModuleVariableNames; protected: com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; @@ -133,7 +135,8 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } - ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); + void AddVarName( const String& aName ); + void RemoveVars(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index e272c48cc2..9b1dce79cf 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,6 +147,7 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { + sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); @@ -1242,6 +1243,33 @@ void SbModule::RunInit() } // Mit private/dim deklarierte Variablen loeschen + +void SbModule::AddVarName( const String& aName ) +{ + // see if the name is added allready + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + if ( aName == *it ) + return; + } + mModuleVariableNames.push_back( aName ); +} + +void SbModule::RemoveVars() +{ + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + // We don't want a Find being called in a derived class ( e.g. + // SbUserform because it could trigger say an initialise event + // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) + SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY ); + if( p.Is() ) + Remove (p); + } +} + void SbModule::ClearPrivateVars() { for( USHORT i = 0 ; i < pProps->Count() ; i++ ) diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index c91624de5e..6ee246da8f 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -131,6 +131,7 @@ BOOL SbModule::Compile() if( bRet ) { pBasic->ClearAllModuleVars(); + RemoveVars(); // remove 'this' Modules variables // clear all method statics for( USHORT i = 0; i < pMethods->Count(); i++ ) { diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 19f33cad8d..e020f97b28 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -1158,15 +1158,26 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; - BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY ); + SbxDataType t = (SbxDataType)(nOp2 & 0xffff);; + + // Store module scope variables at module scope + // in non vba mode these are stored at the library level :/ + // not sure if this really should not be enabled for ALL basic + SbxObject* pStorage = &rBasic; + if ( SbiRuntime::isVBAEnabled() ) + { + pStorage = pMod; + pMod->AddVarName( aName ); + } + + BOOL bFlag = pStorage->IsSet( SBX_NO_MODIFY ); rBasic.SetFlag( SBX_NO_MODIFY ); - SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY ); + SbxVariableRef p = pStorage->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) - rBasic.Remove (p); - p = rBasic.Make( aName, SbxCLASS_PROPERTY, t ); + pStorage->Remove (p); + p = pStorage->Make( aName, SbxCLASS_PROPERTY, t ); if( !bFlag ) - rBasic.ResetFlag( SBX_NO_MODIFY ); + pStorage->ResetFlag( SBX_NO_MODIFY ); if( p ) { p->SetFlag( SBX_DONTSTORE ); |