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