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