Bump version to 6.4-15
[LibreOffice.git] / include / basic / sbmod.hxx
blob8ba26e4568aeb836f37db8f3dc9863c59f6494c8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_BASIC_SBMOD_HXX
21 #define INCLUDED_BASIC_SBMOD_HXX
23 #include <basic/sbdef.hxx>
24 #include <basic/sbxobj.hxx>
25 #include <basic/sbxdef.hxx>
26 #include <basic/sbx.hxx>
27 #include <rtl/ustring.hxx>
28 #include <vector>
29 #include <deque>
30 #include <basic/basicdllapi.h>
31 #include <com/sun/star/uno/Reference.hxx>
33 namespace com::sun::star::script { class XInvocation; }
35 class SbMethod;
36 class SbProperty;
37 typedef std::deque< sal_uInt16 > SbiBreakpoints;
38 class SbiImage;
39 class SbClassModuleObject;
40 class CodeCompleteDataCache;
43 class ModuleInitDependencyMap;
44 struct ClassModuleRunInitItem;
45 struct SbClassData;
47 class BASIC_DLLPUBLIC SbModule : public SbxObject
49 friend class SbiCodeGen;
50 friend class SbMethod;
51 friend class SbiRuntime;
52 friend class StarBASIC;
53 friend class SbClassModuleObject;
55 std::vector< OUString > mModuleVariableNames;
57 BASIC_DLLPRIVATE static void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
59 SbModule(const SbModule&) = delete;
60 SbModule& operator=(const SbModule&) = delete;
61 protected:
62 css::uno::Reference< css::script::XInvocation > mxWrapper;
63 OUString aOUSource;
64 OUString aComment;
65 SbiImage* pImage; // the Image
66 SbiBreakpoints* pBreaks; // Breakpoints
67 std::unique_ptr<SbClassData> pClassData;
68 bool mbVBACompat;
69 sal_Int32 mnType;
70 SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
71 bool bIsProxyModule;
73 static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
74 void StartDefinitions();
75 SbMethod* GetMethod( const OUString&, SbxDataType );
76 SbProperty* GetProperty( const OUString&, SbxDataType );
77 void GetProcedureProperty( const OUString&, SbxDataType );
78 void GetIfaceMapperMethod( const OUString&, SbMethod* );
79 void EndDefinitions( bool=false );
80 void Run( SbMethod* );
81 void RunInit();
82 void ClearPrivateVars();
83 void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
84 void GlobalRunInit( bool bBasicStart ); // for all modules
85 void GlobalRunDeInit();
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=nullptr ) const;
89 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
90 virtual bool StoreData( SvStream& ) const override;
91 virtual bool LoadCompleted() override;
92 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
93 void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
94 virtual ~SbModule() override;
95 public:
96 SBX_DECL_PERSIST_NODATA(SBXID_BASICMOD,2);
97 SbModule( const OUString&, bool bCompat = false );
98 virtual void SetParent( SbxObject* ) override;
99 virtual void Clear() override;
101 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
103 const OUString& GetSource() const;
104 const OUString& GetSource32() const { return aOUSource;}
105 void SetSource32( const OUString& r );
107 bool Compile();
108 bool IsCompiled() const;
109 const SbxObject* FindType( const OUString& aTypeName ) const;
111 bool IsBreakable( sal_uInt16 nLine ) const;
112 bool IsBP( sal_uInt16 nLine ) const;
113 bool SetBP( sal_uInt16 nLine );
114 bool ClearBP( sal_uInt16 nLine );
115 void ClearAllBP();
117 // Store only image, no source (needed for new password protection)
118 void StoreBinaryData( SvStream& );
119 void LoadBinaryData( SvStream& );
120 bool ExceedsLegacyModuleSize();
121 void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = nullptr ) const;
122 bool HasExeCode();
123 bool IsVBACompat() const { return mbVBACompat;}
124 void SetVBACompat( bool bCompat );
125 sal_Int32 GetModuleType() const { return mnType; }
126 void SetModuleType( sal_Int32 nType ) { mnType = nType; }
127 bool isProxyModule() const { return bIsProxyModule; }
128 void AddVarName( const OUString& aName );
129 void RemoveVars();
130 css::uno::Reference< css::script::XInvocation > const & GetUnoModule();
131 bool createCOMWrapperForIface( css::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
132 void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
133 const SbxArrayRef& GetMethods() const { return pMethods;}
134 SbMethod* FindMethod( const OUString&, SbxClassType );
135 static OUString GetKeywordCase( const OUString& sKeyword );
138 typedef tools::SvRef<SbModule> SbModuleRef;
139 typedef std::vector<SbModuleRef> SbModules;
141 // Object class for instances of class modules
142 class BASIC_DLLPUBLIC SbClassModuleObject : public SbModule
144 SbModule* mpClassModule;
145 bool mbInitializeEventDone;
147 public:
148 SbClassModuleObject( SbModule* pClassModule );
149 virtual ~SbClassModuleObject() override;
151 // Overridden to support NameAccess etc.
152 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
154 virtual void Notify( SfxBroadcaster&, const SfxHint& rHint ) override;
156 SbModule* getClassModule()
157 { return mpClassModule; }
159 void triggerInitializeEvent();
160 void triggerTerminateEvent();
163 #endif
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */