lok: initialize the load-language
[LibreOffice.git] / include / basic / sbmod.hxx
bloba71f7253a4517ec76b5e735dadb950347a2937fe
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_SBMOD_HXX
21 #define INCLUDED_BASIC_SBMOD_HXX
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>
34 namespace com::sun::star::script { class XInvocation; }
36 class SbMethod;
37 class SbProperty;
38 typedef std::deque< sal_uInt16 > SbiBreakpoints;
39 class SbiImage;
40 class SbClassModuleObject;
41 class CodeCompleteDataCache;
44 class ModuleInitDependencyMap;
45 struct ClassModuleRunInitItem;
46 struct SbClassData;
48 class BASIC_DLLPUBLIC SbModule : public SbxObject
50 friend class SbiCodeGen;
51 friend class SbMethod;
52 friend class SbiRuntime;
53 friend class StarBASIC;
54 friend class SbClassModuleObject;
56 std::vector< OUString > mModuleVariableNames;
58 BASIC_DLLPRIVATE static void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
60 SbModule(const SbModule&) = delete;
61 SbModule& operator=(const SbModule&) = delete;
62 protected:
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 mbVBACompat;
70 sal_Int32 mnType;
71 SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
72 bool bIsProxyModule;
74 SAL_DLLPRIVATE static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
75 SAL_DLLPRIVATE void StartDefinitions();
76 SAL_DLLPRIVATE SbMethod* GetMethod( const OUString&, SbxDataType );
77 SAL_DLLPRIVATE SbProperty* GetProperty( const OUString&, SbxDataType );
78 SAL_DLLPRIVATE void GetProcedureProperty( const OUString&, SbxDataType );
79 SAL_DLLPRIVATE void GetIfaceMapperMethod( const OUString&, SbMethod* );
80 SAL_DLLPRIVATE void EndDefinitions( bool=false );
81 SAL_DLLPRIVATE void Run( SbMethod* );
82 SAL_DLLPRIVATE void RunInit();
83 SAL_DLLPRIVATE void ClearPrivateVars();
84 SAL_DLLPRIVATE void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
85 SAL_DLLPRIVATE void GlobalRunInit( bool bBasicStart ); // for all modules
86 SAL_DLLPRIVATE void GlobalRunDeInit();
87 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
88 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
89 bool bFollowJumps, const SbiImage* pImg=nullptr ) const;
90 SAL_DLLPRIVATE virtual bool LoadData( SvStream&, sal_uInt16 ) override;
91 SAL_DLLPRIVATE virtual bool StoreData( SvStream& ) const override;
92 SAL_DLLPRIVATE virtual bool LoadCompleted() override;
93 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
94 SAL_DLLPRIVATE void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
95 virtual ~SbModule() override;
96 public:
97 SBX_DECL_PERSIST_NODATA(SBXID_BASICMOD,2);
98 SbModule( const OUString&, bool bCompat = false );
99 SAL_DLLPRIVATE virtual void SetParent( SbxObject* ) override;
100 SAL_DLLPRIVATE virtual void Clear() override;
102 SAL_DLLPRIVATE virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
104 const OUString& GetSource32() const { return aOUSource;}
105 void SetSource32( const OUString& r );
107 bool Compile();
108 bool IsCompiled() const;
109 SAL_DLLPRIVATE const SbxObject* FindType( const OUString& aTypeName ) const;
111 SAL_DLLPRIVATE bool IsBreakable( sal_uInt16 nLine ) const;
112 SAL_DLLPRIVATE bool IsBP( sal_uInt16 nLine ) const;
113 bool SetBP( sal_uInt16 nLine );
114 bool ClearBP( sal_uInt16 nLine );
115 void ClearAllBP();
117 // Store only image, no source (needed for new password protection)
118 SAL_DLLPRIVATE void StoreBinaryData( SvStream& );
119 SAL_DLLPRIVATE void LoadBinaryData( SvStream& );
120 SAL_DLLPRIVATE bool ExceedsLegacyModuleSize();
121 SAL_DLLPRIVATE void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = nullptr ) const;
122 SAL_DLLPRIVATE bool HasExeCode();
123 bool IsVBACompat() const { return mbVBACompat;}
124 SAL_DLLPRIVATE void SetVBACompat( bool bCompat );
125 sal_Int32 GetModuleType() const { return mnType; }
126 void SetModuleType( sal_Int32 nType ) { mnType = nType; }
127 bool isProxyModule() const { return bIsProxyModule; }
128 SAL_DLLPRIVATE void AddVarName( const OUString& aName );
129 SAL_DLLPRIVATE void RemoveVars();
130 css::uno::Reference< css::script::XInvocation > const & GetUnoModule();
131 bool createCOMWrapperForIface( css::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
132 void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
133 const SbxArrayRef& GetMethods() const { return pMethods;}
134 SbMethod* FindMethod( const OUString&, SbxClassType );
135 static OUString GetKeywordCase( const OUString& sKeyword );
138 typedef tools::SvRef<SbModule> SbModuleRef;
139 typedef std::vector<SbModuleRef> SbModules;
141 // Object class for instances of class modules
142 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbClassModuleObject final : public SbModule
144 SbModule* mpClassModule;
145 bool mbInitializeEventDone;
147 public:
148 SbClassModuleObject( SbModule* pClassModule );
149 virtual ~SbClassModuleObject() override;
151 // Overridden to support NameAccess etc.
152 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
154 virtual void Notify( SfxBroadcaster&, const SfxHint& rHint ) override;
156 SbModule* getClassModule()
157 { return mpClassModule; }
159 void triggerInitializeEvent();
160 void triggerTerminateEvent();
163 #endif
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */