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 <rtl/ustring.hxx>
28 : #include <vector>
29 : #include <deque>
30 : #include <boost/utility.hpp>
31 : #include <basic/basicdllapi.h>
32 : #include <basic/codecompletecache.hxx>
33 :
34 : class SbMethod;
35 : class SbProperty;
36 : class SbiRuntime;
37 : typedef std::deque< sal_uInt16 > SbiBreakpoints;
38 : class SbiImage;
39 : class SbProcedureProperty;
40 : class SbIfaceMapperMethod;
41 : class SbClassModuleObject;
42 :
43 :
44 : class ModuleInitDependencyMap;
45 : struct ClassModuleRunInitItem;
46 : struct SbClassData;
47 :
48 : class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable
49 : {
50 : friend class SbiCodeGen;
51 : friend class SbMethod;
52 : friend class SbiRuntime;
53 : friend class StarBASIC;
54 : friend class SbClassModuleObject;
55 :
56 : std::vector< OUString > 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 : OUString aOUSource;
63 : OUString 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 OUString&, SbxDataType );
75 : SbProperty* GetProperty( const OUString&, SbxDataType );
76 : SbProcedureProperty* GetProcedureProperty( const OUString&, SbxDataType );
77 : SbIfaceMapperMethod* GetIfaceMapperMethod( const OUString&, SbMethod* );
78 : void EndDefinitions( bool=false );
79 : sal_uInt16 Run( SbMethod* );
80 : void RunInit();
81 : void ClearPrivateVars();
82 : void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
83 : void GlobalRunInit( 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 : bool bFollowJumps, const SbiImage* pImg=NULL ) const;
88 : virtual bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
89 : virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
90 : virtual bool LoadCompleted() SAL_OVERRIDE;
91 : virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
92 : const SfxHint& rHint, const TypeId& rHintType ) SAL_OVERRIDE;
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_OVERRIDE();
98 : SbModule( const OUString&, bool bCompat = false );
99 : virtual void SetParent( SbxObject* ) SAL_OVERRIDE;
100 : virtual void Clear() SAL_OVERRIDE;
101 :
102 : virtual SbxVariable* Find( const OUString&, SbxClassType ) SAL_OVERRIDE;
103 :
104 : virtual const OUString& GetSource() const;
105 : const OUString& GetSource32() const;
106 : const OUString& GetComment() const { return aComment; }
107 : virtual void SetSource( const OUString& r );
108 : void SetSource32( const OUString& r );
109 :
110 : virtual bool Compile();
111 : virtual bool IsCompiled() const;
112 : const SbxObject* FindType( const OUString& aTypeName ) const;
113 :
114 : virtual bool IsBreakable( sal_uInt16 nLine ) const;
115 : virtual bool IsBP( sal_uInt16 nLine ) const;
116 : virtual bool SetBP( sal_uInt16 nLine );
117 : virtual bool ClearBP( sal_uInt16 nLine );
118 : virtual void ClearAllBP();
119 :
120 : // Store only image, no source (needed for new password protection)
121 : bool StoreBinaryData( SvStream& );
122 : bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
123 : bool LoadBinaryData( SvStream&, sal_uInt16 nVer );
124 : bool LoadBinaryData( SvStream& );
125 : bool ExceedsLegacyModuleSize();
126 : void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
127 : bool HasExeCode();
128 : bool IsVBACompat() const;
129 : void SetVBACompat( bool bCompat );
130 0 : sal_Int32 GetModuleType() { return mnType; }
131 0 : void SetModuleType( sal_Int32 nType ) { mnType = nType; }
132 0 : bool isProxyModule() { return bIsProxyModule; }
133 : void AddVarName( const OUString& aName );
134 : void RemoveVars();
135 : ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule();
136 : bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
137 : void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
138 : SbxArrayRef GetMethods();
139 : OUString GetKeywordCase( const OUString& sKeyword ) const;
140 : };
141 :
142 : typedef tools::SvRef<SbModule> SbModuleRef;
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_OVERRIDE();
152 : SbClassModuleObject( SbModule* pClassModule );
153 : virtual ~SbClassModuleObject();
154 :
155 : // Overridden to support NameAccess etc.
156 : virtual SbxVariable* Find( const OUString&, SbxClassType ) SAL_OVERRIDE;
157 :
158 : virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ) SAL_OVERRIDE;
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: */
|