/src/libreoffice/include/basic/sbstar.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <basic/sbx.hxx> |
23 | | #include <basic/sbxobj.hxx> |
24 | | #include <basic/sbmod.hxx> |
25 | | #include <rtl/ustring.hxx> |
26 | | #include <tools/link.hxx> |
27 | | |
28 | | #include <basic/sbdef.hxx> |
29 | | #include <basic/basicdllapi.h> |
30 | | |
31 | | namespace com::sun::star::frame { class XModel; } |
32 | | namespace com::sun::star::script { struct ModuleInfo; } |
33 | | |
34 | | class ErrCode; |
35 | | class ErrCodeMsg; |
36 | | class SbMethod; |
37 | | |
38 | | class BASIC_DLLPUBLIC StarBASIC final : public SbxObject |
39 | | { |
40 | | friend class SbiScanner; |
41 | | friend class SbiExpression; // Access to RTL |
42 | | friend class SbiInstance; // runtime instance |
43 | | friend class SbiRuntime; // currently running procedure |
44 | | friend class DocBasicItem; |
45 | | |
46 | | SbModules pModules; // List of all modules |
47 | | SbxObjectRef pRtl; // Runtime Library |
48 | | SbxArrayRef xUnoListeners; // Listener handled by CreateUnoListener |
49 | | |
50 | | // Handler-Support: |
51 | | Link<StarBASIC*,bool> aErrorHdl; // Error handler |
52 | | Link<StarBASIC*,BasicDebugFlags> aBreakHdl; // Breakpoint handler |
53 | | bool bNoRtl; // if true: do not search RTL |
54 | | bool bBreak; // if true: Break, otherwise Step |
55 | | bool bDocBasic; |
56 | | bool bVBAEnabled; |
57 | | bool bQuit; |
58 | | |
59 | | SbxObjectRef pVBAGlobals; |
60 | | |
61 | | BASIC_DLLPRIVATE void implClearDependingVarsOnDelete( StarBASIC* pDeletedBasic ); |
62 | | bool CError( ErrCode, const OUString&, sal_Int32, sal_Int32, sal_Int32 ); |
63 | | BASIC_DLLPRIVATE bool RTError( ErrCode, const OUString& rMsg, sal_Int32, sal_Int32, sal_Int32 ); |
64 | | BASIC_DLLPRIVATE BasicDebugFlags BreakPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 ); |
65 | | BASIC_DLLPRIVATE BasicDebugFlags StepPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 ); |
66 | | virtual bool LoadData( SvStream&, sal_uInt16 ) override; |
67 | | virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const override; |
68 | | bool ErrorHdl(); |
69 | | BasicDebugFlags BreakHdl(); |
70 | | virtual ~StarBASIC() override; |
71 | | |
72 | | public: |
73 | | |
74 | | SBX_DECL_PERSIST_NODATA(SBXID_BASIC,1); |
75 | | |
76 | | StarBASIC( StarBASIC* pParent = nullptr, bool bIsDocBasic = false ); |
77 | | |
78 | | // #51727 SetModified overridden so that the Modified-State is |
79 | | // not delivered to Parent. |
80 | | virtual void SetModified( bool ) override; |
81 | | |
82 | | virtual void Insert( SbxVariable* ) override; |
83 | | using SbxObject::Remove; |
84 | | virtual void Remove( SbxVariable* ) override; |
85 | | virtual void Clear() override; |
86 | | |
87 | | // Compiler-Interface |
88 | | SbModule* MakeModule( const OUString& rName, const OUString& rSrc ); |
89 | | SbModule* MakeModule( const OUString& rName, const css::script::ModuleInfo& mInfo, const OUString& rSrc ); |
90 | | static void Stop(); |
91 | | static void Error( ErrCode, const OUString& rMsg = {} ); |
92 | | static void FatalError( ErrCode ); |
93 | | static void FatalError( ErrCode, const OUString& rMsg ); |
94 | | static bool IsRunning(); |
95 | | static ErrCode GetErrBasic(); |
96 | | // #66536 make additional message accessible by RTL function Error |
97 | | static const OUString & GetErrorMsg(); |
98 | | static sal_Int32 GetErl(); |
99 | | |
100 | | virtual SbxVariable* Find( const OUString&, SbxClassType ) override; |
101 | | virtual bool Call( const OUString&, SbxArray* = nullptr ) override; |
102 | | |
103 | 0 | SbModules& GetModules() { return pModules; } |
104 | 0 | SbxObject* GetRtl() { return pRtl.get(); } |
105 | | SbModule* FindModule( std::u16string_view ); |
106 | | // Run init code of all modules (including the inserted Doc-Basics) |
107 | | void InitAllModules( StarBASIC const * pBasicNotToInit = nullptr ); |
108 | | void DeInitAllModules(); |
109 | | void ClearAllModuleVars(); |
110 | | |
111 | | // Calls for error and break handler |
112 | | static sal_uInt16 GetLine(); |
113 | | static sal_uInt16 GetCol1(); |
114 | | static sal_uInt16 GetCol2(); |
115 | | static void SetErrorData( const ErrCodeMsg& nCode, sal_uInt16 nLine, |
116 | | sal_uInt16 nCol1, sal_uInt16 nCol2 ); |
117 | | |
118 | | // Specific to error handler |
119 | | static void MakeErrorText( ErrCode, std::u16string_view aMsg ); |
120 | | static const OUString& GetErrorText(); |
121 | | static ErrCodeMsg const & GetErrorCode(); |
122 | | static sal_uInt16 GetVBErrorCode( ErrCode nError ); |
123 | | static ErrCode GetSfxFromVBError( sal_uInt16 nError ); |
124 | 0 | bool IsBreak() const { return bBreak; } |
125 | | |
126 | | static Link<StarBASIC*,bool> const & GetGlobalErrorHdl(); |
127 | | static void SetGlobalErrorHdl( const Link<StarBASIC*,bool>& rNewHdl ); |
128 | | |
129 | | static void SetGlobalBreakHdl( const Link<StarBASIC*,BasicDebugFlags>& rNewHdl ); |
130 | | |
131 | | SbxArrayRef const & getUnoListeners(); |
132 | | |
133 | | static SbxBase* FindSBXInCurrentScope( const OUString& rName ); |
134 | | static SbMethod* GetActiveMethod( sal_uInt16 nLevel = 0 ); |
135 | | static SbModule* GetActiveModule(); |
136 | | void SetVBAEnabled( bool bEnabled ); |
137 | | bool isVBAEnabled() const; |
138 | | |
139 | 0 | const SbxObjectRef& getRTL() const { return pRtl; } |
140 | 0 | bool IsDocBasic() const { return bDocBasic; } |
141 | | SbxVariable* VBAFind( const OUString& rName, SbxClassType t ); |
142 | | bool GetUNOConstant( const OUString& rName, css::uno::Any& aOut ); |
143 | | void QuitAndExitApplication(); |
144 | 0 | bool IsQuitApplication() const { return bQuit; }; |
145 | | |
146 | | SbxObject* getVBAGlobals( ); |
147 | | |
148 | | static css::uno::Reference< css::frame::XModel > |
149 | | GetModelFromBasic( SbxObject* pBasic ); |
150 | | |
151 | | static void DetachAllDocBasicItems(); |
152 | | }; |
153 | | |
154 | | typedef tools::SvRef<StarBASIC> StarBASICRef; |
155 | | |
156 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |