lok: initialize the load-language
[LibreOffice.git] / include / basic / sbstar.hxx
blob1629ab16c77494be3752e2faaaed0edb1dea58b2
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 final : 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 );
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 bool StoreData( SvStream& ) const override;
67 bool ErrorHdl();
68 BasicDebugFlags BreakHdl();
69 virtual ~StarBASIC() override;
71 public:
73 SBX_DECL_PERSIST_NODATA(SBXID_BASIC,1);
75 StarBASIC( StarBASIC* pParent = nullptr, bool bIsDocBasic = false );
77 // #51727 SetModified overridden so that the Modified-State is
78 // not delivered to Parent.
79 virtual void SetModified( bool ) override;
81 virtual void Insert( SbxVariable* ) override;
82 using SbxObject::Remove;
83 virtual void Remove( SbxVariable* ) override;
84 virtual void Clear() override;
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();
99 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
100 virtual bool Call( const OUString&, SbxArray* = nullptr ) override;
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();
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 );
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; }
125 static Link<StarBASIC*,bool> const & GetGlobalErrorHdl();
126 static void SetGlobalErrorHdl( const Link<StarBASIC*,bool>& rNewHdl );
128 static void SetGlobalBreakHdl( const Link<StarBASIC*,BasicDebugFlags>& rNewHdl );
130 SbxArrayRef const & getUnoListeners();
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;
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; };
145 SbxObject* getVBAGlobals( );
147 static css::uno::Reference< css::frame::XModel >
148 GetModelFromBasic( SbxObject* pBasic );
150 static void DetachAllDocBasicItems();
153 typedef tools::SvRef<StarBASIC> StarBASICRef;
155 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */