diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-03-25 10:40:25 +0100 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-03-25 10:40:25 +0100 |
commit | b46dab973c91c3a94bcda188a9888fef3fd16426 (patch) | |
tree | ecf2283bed35cbd42e3fb5fb541194d70179e51d /basic/source/inc | |
parent | 61879c218dd0e6e94884e7c6e06e3c5c18540b4a (diff) |
calcvba: #164410# improve VBA compatibility implementation in various areas: Excel symbols, MSForms symbols, document and forms event handling
Diffstat (limited to 'basic/source/inc')
-rw-r--r-- | basic/source/inc/codegen.hxx | 3 | ||||
-rw-r--r-- | basic/source/inc/namecont.hxx | 220 | ||||
-rw-r--r-- | basic/source/inc/runtime.hxx | 2 | ||||
-rwxr-xr-x | basic/source/inc/sbtrace.hxx | 15 | ||||
-rw-r--r-- | basic/source/inc/scriptcont.hxx | 17 | ||||
-rw-r--r-- | basic/source/inc/symtbl.hxx | 3 |
6 files changed, 155 insertions, 105 deletions
diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index a496322bb6d7..9ba99e7ceae8 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -87,6 +87,7 @@ public: // #111897 PARAM_INFO flags start at 0x00010000 to not // conflict with DefaultId in SbxParamInfo::nUserData -#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_WITHBRACKETS 0x0020000 #endif diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 7fd6eb06f607..c0e8191be307 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -29,6 +29,7 @@ #define BASIC_NAMECONTAINER_HXX #include <hash_map> + #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -46,71 +47,41 @@ #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/deployment/XPackage.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAScriptListener.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> + #include <osl/mutex.hxx> #include <unotools/eventlisteneradapter.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weakref.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/basemutex.hxx> #include <sot/storage.hxx> +#include <comphelper/listenernotification.hxx> #include <xmlscript/xmllib_imexp.hxx> -#include <com/sun/star/deployment/XPackage.hpp> - -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/compbase8.hxx> -#include <cppuhelper/interfacecontainer.hxx> -#include <com/sun/star/script/vba/XVBACompatibility.hpp> class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper8< - ::com::sun::star::lang::XInitialization, - ::com::sun::star::script::XStorageBasedLibraryContainer, - ::com::sun::star::script::XLibraryContainerPassword, - ::com::sun::star::script::XLibraryContainerExport, - ::com::sun::star::script::XLibraryContainer3, - ::com::sun::star::container::XContainer, - ::com::sun::star::script::vba::XVBACompatibility, - ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; - -typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, - ::com::sun::star::container::XContainer > NameContainerHelper; - +//============================================================================ -struct hashName_Impl -{ - size_t operator()(const ::rtl::OUString Str) const - { - return (size_t)Str.hashCode(); - } -}; +typedef ::cppu::WeakImplHelper3< + ::com::sun::star::container::XNameContainer, + ::com::sun::star::container::XContainer, + ::com::sun::star::util::XChangesNotifier > NameContainer_BASE; -struct eqName_Impl +class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE { - sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const - { - return ( Str1 == Str2 ); - } -}; - -typedef std::hash_map -< - ::rtl::OUString, - sal_Int32, - hashName_Impl, - eqName_Impl -> -NameContainerNameMap; - - -//============================================================================ + typedef std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap; -class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper -{ NameContainerNameMap mHashMap; ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues; @@ -119,14 +90,16 @@ class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper ::com::sun::star::uno::Type mType; ::com::sun::star::uno::XInterface* mpxEventSource; - ::cppu::OInterfaceContainerHelper maListenerContainer; + ::cppu::OInterfaceContainerHelper maContainerListeners; + ::cppu::OInterfaceContainerHelper maChangesListeners; public: NameContainer( const ::com::sun::star::uno::Type& rType ) : mnElementCount( 0 ) , mType( rType ) , mpxEventSource( NULL ) - , maListenerContainer( m_aMutex ) + , maContainerListeners( m_aMutex ) + , maChangesListeners( m_aMutex ) {} void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource ) @@ -173,21 +146,18 @@ public: virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); }; //============================================================================ -class SfxLibrary; - -enum InitMode -{ - DEFAULT, - CONTAINER_INIT_FILE, - LIBRARY_INIT_FILE, - OFFICE_DOCUMENT, - OLD_BASIC_STORAGE -}; - class ModifiableHelper { private: @@ -217,9 +187,42 @@ public: } }; -class SfxLibraryContainer :public LibraryContainerHelper - ,public ::utl::OEventListenerAdapter +//============================================================================ + +typedef ::comphelper::OListenerContainerBase< + ::com::sun::star::script::vba::XVBAScriptListener, + ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE; + +class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE +{ +public: + explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex ); + +private: + virtual bool implTypedNotify( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener, + const ::com::sun::star::script::vba::VBAScriptEvent& rEvent ) + throw (::com::sun::star::uno::Exception); +}; + +//============================================================================ + +class SfxLibrary; + +typedef ::cppu::WeakComponentImplHelper8< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::script::XStorageBasedLibraryContainer, + ::com::sun::star::script::XLibraryContainerPassword, + ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, + ::com::sun::star::container::XContainer, + ::com::sun::star::script::vba::XVBACompatibility, + ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE; + +class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter { + VBAScriptListenerContainer maVBAScriptListeners; + sal_Int32 mnRunningVBAScripts; sal_Bool mbVBACompat; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; @@ -246,7 +249,14 @@ protected: BasicManager* mpBasMgr; sal_Bool mbOwnBasMgr; - InitMode meInitMode; + enum InitMode + { + DEFAULT, + CONTAINER_INIT_FILE, + LIBRARY_INIT_FILE, + OFFICE_DOCUMENT, + OLD_BASIC_STORAGE + } meInitMode; void implStoreLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, @@ -508,10 +518,24 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; // Methods XVBACompatibility - virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRunningVBAScripts() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) + throw (::com::sun::star::uno::RuntimeException); }; +//============================================================================ + class LibraryContainerMethodGuard { private: @@ -529,12 +553,12 @@ public: } }; - //============================================================================ class SfxLibrary : public ::com::sun::star::container::XNameContainer , public ::com::sun::star::container::XContainer + , public ::com::sun::star::util::XChangesNotifier , public ::cppu::BaseMutex , public ::cppu::OComponentHelper { @@ -670,6 +694,14 @@ public: ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + public: struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } }; void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess ) @@ -681,18 +713,19 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; }; -//=================================================================== +//============================================================================ + class ScriptSubPackageIterator { - com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; - bool m_bIsValid; - bool m_bIsBundle; + bool m_bIsValid; + bool m_bIsBundle; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; - sal_Int32 m_nSubPkgCount; - sal_Int32 m_iNextSubPkg; + < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; + sal_Int32 m_nSubPkgCount; + sal_Int32 m_iNextSubPkg; com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implDetectScriptPackage( const com::sun::star::uno::Reference @@ -704,13 +737,7 @@ public: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); }; -enum IteratorState -{ - USER_EXTENSIONS, - SHARED_EXTENSIONS, - BUNDLED_EXTENSIONS, - END_REACHED -}; +//============================================================================ class ScriptExtensionIterator { @@ -731,34 +758,37 @@ protected: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledScriptPackage( bool& rbPureDialogLib ); - com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; - IteratorState m_eState; + enum IteratorState + { + USER_EXTENSIONS, + SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, + END_REACHED + } m_eState; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; - bool m_bUserPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; + bool m_bUserPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; - bool m_bSharedPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; + bool m_bSharedPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; - bool m_bBundledPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; + int m_iSharedPackage; + int m_iBundledPackage; - int m_iUserPackage; - int m_iSharedPackage; - int m_iBundledPackage; - - - - ScriptSubPackageIterator* m_pScriptSubPackageIterator; + ScriptSubPackageIterator* m_pScriptSubPackageIterator; }; // end class ScriptExtensionIterator - +//============================================================================ } // namespace basic diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 46cd9d16521f..406bd487034c 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -465,6 +465,8 @@ public: SbxArray* GetLocals(); SbxArray* GetParams(); + SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection ); + SbxBase* FindElementExtern( const String& rName ); static bool isVBAEnabled(); diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx index d91c7bdf16e8..4fd139202b52 100755 --- a/basic/source/inc/sbtrace.hxx +++ b/basic/source/inc/sbtrace.hxx @@ -28,7 +28,20 @@ #ifndef _SBTRACE_HXX #define _SBTRACE_HXX -//#define DBG_TRACE_BASIC +#define DBG_TRACE_BASIC + +// ############################################################################### +// ### +// ### ATTENTION: +// ### +// ### - DBG_TRACE_PROFILING can only be activated together with DBG_TRACE_BASIC +// ### +// ### - If you activate DBG_TRACE_PROFILING you also need to uncomment line +// ### # SHL1STDLIBS+=$(CANVASTOOLSLIB) in basic/util/makefile.mk (search +// ### for DBG_TRACE_PROFILING there) +// ### +// ############################################################################### +//#define DBG_TRACE_PROFILING #ifdef DBG_TRACE_BASIC void dbg_InitTrace( void ); diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index d788a73da0fc..9ef4c41c6ce3 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -35,11 +35,11 @@ class BasicManager; -//============================================================================ - namespace basic { +//============================================================================ + class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword { ::rtl::OUString maScriptLanguage; @@ -140,16 +140,15 @@ public: }; //============================================================================ -typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; -typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo - > SfxScriptLibrary_BASE; +typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; -class SfxScriptLibrary : public SfxLibrary - , public SfxScriptLibrary_BASE +class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE { friend class SfxScriptLibraryContainer; + typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap; + sal_Bool mbLoadedSource; sal_Bool mbLoadedBinary; ModuleInfoMap mModuleInfos; @@ -194,7 +193,9 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; }; -} // namespace base +//============================================================================ + +} // namespace basic #endif diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index c30445d87634..576639dc5a45 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -133,6 +133,7 @@ protected: sal_Bool bGlobal : 1; // sal_True: Global-Variable sal_Bool bParamArray : 1; // sal_True: ParamArray parameter sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents + sal_Bool bWithBrackets : 1; // sal_True: Followed by () sal_uInt16 nDefaultId; // Symbol number of default value short nFixedStringLength; // String length in: Dim foo As String*Length public: @@ -159,6 +160,7 @@ public: void SetOptional() { bOpt = sal_True; } void SetParamArray() { bParamArray = sal_True; } void SetWithEvents() { bWithEvents = sal_True; } + void SetWithBrackets(){ bWithBrackets = sal_True; } void SetByVal( sal_Bool bByVal_ = sal_True ) { bByVal = bByVal_; } void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; } @@ -170,6 +172,7 @@ public: sal_Bool IsOptional() const{ return bOpt; } sal_Bool IsParamArray() const{ return bParamArray; } sal_Bool IsWithEvents() const{ return bWithEvents; } + sal_Bool IsWithBrackets() const{ return bWithBrackets; } sal_Bool IsByVal() const { return bByVal; } sal_Bool IsStatic() const { return bStatic; } sal_Bool IsNew() const { return bNew; } |