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 sal_Bool IsBP( sal_uInt16 nLine ) const;
114 : virtual sal_Bool SetBP( sal_uInt16 nLine );
115 : virtual sal_Bool ClearBP( sal_uInt16 nLine );
116 : virtual void ClearAllBP();
117 :
118 : // Store only image, no source (needed for new password protection)
119 : sal_Bool StoreBinaryData( SvStream& );
120 : sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
121 : sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer );
122 : sal_Bool LoadBinaryData( SvStream& );
123 : sal_Bool ExceedsLegacyModuleSize();
124 : void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
125 : bool HasExeCode();
126 : bool IsVBACompat() const;
127 : void SetVBACompat( bool bCompat );
128 19122 : sal_Int32 GetModuleType() { return mnType; }
129 330 : void SetModuleType( sal_Int32 nType ) { mnType = nType; }
130 1183 : bool isProxyModule() { return bIsProxyModule; }
131 : void AddVarName( const OUString& aName );
132 : void RemoveVars();
133 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule();
134 : bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
135 : };
136 :
137 268 : SV_DECL_IMPL_REF(SbModule)
138 :
139 : // Object class for instances of class modules
140 : class BASIC_DLLPUBLIC SbClassModuleObject : public SbModule
141 : {
142 : SbModule* mpClassModule;
143 : bool mbInitializeEventDone;
144 :
145 : public:
146 : TYPEINFO();
147 : SbClassModuleObject( SbModule* pClassModule );
148 : ~SbClassModuleObject();
149 :
150 : // Overridden to support NameAccess etc.
151 : virtual SbxVariable* Find( const OUString&, SbxClassType );
152 :
153 : virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
154 :
155 0 : SbModule* getClassModule( void )
156 0 : { return mpClassModule; }
157 :
158 : void triggerInitializeEvent( void );
159 : void triggerTerminateEvent( void );
160 : };
161 :
162 : #endif
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|