nss: upgrade to release 3.73
[LibreOffice.git] / include / basic / sbx.hxx
blob0390d421c9d1eed0434d4604321ce92dc3262de7
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_SBX_HXX
21 #define INCLUDED_BASIC_SBX_HXX
23 #include <config_options.h>
24 #include <tools/ref.hxx>
25 #include <svl/hint.hxx>
27 #include <basic/sbxdef.hxx>
28 #include <basic/sbxobj.hxx>
29 #include <basic/basicdllapi.h>
31 #include <vector>
32 #include <memory>
34 class SvStream;
36 class SfxBroadcaster;
38 // Parameter information
39 struct SbxParamInfo
41 const OUString aName; // Name of the parameter
42 SbxDataType eType; // Data type
43 SbxFlagBits nFlags; // Flag-Bits
44 sal_uInt32 nUserData; // IDs etc.
45 SbxParamInfo( const OUString& s, SbxDataType t, SbxFlagBits n )
46 : aName( s ), eType( t ), nFlags( n ), nUserData( 0 ) {}
49 typedef std::vector<std::unique_ptr<SbxParamInfo>> SbxParams;
51 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) SbxInfo : public SvRefBase
53 friend class SbxVariable;
54 friend class SbMethod;
56 OUString aComment;
57 OUString aHelpFile;
58 sal_uInt32 nHelpId;
59 SbxParams m_Params;
61 SbxInfo(SbxInfo const&) = delete;
62 void operator=(SbxInfo const&) = delete;
64 protected:
65 void LoadData( SvStream&, sal_uInt16 );
66 void StoreData( SvStream& ) const;
67 virtual ~SbxInfo() override;
68 public:
69 SbxInfo();
70 SbxInfo( const OUString&, sal_uInt32 );
72 void AddParam( const OUString&, SbxDataType, SbxFlagBits=SbxFlagBits::Read );
73 const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
74 const OUString& GetComment() const { return aComment; }
75 const OUString& GetHelpFile() const { return aHelpFile; }
76 sal_uInt32 GetHelpId() const { return nHelpId; }
78 void SetComment( const OUString& r ) { aComment = r; }
81 class BASIC_DLLPUBLIC SbxHint final : public SfxHint
83 SbxVariable* pVar;
84 public:
85 SbxHint( SfxHintId n, SbxVariable* v ) : SfxHint( n ), pVar( v ) {}
86 SbxVariable* GetVar() const { return pVar; }
89 // SbxArray is an unidimensional, dynamic Array
90 // The variables convert from SbxVariablen. Put()/Insert() into the
91 // declared datatype, if they are not SbxVARIANT.
93 struct SbxVarEntry;
95 class BASIC_DLLPUBLIC SbxArray : public SbxBase
97 // #100883 Method to set method directly to parameter array
98 friend class SbMethod;
99 friend class SbClassModuleObject;
100 friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
101 BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
103 std::vector<SbxVarEntry> mVarEntries; // The variables
104 SbxDataType eType; // Data type of the array
106 protected:
107 virtual ~SbxArray() override;
108 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
109 virtual bool StoreData( SvStream& ) const override;
111 public:
112 SBX_DECL_PERSIST_NODATA(SBXID_ARRAY,1);
113 SbxArray( SbxDataType=SbxVARIANT );
114 SbxArray( const SbxArray& ) = delete;
115 SbxArray& operator=( const SbxArray& );
116 virtual void Clear() override;
117 sal_uInt32 Count32() const;
118 virtual SbxDataType GetType() const override;
119 SbxVariableRef& GetRef32( sal_uInt32 );
120 SbxVariable* Get32( sal_uInt32 );
121 void Put32( SbxVariable*, sal_uInt32 );
122 void Insert32( SbxVariable*, sal_uInt32 );
123 void Remove( sal_uInt32 );
124 void Remove( SbxVariable const * );
125 void Merge( SbxArray* );
126 OUString GetAlias32( sal_uInt32 );
127 void PutAlias32( const OUString&, sal_uInt32 );
128 SbxVariable* Find( const OUString&, SbxClassType );
131 // SbxDimArray is an array that can dimensioned using BASIC conventions.
132 struct SbxDim { // an array-dimension:
133 sal_Int32 nLbound, nUbound; // Limitations
134 sal_Int32 nSize; // Number of elements
137 class BASIC_DLLPUBLIC SbxDimArray final : public SbxArray
139 std::vector<SbxDim> m_vDimensions; // Dimension table
140 BASIC_DLLPRIVATE void AddDimImpl32( sal_Int32, sal_Int32, bool bAllowSize0 );
141 bool mbHasFixedSize;
143 sal_uInt32 Offset32( const sal_Int32* );
144 sal_uInt32 Offset32( SbxArray* );
145 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
146 virtual bool StoreData( SvStream& ) const override;
147 virtual ~SbxDimArray() override;
148 public:
149 SBX_DECL_PERSIST_NODATA(SBXID_DIMARRAY,1);
150 SbxDimArray( SbxDataType=SbxVARIANT );
151 SbxDimArray( const SbxDimArray& ) = delete;
152 SbxDimArray& operator=( const SbxDimArray& );
153 virtual void Clear() override;
154 SbxVariable* Get( SbxArray* );
156 using SbxArray::GetRef32;
157 using SbxArray::Get32;
158 SbxVariable* Get32( const sal_Int32* );
159 using SbxArray::Put32;
160 void Put32( SbxVariable*, const sal_Int32* );
161 sal_Int32 GetDims32() const { return m_vDimensions.size(); }
162 void AddDim32( sal_Int32, sal_Int32 );
163 void unoAddDim32( sal_Int32, sal_Int32 );
164 bool GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
165 bool hasFixedSize() const { return mbHasFixedSize; };
166 void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
169 class SbxCollection : public SbxObject
171 void Initialize();
172 protected:
173 virtual ~SbxCollection() override;
174 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
175 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
176 // Overridable methods (why not pure virtual?):
177 virtual void CollAdd( SbxArray* pPar );
178 void CollItem( SbxArray* pPar );
179 virtual void CollRemove( SbxArray* pPar );
181 public:
182 SBX_DECL_PERSIST_NODATA(SBXID_COLLECTION,1);
183 SbxCollection();
184 SbxCollection( const SbxCollection& );
185 SbxCollection& operator=( const SbxCollection& );
186 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
187 virtual void Clear() override;
190 class SbxStdCollection final : public SbxCollection
192 OUString aElemClass;
193 bool bAddRemoveOk;
194 virtual ~SbxStdCollection() override;
195 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
196 virtual bool StoreData( SvStream& ) const override;
197 virtual void CollAdd( SbxArray* pPar ) override;
198 virtual void CollRemove( SbxArray* pPar ) override;
199 public:
200 SBX_DECL_PERSIST_NODATA(SBXID_FIXCOLLECTION,1);
201 SbxStdCollection();
202 SbxStdCollection( const SbxStdCollection& );
203 SbxStdCollection& operator=( const SbxStdCollection& );
204 virtual void Insert( SbxVariable* ) override;
207 typedef tools::SvRef<SbxArray> SbxArrayRef;
208 typedef tools::SvRef<SbxInfo> SbxInfoRef;
209 typedef tools::SvRef<SbxDimArray> SbxDimArrayRef;
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */