LibreOffice Module basic (master) 1
sbmod.hxx
Go to the documentation of this file.
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 <config_options.h>
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 <basic/basicdllapi.h>
32#include <com/sun/star/uno/Reference.hxx>
33
34namespace com::sun::star::script { class XInvocation; }
35
36class SbMethod;
37class SbProperty;
38typedef std::deque< sal_uInt16 > SbiBreakpoints;
39class SbiImage;
40class SbClassModuleObject;
41class CodeCompleteDataCache;
42
43
46struct SbClassData;
47
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 static void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
59
60 SbModule(const SbModule&) = delete;
61 SbModule& operator=(const SbModule&) = delete;
62protected:
63 css::uno::Reference< css::script::XInvocation > mxWrapper;
64 OUString aOUSource;
65 OUString aComment;
66 std::unique_ptr<SbiImage> pImage; // the Image
67 SbiBreakpoints* pBreaks; // Breakpoints
68 std::unique_ptr<SbClassData> pClassData;
69 bool mbVBASupport; // Option VBASupport
70 bool mbCompat; // Option Compatible
71 sal_Int32 mnType;
72 SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
74
75 SAL_DLLPRIVATE static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
76 SAL_DLLPRIVATE void StartDefinitions();
77 SAL_DLLPRIVATE SbMethod* GetMethod( const OUString&, SbxDataType );
78 SAL_DLLPRIVATE SbProperty* GetProperty( const OUString&, SbxDataType );
79 SAL_DLLPRIVATE void GetProcedureProperty( const OUString&, SbxDataType );
80 SAL_DLLPRIVATE void GetIfaceMapperMethod( const OUString&, SbMethod* );
81 SAL_DLLPRIVATE void EndDefinitions( bool=false );
82 SAL_DLLPRIVATE void Run( SbMethod* );
83 SAL_DLLPRIVATE void RunInit();
84 SAL_DLLPRIVATE void ClearPrivateVars();
85 SAL_DLLPRIVATE void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
86 SAL_DLLPRIVATE void GlobalRunInit( bool bBasicStart ); // for all modules
87 SAL_DLLPRIVATE void GlobalRunDeInit();
88 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
89 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
90 bool bFollowJumps, const SbiImage* pImg=nullptr ) const;
91 SAL_DLLPRIVATE virtual bool LoadData( SvStream&, sal_uInt16 ) override;
92 SAL_DLLPRIVATE virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override;
93 SAL_DLLPRIVATE virtual bool LoadCompleted() override;
94 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
95 SAL_DLLPRIVATE void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
96 virtual ~SbModule() override;
97 bool IsOptionCompatible() const override { return mbCompat; }
98
99public:
101 SbModule( const OUString&, bool bVBASupport = false );
102 SAL_DLLPRIVATE virtual void SetParent( SbxObject* ) override;
103 SAL_DLLPRIVATE virtual void Clear() override;
104
105 SAL_DLLPRIVATE virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
106
107 const OUString& GetSource32() const { return aOUSource;}
108 void SetSource32( const OUString& r );
109
110 bool Compile();
111 bool IsCompiled() const;
112 SAL_DLLPRIVATE const SbxObject* FindType( const OUString& aTypeName ) const;
113
114 SAL_DLLPRIVATE bool IsBreakable( sal_uInt16 nLine ) const;
115 SAL_DLLPRIVATE bool IsBP( sal_uInt16 nLine ) const;
116 bool SetBP( sal_uInt16 nLine );
117 bool ClearBP( sal_uInt16 nLine );
118 void ClearAllBP();
119
120 // Store only image, no source (needed for new password protection)
121 SAL_DLLPRIVATE void StoreBinaryData( SvStream& );
122 SAL_DLLPRIVATE void LoadBinaryData( SvStream& );
123 SAL_DLLPRIVATE bool ExceedsImgVersion12ModuleSize();
124 SAL_DLLPRIVATE void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = nullptr ) const;
125 SAL_DLLPRIVATE bool HasExeCode();
126 bool IsVBASupport() const { return mbVBASupport; }
127 SAL_DLLPRIVATE void SetVBASupport( bool bSupport );
128 sal_Int32 GetModuleType() const { return mnType; }
129 void SetModuleType( sal_Int32 nType ) { mnType = nType; }
130 bool isProxyModule() const { return bIsProxyModule; }
131 SAL_DLLPRIVATE void AddVarName( const OUString& aName );
132 SAL_DLLPRIVATE void RemoveVars();
133 css::uno::Reference< css::script::XInvocation > const & GetUnoModule();
134 bool createCOMWrapperForIface( css::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
135 void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
136 const SbxArrayRef& GetMethods() const { return pMethods;}
137 SbMethod* FindMethod( const OUString&, SbxClassType );
138 static OUString GetKeywordCase( std::u16string_view sKeyword );
139};
140
142typedef std::vector<SbModuleRef> SbModules;
143
144// Object class for instances of class modules
145class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbClassModuleObject final : public SbModule
146{
147 SbModule* mpClassModule;
148 bool mbInitializeEventDone;
149
150public:
151 SbClassModuleObject( SbModule* pClassModule );
152 virtual ~SbClassModuleObject() override;
153
154 // Overridden to support NameAccess etc.
155 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
156
157 virtual void Notify( SfxBroadcaster&, const SfxHint& rHint ) override;
158
159 SbModule* getClassModule()
160 { return mpClassModule; }
161
162 void triggerInitializeEvent();
163 void triggerTerminateEvent();
164};
165
166#endif
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASIC_DLLPRIVATE
Definition: basicdllapi.h:19
#define BASIC_DLLPUBLIC
Definition: basicdllapi.h:17
sal_Int32 mnType
Definition: sbmod.hxx:71
bool bIsProxyModule
Definition: sbmod.hxx:73
friend class SbClassModuleObject
Definition: sbmod.hxx:54
bool mbCompat
Definition: sbmod.hxx:70
OUString aComment
Definition: sbmod.hxx:65
bool mbVBASupport
Definition: sbmod.hxx:69
const SbxArrayRef & GetMethods() const
Definition: sbmod.hxx:136
virtual SAL_DLLPRIVATE SbxVariable * Find(const OUString &, SbxClassType) override
Definition: sbxmod.cxx:626
sal_Int32 GetModuleType() const
Definition: sbmod.hxx:128
virtual SAL_DLLPRIVATE void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: sbxmod.cxx:674
std::unique_ptr< SbiImage > pImage
Definition: sbmod.hxx:66
SbModule & operator=(const SbModule &)=delete
bool IsOptionCompatible() const override
Definition: sbmod.hxx:97
SbModule(const SbModule &)=delete
std::vector< OUString > mModuleVariableNames
Definition: sbmod.hxx:56
void SetModuleType(sal_Int32 nType)
Definition: sbmod.hxx:129
css::uno::Reference< css::script::XInvocation > mxWrapper
Definition: sbmod.hxx:63
SbiBreakpoints * pBreaks
Definition: sbmod.hxx:67
std::unique_ptr< SbClassData > pClassData
Definition: sbmod.hxx:68
bool isProxyModule() const
Definition: sbmod.hxx:130
const OUString & GetSource32() const
Definition: sbmod.hxx:107
OUString aOUSource
Definition: sbmod.hxx:64
SBX_DECL_PERSIST_NODATA(SBXID_BASICMOD, 2)
SbxObjectRef pDocObject
Definition: sbmod.hxx:72
bool IsVBASupport() const
Definition: sbmod.hxx:126
virtual bool LoadCompleted()
Definition: sbxbase.cxx:277
virtual void Clear() override
Definition: sbxobj.cxx:125
virtual SbxVariable * Find(const OUString &, SbxClassType)
Definition: sbxobj.cxx:182
SbxArrayRef pMethods
Definition: sbxobj.hxx:34
virtual bool LoadData(SvStream &, sal_uInt16) override
Definition: sbxobj.cxx:561
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: sbxobj.cxx:140
virtual std::pair< bool, sal_uInt32 > StoreData(SvStream &) const override
Definition: sbxobj.cxx:607
virtual void SetParent(SbxObject *)
Definition: sbxvar.cxx:355
UNOTOOLS_DLLPUBLIC css::uno::Any GetProperty(OUString const &url, OUString const &property)
QPRO_FUNC_TYPE nType
sal_Int32 mnType
#define SBXID_BASICMOD
Definition: sbdef.hxx:59
tools::SvRef< SbModule > SbModuleRef
Definition: sbmod.hxx:141
std::vector< SbModuleRef > SbModules
Definition: sbmod.hxx:142
std::deque< sal_uInt16 > SbiBreakpoints
Definition: sbmod.hxx:37
SbxDataType
Definition: sbxdef.hxx:37
SbxClassType
Definition: sbxdef.hxx:27
unsigned char sal_uInt8