1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
30 #include <boost/utility.hpp>
31 #include "basicdllapi.h"
36 typedef std::deque
< sal_uInt16
> SbiBreakpoints
;
38 class SbProcedureProperty
;
39 class SbIfaceMapperMethod
;
40 class SbClassModuleObject
;
42 class ModuleInitDependencyMap
;
43 struct ClassModuleRunInitItem
;
46 class BASIC_DLLPUBLIC SbModule
: public SbxObject
, private ::boost::noncopyable
48 friend class SbiCodeGen
;
49 friend class SbMethod
;
50 friend class SbiRuntime
;
51 friend class StarBASIC
;
52 friend class SbClassModuleObject
;
54 std::vector
< OUString
> mModuleVariableNames
;
56 BASIC_DLLPRIVATE
void implClearIfVarDependsOnDeletedBasic( SbxVariable
* pVar
, StarBASIC
* pDeletedBasic
);
59 com::sun::star::uno::Reference
< com::sun::star::script::XInvocation
> mxWrapper
;
62 SbiImage
* pImage
; // the Image
63 SbiBreakpoints
* pBreaks
; // Breakpoints
64 SbClassData
* pClassData
;
67 SbxObjectRef pDocObject
; // an impl object ( used by Document Modules )
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
* );
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
);
94 SBX_DECL_PERSIST_NODATA(SBXCR_SBX
,SBXID_BASICMOD
,2);
96 SbModule( const OUString
&, sal_Bool bCompat
= sal_False
);
97 virtual void SetParent( SbxObject
* );
100 virtual SbxVariable
* Find( const OUString
&, SbxClassType
);
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
);
108 virtual sal_Bool
Compile();
109 virtual sal_Bool
IsCompiled() const;
110 const SbxObject
* FindType( OUString aTypeName
) const;
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();
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;
126 bool IsVBACompat() const;
127 void SetVBACompat( bool bCompat
);
128 sal_Int32
GetModuleType() { return mnType
; }
129 void SetModuleType( sal_Int32 nType
) { mnType
= nType
; }
130 bool isProxyModule() { return bIsProxyModule
; }
131 void AddVarName( const OUString
& aName
);
133 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XInvocation
> GetUnoModule();
134 bool createCOMWrapperForIface( ::com::sun::star::uno::Any
& o_rRetAny
, SbClassModuleObject
* pProxyClassModuleObject
);
137 SV_DECL_IMPL_REF(SbModule
)
139 // Object class for instances of class modules
140 class BASIC_DLLPUBLIC SbClassModuleObject
: public SbModule
142 SbModule
* mpClassModule
;
143 bool mbInitializeEventDone
;
147 SbClassModuleObject( SbModule
* pClassModule
);
148 ~SbClassModuleObject();
150 // Overridden to support NameAccess etc.
151 virtual SbxVariable
* Find( const OUString
&, SbxClassType
);
153 virtual void SFX_NOTIFY( SfxBroadcaster
&, const TypeId
&, const SfxHint
& rHint
, const TypeId
& );
155 SbModule
* getClassModule( void )
156 { return mpClassModule
; }
158 void triggerInitializeEvent( void );
159 void triggerTerminateEvent( void );
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */