Bump version to 6.4-15
[LibreOffice.git] / include / basic / sbx.hxx
blob2cdf241170015d1907896de620d62c5125ecdd5a
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 <tools/ref.hxx>
24 #include <svl/hint.hxx>
26 #include <basic/sbxdef.hxx>
27 #include <basic/sbxobj.hxx>
28 #include <basic/basicdllapi.h>
30 #include <vector>
31 #include <memory>
33 class SvStream;
35 class SfxBroadcaster;
37 // Parameter information
38 struct SbxParamInfo
40 const OUString aName; // Name of the parameter
41 SbxDataType eType; // Data type
42 SbxFlagBits nFlags; // Flag-Bits
43 sal_uInt32 nUserData; // IDs etc.
44 SbxParamInfo( const OUString& s, SbxDataType t, SbxFlagBits n )
45 : aName( s ), eType( t ), nFlags( n ), nUserData( 0 ) {}
48 typedef std::vector<std::unique_ptr<SbxParamInfo>> SbxParams;
50 class BASIC_DLLPUBLIC SbxInfo : public SvRefBase
52 friend class SbxVariable;
53 friend class SbMethod;
55 OUString aComment;
56 OUString aHelpFile;
57 sal_uInt32 nHelpId;
58 SbxParams m_Params;
60 SbxInfo(SbxInfo const&) = delete;
61 void operator=(SbxInfo const&) = delete;
63 protected:
64 void LoadData( SvStream&, sal_uInt16 );
65 void StoreData( SvStream& ) const;
66 virtual ~SbxInfo() override;
67 public:
68 SbxInfo();
69 SbxInfo( const OUString&, sal_uInt32 );
71 void AddParam( const OUString&, SbxDataType, SbxFlagBits=SbxFlagBits::Read );
72 const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
73 const OUString& GetComment() const { return aComment; }
74 const OUString& GetHelpFile() const { return aHelpFile; }
75 sal_uInt32 GetHelpId() const { return nHelpId; }
77 void SetComment( const OUString& r ) { aComment = r; }
80 class BASIC_DLLPUBLIC SbxHint final : public SfxHint
82 SbxVariable* pVar;
83 public:
84 SbxHint( SfxHintId n, SbxVariable* v ) : SfxHint( n ), pVar( v ) {}
85 SbxVariable* GetVar() const { return pVar; }
88 // SbxArray is an unidimensional, dynamic Array
89 // The variables convert from SbxVariablen. Put()/Insert() into the
90 // declared datatype, if they are not SbxVARIANT.
92 struct SbxVarEntry;
94 class BASIC_DLLPUBLIC SbxArray : public SbxBase
96 // #100883 Method to set method directly to parameter array
97 friend class SbMethod;
98 friend class SbClassModuleObject;
99 friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
100 BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
102 std::vector<SbxVarEntry> mVarEntries; // The variables
103 SbxDataType eType; // Data type of the array
105 protected:
106 virtual ~SbxArray() override;
107 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
108 virtual bool StoreData( SvStream& ) const override;
110 public:
111 SBX_DECL_PERSIST_NODATA(SBXID_ARRAY,1);
112 SbxArray( SbxDataType=SbxVARIANT );
113 SbxArray( const SbxArray& ) = delete;
114 SbxArray& operator=( const SbxArray& );
115 virtual void Clear() override;
116 sal_uInt16 Count() const;
117 virtual SbxDataType GetType() const override;
118 SbxVariableRef& GetRef( sal_uInt16 );
119 SbxVariable* Get( sal_uInt16 );
120 void Put( SbxVariable*, sal_uInt16 );
121 void Insert( SbxVariable*, sal_uInt16 );
122 void Remove( SbxVariable const * );
123 void Merge( SbxArray* );
124 OUString GetAlias( sal_uInt16 );
125 void PutAlias( const OUString&, sal_uInt16 );
126 SbxVariable* Find( const OUString&, SbxClassType );
128 // Additional methods for 32-bit indices
129 sal_uInt32 Count32() const;
130 SbxVariableRef& GetRef32( sal_uInt32 );
131 SbxVariable* Get32( sal_uInt32 );
132 void Put32( SbxVariable*, sal_uInt32 );
133 void Insert32( SbxVariable*, sal_uInt32 );
134 void Remove( sal_uInt32 );
137 // SbxDimArray is an array that can dimensioned using BASIC conventions.
138 struct SbxDim { // an array-dimension:
139 sal_Int32 nLbound, nUbound; // Limitations
140 sal_Int32 nSize; // Number of elements
143 class BASIC_DLLPUBLIC SbxDimArray final : public SbxArray
145 std::vector<SbxDim> m_vDimensions; // Dimension table
146 BASIC_DLLPRIVATE void AddDimImpl32( sal_Int32, sal_Int32, bool bAllowSize0 );
147 bool mbHasFixedSize;
149 sal_uInt16 Offset( const short* );
150 sal_uInt32 Offset32( const sal_Int32* );
151 sal_uInt32 Offset32( SbxArray* );
152 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
153 virtual bool StoreData( SvStream& ) const override;
154 virtual ~SbxDimArray() override;
155 public:
156 SBX_DECL_PERSIST_NODATA(SBXID_DIMARRAY,1);
157 SbxDimArray( SbxDataType=SbxVARIANT );
158 SbxDimArray( const SbxDimArray& ) = delete;
159 SbxDimArray& operator=( const SbxDimArray& );
160 virtual void Clear() override;
161 using SbxArray::GetRef;
162 using SbxArray::Get;
163 SbxVariable* Get( const short* );
164 using SbxArray::Put;
165 void Put( SbxVariable*, const short* );
166 SbxVariable* Get( SbxArray* );
168 short GetDims() const { return m_vDimensions.size();}
169 void AddDim( short, short );
170 void unoAddDim( short, short );
171 bool GetDim( short, short&, short& ) const;
173 using SbxArray::GetRef32;
174 using SbxArray::Get32;
175 SbxVariable* Get32( const sal_Int32* );
176 using SbxArray::Put32;
177 void Put32( SbxVariable*, const sal_Int32* );
178 void AddDim32( sal_Int32, sal_Int32 );
179 void unoAddDim32( sal_Int32, sal_Int32 );
180 bool GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
181 bool hasFixedSize() const { return mbHasFixedSize; };
182 void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
185 class SbxCollection : public SbxObject
187 void Initialize();
188 protected:
189 virtual ~SbxCollection() override;
190 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
191 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
192 // Overridable methods (why not pure virtual?):
193 virtual void CollAdd( SbxArray* pPar );
194 void CollItem( SbxArray* pPar );
195 virtual void CollRemove( SbxArray* pPar );
197 public:
198 SBX_DECL_PERSIST_NODATA(SBXID_COLLECTION,1);
199 SbxCollection();
200 SbxCollection( const SbxCollection& );
201 SbxCollection& operator=( const SbxCollection& );
202 virtual SbxVariable* Find( const OUString&, SbxClassType ) override;
203 virtual void Clear() override;
206 class SbxStdCollection final : public SbxCollection
208 OUString aElemClass;
209 bool bAddRemoveOk;
210 virtual ~SbxStdCollection() override;
211 virtual bool LoadData( SvStream&, sal_uInt16 ) override;
212 virtual bool StoreData( SvStream& ) const override;
213 virtual void CollAdd( SbxArray* pPar ) override;
214 virtual void CollRemove( SbxArray* pPar ) override;
215 public:
216 SBX_DECL_PERSIST_NODATA(SBXID_FIXCOLLECTION,1);
217 SbxStdCollection();
218 SbxStdCollection( const SbxStdCollection& );
219 SbxStdCollection& operator=( const SbxStdCollection& );
220 virtual void Insert( SbxVariable* ) override;
223 typedef tools::SvRef<SbxArray> SbxArrayRef;
224 typedef tools::SvRef<SbxInfo> SbxInfoRef;
225 typedef tools::SvRef<SbxDimArray> SbxDimArrayRef;
227 #endif
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */