1*234bd5c5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*234bd5c5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*234bd5c5SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*234bd5c5SAndrew Rist * distributed with this work for additional information 6*234bd5c5SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*234bd5c5SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*234bd5c5SAndrew Rist * "License"); you may not use this file except in compliance 9*234bd5c5SAndrew Rist * with the License. You may obtain a copy of the License at 10*234bd5c5SAndrew Rist * 11*234bd5c5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*234bd5c5SAndrew Rist * 13*234bd5c5SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*234bd5c5SAndrew Rist * software distributed under the License is distributed on an 15*234bd5c5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*234bd5c5SAndrew Rist * KIND, either express or implied. See the License for the 17*234bd5c5SAndrew Rist * specific language governing permissions and limitations 18*234bd5c5SAndrew Rist * under the License. 19*234bd5c5SAndrew Rist * 20*234bd5c5SAndrew Rist *************************************************************/ 21*234bd5c5SAndrew Rist 22*234bd5c5SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SB_SBMOD_HXX 25cdf0e10cSrcweir #define _SB_SBMOD_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 28cdf0e10cSrcweir #include <basic/sbdef.hxx> 29cdf0e10cSrcweir #include <basic/sbxobj.hxx> 30cdf0e10cSrcweir #include <basic/sbxdef.hxx> 31cdf0e10cSrcweir #include <rtl/ustring.hxx> 32cdf0e10cSrcweir #include <vector> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <deque> 35cdf0e10cSrcweir 36cdf0e10cSrcweir class SbMethod; 37cdf0e10cSrcweir class SbProperty; 38cdf0e10cSrcweir class SbiRuntime; 39cdf0e10cSrcweir typedef std::deque< sal_uInt16 > SbiBreakpoints; 40cdf0e10cSrcweir class SbiImage; 41cdf0e10cSrcweir class SbProcedureProperty; 42cdf0e10cSrcweir class SbIfaceMapperMethod; 43cdf0e10cSrcweir class SbClassModuleObject; 44cdf0e10cSrcweir 45cdf0e10cSrcweir class ModuleInitDependencyMap; 46cdf0e10cSrcweir struct ClassModuleRunInitItem; 47cdf0e10cSrcweir struct SbClassData; 48cdf0e10cSrcweir class SbModuleImpl; 49cdf0e10cSrcweir 50cdf0e10cSrcweir class SbModule : public SbxObject 51cdf0e10cSrcweir { 52cdf0e10cSrcweir friend class TestToolObj; // allows module initialisation at runtime 53cdf0e10cSrcweir friend class SbiCodeGen; 54cdf0e10cSrcweir friend class SbMethod; 55cdf0e10cSrcweir friend class SbiRuntime; 56cdf0e10cSrcweir friend class StarBASIC; 57cdf0e10cSrcweir friend class SbClassModuleObject; 58cdf0e10cSrcweir 59cdf0e10cSrcweir SbModuleImpl* mpSbModuleImpl; // Impl data 60cdf0e10cSrcweir std::vector< String > mModuleVariableNames; 61cdf0e10cSrcweir 62cdf0e10cSrcweir void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic ); 63cdf0e10cSrcweir 64cdf0e10cSrcweir protected: 65cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; 66cdf0e10cSrcweir ::rtl::OUString aOUSource; 67cdf0e10cSrcweir String aComment; 68cdf0e10cSrcweir SbiImage* pImage; // the Image 69cdf0e10cSrcweir SbiBreakpoints* pBreaks; // Breakpoints 70cdf0e10cSrcweir SbClassData* pClassData; 71cdf0e10cSrcweir sal_Bool mbVBACompat; 72cdf0e10cSrcweir sal_Int32 mnType; 73cdf0e10cSrcweir SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) 74cdf0e10cSrcweir bool bIsProxyModule; 75cdf0e10cSrcweir 76cdf0e10cSrcweir static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem ); 77cdf0e10cSrcweir void StartDefinitions(); 78cdf0e10cSrcweir SbMethod* GetMethod( const String&, SbxDataType ); 79cdf0e10cSrcweir SbProperty* GetProperty( const String&, SbxDataType ); 80cdf0e10cSrcweir SbProcedureProperty* GetProcedureProperty( const String&, SbxDataType ); 81cdf0e10cSrcweir SbIfaceMapperMethod* GetIfaceMapperMethod( const String&, SbMethod* ); 82cdf0e10cSrcweir void EndDefinitions( sal_Bool=sal_False ); 83cdf0e10cSrcweir sal_uInt16 Run( SbMethod* ); 84cdf0e10cSrcweir void RunInit(); 85cdf0e10cSrcweir void ClearPrivateVars(); 86cdf0e10cSrcweir void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic ); 87cdf0e10cSrcweir void GlobalRunInit( sal_Bool bBasicStart ); // for all modules 88cdf0e10cSrcweir void GlobalRunDeInit( void ); 89cdf0e10cSrcweir const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const; 90cdf0e10cSrcweir const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&, 91cdf0e10cSrcweir sal_Bool bFollowJumps, const SbiImage* pImg=NULL ) const; 92cdf0e10cSrcweir virtual sal_Bool LoadData( SvStream&, sal_uInt16 ); 93cdf0e10cSrcweir virtual sal_Bool StoreData( SvStream& ) const; 94cdf0e10cSrcweir virtual sal_Bool LoadCompleted(); 95cdf0e10cSrcweir virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, 96cdf0e10cSrcweir const SfxHint& rHint, const TypeId& rHintType ); 97cdf0e10cSrcweir void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint ); 98cdf0e10cSrcweir virtual ~SbModule(); 99cdf0e10cSrcweir public: 100cdf0e10cSrcweir SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2); 101cdf0e10cSrcweir TYPEINFO(); 102cdf0e10cSrcweir SbModule( const String&, sal_Bool bCompat = sal_False ); 103cdf0e10cSrcweir virtual void SetParent( SbxObject* ); 104cdf0e10cSrcweir virtual void Clear(); 105cdf0e10cSrcweir 106cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual const String& GetSource() const; 109cdf0e10cSrcweir const ::rtl::OUString& GetSource32() const; GetComment() const110cdf0e10cSrcweir const String& GetComment() const { return aComment; } 111cdf0e10cSrcweir virtual void SetSource( const String& r ); 112cdf0e10cSrcweir void SetSource32( const ::rtl::OUString& r ); 113cdf0e10cSrcweir void SetComment( const String& r ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir virtual sal_Bool Compile(); 116cdf0e10cSrcweir sal_Bool Disassemble( String& rText ); 117cdf0e10cSrcweir virtual sal_Bool IsCompiled() const; 118cdf0e10cSrcweir const SbxObject* FindType( String aTypeName ) const; 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const; 121cdf0e10cSrcweir virtual size_t GetBPCount() const; 122cdf0e10cSrcweir virtual sal_uInt16 GetBP( size_t n ) const; 123cdf0e10cSrcweir virtual sal_Bool IsBP( sal_uInt16 nLine ) const; 124cdf0e10cSrcweir virtual sal_Bool SetBP( sal_uInt16 nLine ); 125cdf0e10cSrcweir virtual sal_Bool ClearBP( sal_uInt16 nLine ); 126cdf0e10cSrcweir virtual void ClearAllBP(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // Lines of Subs 129cdf0e10cSrcweir virtual SbMethod* GetFunctionForLine( sal_uInt16 ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir // Store only image, no source (needed for new password protection) 132cdf0e10cSrcweir sal_Bool StoreBinaryData( SvStream& ); 133cdf0e10cSrcweir sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer ); 134cdf0e10cSrcweir sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer ); 135cdf0e10cSrcweir sal_Bool LoadBinaryData( SvStream& ); 136cdf0e10cSrcweir sal_Bool ExceedsLegacyModuleSize(); 137cdf0e10cSrcweir void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; 138cdf0e10cSrcweir sal_Bool IsVBACompat() const; 139cdf0e10cSrcweir void SetVBACompat( sal_Bool bCompat ); GetModuleType()140cdf0e10cSrcweir sal_Int32 GetModuleType() { return mnType; } SetModuleType(sal_Int32 nType)141cdf0e10cSrcweir void SetModuleType( sal_Int32 nType ) { mnType = nType; } isProxyModule()142cdf0e10cSrcweir bool isProxyModule() { return bIsProxyModule; } 143cdf0e10cSrcweir void AddVarName( const String& aName ); 144cdf0e10cSrcweir void RemoveVars(); 145cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); 146cdf0e10cSrcweir bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); 147cdf0e10cSrcweir }; 148cdf0e10cSrcweir 149cdf0e10cSrcweir #ifndef __SB_SBMODULEREF_HXX 150cdf0e10cSrcweir #define __SB_SBMODULEREF_HXX 151cdf0e10cSrcweir 152cdf0e10cSrcweir SV_DECL_IMPL_REF(SbModule) 153cdf0e10cSrcweir 154cdf0e10cSrcweir #endif 155cdf0e10cSrcweir 156cdf0e10cSrcweir class SbClassModuleImpl; 157cdf0e10cSrcweir 158cdf0e10cSrcweir // Object class for instances of class modules 159cdf0e10cSrcweir class SbClassModuleObject : public SbModule 160cdf0e10cSrcweir { 161cdf0e10cSrcweir SbClassModuleImpl* mpSbClassModuleImpl; 162cdf0e10cSrcweir 163cdf0e10cSrcweir SbModule* mpClassModule; 164cdf0e10cSrcweir bool mbInitializeEventDone; 165cdf0e10cSrcweir 166cdf0e10cSrcweir public: 167cdf0e10cSrcweir TYPEINFO(); 168cdf0e10cSrcweir SbClassModuleObject( SbModule* pClassModule ); 169cdf0e10cSrcweir ~SbClassModuleObject(); 170cdf0e10cSrcweir 171cdf0e10cSrcweir // Overridden to support NameAccess etc. 172cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); 175cdf0e10cSrcweir getClassModule(void)176cdf0e10cSrcweir SbModule* getClassModule( void ) 177cdf0e10cSrcweir { return mpClassModule; } 178cdf0e10cSrcweir 179cdf0e10cSrcweir void triggerInitializeEvent( void ); 180cdf0e10cSrcweir void triggerTerminateEvent( void ); 181cdf0e10cSrcweir }; 182cdf0e10cSrcweir 183cdf0e10cSrcweir #ifndef __SB_SBCLASSMODULEREF_HXX 184cdf0e10cSrcweir #define __SB_SBCLASSMODULEREF_HXX 185cdf0e10cSrcweir 186cdf0e10cSrcweir SV_DECL_IMPL_REF(SbClassModuleObject); 187cdf0e10cSrcweir 188cdf0e10cSrcweir #endif 189cdf0e10cSrcweir 190cdf0e10cSrcweir #endif 191