Bump version to 6.4-15
[LibreOffice.git] / include / basic / sbstar.hxx
blob7ff6a138123ef8857da5e3f3f09ae4b9e07ca559
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_SBSTAR_HXX
21 #define INCLUDED_BASIC_SBSTAR_HXX
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>
29 #include <basic/sbdef.hxx>
30 #include <basic/basicdllapi.h>
32 namespace com::sun::star::frame { class XModel; }
33 namespace com::sun::star::script { struct ModuleInfo; }
35 class SbMethod;
37 class BASIC_DLLPUBLIC StarBASIC : public SbxObject
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;
45 SbModules pModules; // List of all modules
46 SbxObjectRef pRtl; // Runtime Library
47 SbxArrayRef xUnoListeners; // Listener handled by CreateUnoListener
49 // Handler-Support:
50 Link<StarBASIC*,bool> aErrorHdl; // Error handler
51 Link<StarBASIC*,BasicDebugFlags> aBreakHdl; // Breakpoint handler
52 bool bNoRtl; // if true: do not search RTL
53 bool bBreak; // if true: Break, otherwise Step
54 bool bDocBasic;
55 bool bVBAEnabled;
56 bool bQuit;
58 SbxObjectRef pVBAGlobals;
60 BASIC_DLLPRIVATE void implClearDependingVarsOnDelete( StarBASIC* pDeletedBasic );
62 protected:
63 bool CError( ErrCode, const OUString&, sal_Int32, sal_Int32, sal_Int32 );
64 private:
65 BASIC_DLLPRIVATE bool RTError( ErrCode, const OUString& rMsg, sal_Int32, sal_Int32, sal_Int32 );
66 BASIC_DLLPRIVATE BasicDebugFlags BreakPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 );
67 BASIC_DLLPRIVATE BasicDebugFlags StepPoint( sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2 );
68 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
69 virtual bool StoreData( SvStream& ) const override;
71 protected:
72 bool ErrorHdl();
73 BasicDebugFlags BreakHdl();
74 virtual ~StarBASIC() override;
76 public:
78 SBX_DECL_PERSIST_NODATA(SBXID_BASIC,1);
80 StarBASIC( StarBASIC* pParent = nullptr, bool bIsDocBasic = false );
82 // #51727 SetModified overridden so that the Modified-State is
83 // not delivered to Parent.
84 virtual void SetModified( bool ) override;
86 virtual void Insert( SbxVariable* ) override;
87 using SbxObject::Remove;
88 virtual void Remove( SbxVariable* ) override;
89 virtual void Clear() override;
91 // Compiler-Interface
92 SbModule* MakeModule( const OUString& rName, const OUString& rSrc );
93 SbModule* MakeModule( const OUString& rName, const css::script::ModuleInfo& mInfo, const OUString& rSrc );
94 static void Stop();
95 static void Error( ErrCode );
96 static void Error( ErrCode, const OUString& rMsg );
97 static void FatalError( ErrCode );
98 static void FatalError( ErrCode, const OUString& rMsg );
99 static bool IsRunning();
100 static ErrCode GetErrBasic();
101 // #66536 make additional message accessible by RTL function Error
102 static OUString GetErrorMsg();
103 static sal_Int32 GetErl();
105 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
106 virtual bool Call( const OUString&, SbxArray* = nullptr ) override;
108 SbModules& GetModules() { return pModules; }
109 SbxObject* GetRtl() { return pRtl.get(); }
110 SbModule* FindModule( const OUString& );
111 // Run init code of all modules (including the inserted Doc-Basics)
112 void InitAllModules( StarBASIC const * pBasicNotToInit = nullptr );
113 void DeInitAllModules();
114 void ClearAllModuleVars();
116 // Calls for error and break handler
117 static sal_uInt16 GetLine();
118 static sal_uInt16 GetCol1();
119 static sal_uInt16 GetCol2();
120 static void SetErrorData( ErrCode nCode, sal_uInt16 nLine,
121 sal_uInt16 nCol1, sal_uInt16 nCol2 );
123 // Specific to error handler
124 static void MakeErrorText( ErrCode, const OUString& aMsg );
125 static const OUString& GetErrorText();
126 static ErrCode const & GetErrorCode();
127 static sal_uInt16 GetVBErrorCode( ErrCode nError );
128 static ErrCode GetSfxFromVBError( sal_uInt16 nError );
129 bool IsBreak() const { return bBreak; }
131 static Link<StarBASIC*,bool> const & GetGlobalErrorHdl();
132 static void SetGlobalErrorHdl( const Link<StarBASIC*,bool>& rNewHdl );
134 static void SetGlobalBreakHdl( const Link<StarBASIC*,BasicDebugFlags>& rNewHdl );
136 SbxArrayRef const & getUnoListeners();
138 static SbxBase* FindSBXInCurrentScope( const OUString& rName );
139 static SbMethod* GetActiveMethod( sal_uInt16 nLevel = 0 );
140 static SbModule* GetActiveModule();
141 void SetVBAEnabled( bool bEnabled );
142 bool isVBAEnabled() const;
144 const SbxObjectRef& getRTL() const { return pRtl; }
145 bool IsDocBasic() const { return bDocBasic; }
146 SbxVariable* VBAFind( const OUString& rName, SbxClassType t );
147 bool GetUNOConstant( const OUString& rName, css::uno::Any& aOut );
148 void QuitAndExitApplication();
149 bool IsQuitApplication() const { return bQuit; };
151 SbxObject* getVBAGlobals( );
153 static css::uno::Reference< css::frame::XModel >
154 GetModelFromBasic( SbxObject* pBasic );
156 static void DetachAllDocBasicItems();
159 typedef tools::SvRef<StarBASIC> StarBASICRef;
161 #endif
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */