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 :
46 : class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable
47 : {
48 : friend class SbiCodeGen;
49 : friend class SbMethod;
50 : friend class SbiRuntime;
51 : friend class StarBASIC;
52 : friend class SbClassModuleObject;
53 :
54 : std::vector< OUString > mModuleVariableNames;
55 :
56 : BASIC_DLLPRIVATE void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
57 :
58 : protected:
59 : com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper;
60 : OUString aOUSource;
61 : OUString aComment;
62 : SbiImage* pImage; // the Image
63 : SbiBreakpoints* pBreaks; // Breakpoints
64 : SbClassData* pClassData;
65 : bool mbVBACompat;
66 : sal_Int32 mnType;
67 : SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
68 : bool bIsProxyModule;
69 :
70 : static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
71 : void StartDefinitions();
72 : SbMethod* GetMethod( const OUString&, SbxDataType );
73 : SbProperty* GetProperty( const OUString&, SbxDataType );
74 : SbProcedureProperty* GetProcedureProperty( const OUString&, SbxDataType );
75 : SbIfaceMapperMethod* GetIfaceMapperMethod( const OUString&, SbMethod* );
76 : void EndDefinitions( sal_Bool=sal_False );
77 : sal_uInt16 Run( SbMethod* );
78 : void RunInit();
79 : void ClearPrivateVars();
80 : void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
81 : void GlobalRunInit( bool bBasicStart ); // for all modules
82 : void GlobalRunDeInit( void );
83 : const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
84 : const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
85 : sal_Bool bFollowJumps, const SbiImage* pImg=NULL ) const;
86 : virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
87 : virtual sal_Bool StoreData( SvStream& ) const;
88 : virtual sal_Bool LoadCompleted();
89 : virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
90 : const SfxHint& rHint, const TypeId& rHintType );
91 : void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
92 : virtual ~SbModule();
93 : public:
94 0 : SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2);
95 : TYPEINFO();
96 : SbModule( const OUString&, sal_Bool bCompat = sal_False );
97 : virtual void SetParent( SbxObject* );
98 : virtual void Clear();
99 :
100 : virtual SbxVariable* Find( const OUString&, SbxClassType );
101 :
102 : virtual const OUString& GetSource() const;
103 : const OUString& GetSource32() const;
104 : const OUString& GetComment() const { return aComment; }
105 : virtual void SetSource( const OUString& r );
106 : void SetSource32( const OUString& r );
107 :
108 : virtual sal_Bool Compile();
109 : virtual sal_Bool IsCompiled() const;
110 : const SbxObject* FindType( OUString aTypeName ) const;
111 :
112 : virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const;
113 : virtual size_t GetBPCount() const;
114 : virtual sal_uInt16 GetBP( size_t n ) const;
115 : virtual sal_Bool IsBP( sal_uInt16 nLine ) const;
116 : virtual sal_Bool SetBP( sal_uInt16 nLine );
117 : virtual sal_Bool ClearBP( sal_uInt16 nLine );
118 : virtual void ClearAllBP();
119 :
120 : // Lines of Subs
121 : virtual SbMethod* GetFunctionForLine( sal_uInt16 );
122 :
123 : // Store only image, no source (needed for new password protection)
124 : sal_Bool StoreBinaryData( SvStream& );
125 : sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
126 : sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer );
127 : sal_Bool LoadBinaryData( SvStream& );
128 : sal_Bool ExceedsLegacyModuleSize();
129 : void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
130 : bool HasExeCode();
131 : bool IsVBACompat() const;
132 : void SetVBACompat( bool bCompat );
133 22 : sal_Int32 GetModuleType() { return mnType; }
134 36 : void SetModuleType( sal_Int32 nType ) { mnType = nType; }
135 28 : bool isProxyModule() { return bIsProxyModule; }
136 : void AddVarName( const OUString& aName );
137 : void RemoveVars();
138 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule();
139 : bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
140 : };
141 :
142 0 : SV_DECL_IMPL_REF(SbModule)
143 :
144 : // Object class for instances of class modules
145 : class BASIC_DLLPUBLIC SbClassModuleObject : public SbModule
146 : {
147 : SbModule* mpClassModule;
148 : bool mbInitializeEventDone;
149 :
150 : public:
151 : TYPEINFO();
152 : SbClassModuleObject( SbModule* pClassModule );
153 : ~SbClassModuleObject();
154 :
155 : // Overridden to support NameAccess etc.
156 : virtual SbxVariable* Find( const OUString&, SbxClassType );
157 :
158 : virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
159 :
160 0 : SbModule* getClassModule( void )
161 0 : { return mpClassModule; }
162 :
163 : void triggerInitializeEvent( void );
164 : void triggerTerminateEvent( void );
165 : };
166 :
167 : #endif
168 :
169 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|