Handle pasting disallowed clipboard contents on iOS
[LibreOffice.git] / include / basic / sbmod.hxx
blob7ca52276d01234a592b59e8b292e748e5dd8c695
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 mbVBASupport; // Option VBASupport
70 bool mbCompat; // Option Compatible
71 sal_Int32 mnType;
72 SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
73 bool bIsProxyModule;
75 SAL_DLLPRIVATE static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
76 SAL_DLLPRIVATE void StartDefinitions();
77 SAL_DLLPRIVATE SbMethod* GetMethod( const OUString&, SbxDataType );
78 SAL_DLLPRIVATE SbProperty* GetProperty( const OUString&, SbxDataType );
79 SAL_DLLPRIVATE void GetProcedureProperty( const OUString&, SbxDataType );
80 SAL_DLLPRIVATE void GetIfaceMapperMethod( const OUString&, SbMethod* );
81 SAL_DLLPRIVATE void EndDefinitions( bool=false );
82 SAL_DLLPRIVATE void Run( SbMethod* );
83 SAL_DLLPRIVATE void RunInit();
84 SAL_DLLPRIVATE void ClearPrivateVars();
85 SAL_DLLPRIVATE void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
86 SAL_DLLPRIVATE void GlobalRunInit( bool bBasicStart ); // for all modules
87 SAL_DLLPRIVATE void GlobalRunDeInit();
88 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
89 SAL_DLLPRIVATE const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
90 bool bFollowJumps, const SbiImage* pImg=nullptr ) const;
91 SAL_DLLPRIVATE virtual bool LoadData( SvStream&, sal_uInt16 ) override;
92 SAL_DLLPRIVATE virtual bool StoreData( SvStream& ) const override;
93 SAL_DLLPRIVATE virtual bool LoadCompleted() override;
94 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
95 SAL_DLLPRIVATE void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
96 virtual ~SbModule() override;
97 bool IsOptionCompatible() const override { return mbCompat; }
99 public:
100 SBX_DECL_PERSIST_NODATA(SBXID_BASICMOD,2);
101 SbModule( const OUString&, bool bVBASupport = false );
102 SAL_DLLPRIVATE virtual void SetParent( SbxObject* ) override;
103 SAL_DLLPRIVATE virtual void Clear() override;
105 SAL_DLLPRIVATE virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
107 const OUString& GetSource32() const { return aOUSource;}
108 void SetSource32( const OUString& r );
110 bool Compile();
111 bool IsCompiled() const;
112 SAL_DLLPRIVATE const SbxObject* FindType( const OUString& aTypeName ) const;
114 SAL_DLLPRIVATE bool IsBreakable( sal_uInt16 nLine ) const;
115 SAL_DLLPRIVATE bool IsBP( sal_uInt16 nLine ) const;
116 bool SetBP( sal_uInt16 nLine );
117 bool ClearBP( sal_uInt16 nLine );
118 void ClearAllBP();
120 // Store only image, no source (needed for new password protection)
121 SAL_DLLPRIVATE void StoreBinaryData( SvStream& );
122 SAL_DLLPRIVATE void LoadBinaryData( SvStream& );
123 SAL_DLLPRIVATE bool ExceedsLegacyModuleSize();
124 SAL_DLLPRIVATE void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = nullptr ) const;
125 SAL_DLLPRIVATE bool HasExeCode();
126 bool IsVBASupport() const { return mbVBASupport; }
127 SAL_DLLPRIVATE void SetVBASupport( bool bSupport );
128 sal_Int32 GetModuleType() const { return mnType; }
129 void SetModuleType( sal_Int32 nType ) { mnType = nType; }
130 bool isProxyModule() const { return bIsProxyModule; }
131 SAL_DLLPRIVATE void AddVarName( const OUString& aName );
132 SAL_DLLPRIVATE void RemoveVars();
133 css::uno::Reference< css::script::XInvocation > const & GetUnoModule();
134 bool createCOMWrapperForIface( css::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
135 void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
136 const SbxArrayRef& GetMethods() const { return pMethods;}
137 SbMethod* FindMethod( const OUString&, SbxClassType );
138 static OUString GetKeywordCase( const OUString& sKeyword );
141 typedef tools::SvRef<SbModule> SbModuleRef;
142 typedef std::vector<SbModuleRef> SbModules;
144 // Object class for instances of class modules
145 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbClassModuleObject final : public SbModule
147 SbModule* mpClassModule;
148 bool mbInitializeEventDone;
150 public:
151 SbClassModuleObject( SbModule* pClassModule );
152 virtual ~SbClassModuleObject() override;
154 // Overridden to support NameAccess etc.
155 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
157 virtual void Notify( SfxBroadcaster&, const SfxHint& rHint ) override;
159 SbModule* getClassModule()
160 { return mpClassModule; }
162 void triggerInitializeEvent();
163 void triggerTerminateEvent();
166 #endif
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */