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