update credits
[LibreOffice.git] / include / basic / sbx.hxx
blobd5fba159e51080c818f21d662640ce48fdaeba12
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 _SBXCLASS_HXX
21 #define _SBXCLASS_HXX
23 #include "tools/ref.hxx"
24 #include "svl/smplhint.hxx"
25 #include "svl/lstner.hxx"
27 #include <basic/sbxdef.hxx>
28 #include <basic/sbxform.hxx>
29 #include <basic/sbxobj.hxx>
30 #include <basic/sbxprop.hxx>
31 #include <basic/sbxmeth.hxx>
32 #include "basicdllapi.h"
34 #include <boost/ptr_container/ptr_vector.hpp>
36 class SvStream;
37 class SbxBase;
38 class SbxVariable;
39 class SbxProperty;
40 class SbxMethod;
41 class SbxObject;
42 class SbxArray;
43 class SbxDimArray;
44 class SbxFactory;
46 class SfxBroadcaster;
48 // Parameter information
49 struct SbxParamInfo
51 const OUString aName; // Name of the parameter
52 SbxBaseRef aTypeRef; // Object, if object type
53 SbxDataType eType; // Data type
54 sal_uInt16 nFlags; // Flag-Bits
55 sal_uInt32 nUserData; // IDs etc.
56 SbxParamInfo( const OUString& s, SbxDataType t, sal_uInt16 n, SbxBase* b = NULL )
57 : aName( s ), aTypeRef( b ), eType( t ), nFlags( n ), nUserData( 0 ) {}
58 ~SbxParamInfo() {}
61 typedef boost::ptr_vector<SbxParamInfo> SbxParams;
63 class BASIC_DLLPUBLIC SbxInfo : public SvRefBase
65 friend class SbxVariable;
66 friend class SbMethod;
68 OUString aComment;
69 OUString aHelpFile;
70 sal_uInt32 nHelpId;
71 SbxParams aParams;
73 protected:
74 sal_Bool LoadData( SvStream&, sal_uInt16 );
75 sal_Bool StoreData( SvStream& ) const;
76 virtual ~SbxInfo();
77 public:
78 SbxInfo();
79 SbxInfo( const OUString&, sal_uInt32 );
81 void AddParam( const OUString&, SbxDataType, sal_uInt16=SBX_READ );
82 const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
83 const OUString& GetComment() const { return aComment; }
84 const OUString& GetHelpFile() const { return aHelpFile; }
85 sal_uInt32 GetHelpId() const { return nHelpId; }
87 void SetComment( const OUString& r ) { aComment = r; }
88 void SetHelpFile( const OUString& r ) { aHelpFile = r; }
89 void SetHelpId( sal_uInt32 nId ) { nHelpId = nId; }
92 class BASIC_DLLPUBLIC SbxHint : public SfxSimpleHint
94 SbxVariable* pVar;
95 public:
96 TYPEINFO();
97 SbxHint( sal_uIntPtr n, SbxVariable* v ) : SfxSimpleHint( n ), pVar( v ) {}
98 SbxVariable* GetVar() const { return pVar; }
101 // SbxAlias is an alias for a var or object
102 class BASIC_DLLPUBLIC SbxAlias : public SbxVariable, public SfxListener
104 SbxVariableRef xAlias;
105 virtual ~SbxAlias();
106 virtual void Broadcast( sal_uIntPtr );
107 virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
108 const SfxHint& rHint, const TypeId& rHintType );
109 public:
110 SbxAlias( const SbxAlias& );
111 SbxAlias& operator=( const SbxAlias& );
114 // SbxArray is an unidimensional, dynamic Array
115 // The variables convert from SbxVariablen. Put()/Insert() into the
116 // declared datatype, if they are not SbxVARIANT.
118 class SbxVarRefs;
119 class SbxVariableRef;
121 class BASIC_DLLPUBLIC SbxArray : public SbxBase
123 // #100883 Method to set method directly to parameter array
124 friend class SbMethod;
125 friend class SbClassModuleObject;
126 friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
127 BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
129 SbxVarRefs* pData; // The variables
131 protected:
132 SbxDataType eType; // Data type of the array
133 virtual ~SbxArray();
134 virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
135 virtual sal_Bool StoreData( SvStream& ) const;
137 public:
138 SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_ARRAY,1);
139 TYPEINFO();
140 SbxArray( SbxDataType=SbxVARIANT );
141 SbxArray( const SbxArray& );
142 SbxArray& operator=( const SbxArray& );
143 virtual void Clear();
144 sal_uInt16 Count() const;
145 virtual SbxDataType GetType() const;
146 virtual SbxClassType GetClass() const;
147 SbxVariableRef& GetRef( sal_uInt16 );
148 SbxVariable* Get( sal_uInt16 );
149 void Put( SbxVariable*, sal_uInt16 );
150 void Insert( SbxVariable*, sal_uInt16 );
151 void Remove( sal_uInt16 );
152 void Remove( SbxVariable* );
153 void Merge( SbxArray* );
154 const OUString& GetAlias( sal_uInt16 );
155 void PutAlias( const OUString&, sal_uInt16 );
156 SbxVariable* FindUserData( sal_uInt32 nUserData );
157 virtual SbxVariable* Find( const OUString&, SbxClassType );
159 // Additional methods for 32-bit indices
160 sal_uInt32 Count32() const;
161 SbxVariableRef& GetRef32( sal_uInt32 );
162 SbxVariable* Get32( sal_uInt32 );
163 void Put32( SbxVariable*, sal_uInt32 );
164 void Insert32( SbxVariable*, sal_uInt32 );
165 void Remove32( sal_uInt32 );
168 // SbxDimArray is an array that can dimensioned using BASIC conventions.
169 struct SbxDim;
171 class BASIC_DLLPUBLIC SbxDimArray : public SbxArray
173 SbxDim* pFirst, *pLast; // Links to Dimension table
174 short nDim; // Number of dimensions
175 BASIC_DLLPRIVATE void AddDimImpl32( sal_Int32, sal_Int32, sal_Bool bAllowSize0 );
176 bool mbHasFixedSize;
177 protected:
178 sal_uInt16 Offset( const short* );
179 sal_uInt32 Offset32( const sal_Int32* );
180 sal_uInt32 Offset32( SbxArray* );
181 virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
182 virtual sal_Bool StoreData( SvStream& ) const;
183 virtual ~SbxDimArray();
184 public:
185 SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DIMARRAY,1);
186 TYPEINFO();
187 SbxDimArray( SbxDataType=SbxVARIANT );
188 SbxDimArray( const SbxDimArray& );
189 SbxDimArray& operator=( const SbxDimArray& );
190 virtual void Clear();
191 using SbxArray::GetRef;
192 using SbxArray::Get;
193 SbxVariable* Get( const short* );
194 using SbxArray::Put;
195 void Put( SbxVariable*, const short* );
196 SbxVariable* Get( SbxArray* );
198 short GetDims() const;
199 void AddDim( short, short );
200 void unoAddDim( short, short );
201 sal_Bool GetDim( short, short&, short& ) const;
203 using SbxArray::GetRef32;
204 using SbxArray::Get32;
205 SbxVariable* Get32( const sal_Int32* );
206 using SbxArray::Put32;
207 void Put32( SbxVariable*, const sal_Int32* );
208 void AddDim32( sal_Int32, sal_Int32 );
209 void unoAddDim32( sal_Int32, sal_Int32 );
210 sal_Bool GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
211 bool hasFixedSize() { return mbHasFixedSize; };
212 void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
215 class BASIC_DLLPUBLIC SbxCollection : public SbxObject
217 BASIC_DLLPRIVATE void Initialize();
218 protected:
219 virtual ~SbxCollection();
220 virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
221 virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
222 const SfxHint& rHint, const TypeId& rHintType );
223 // Overridable methods (why not pure virtual?):
224 virtual void CollAdd( SbxArray* pPar );
225 virtual void CollItem( SbxArray* pPar );
226 virtual void CollRemove( SbxArray* pPar );
228 public:
229 SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_COLLECTION,1);
230 TYPEINFO();
231 SbxCollection( const OUString& rClassname );
232 SbxCollection( const SbxCollection& );
233 SbxCollection& operator=( const SbxCollection& );
234 virtual SbxVariable* FindUserData( sal_uInt32 nUserData );
235 virtual SbxVariable* Find( const OUString&, SbxClassType );
236 virtual void Clear();
239 class BASIC_DLLPUBLIC SbxStdCollection : public SbxCollection
241 protected:
242 OUString aElemClass;
243 sal_Bool bAddRemoveOk;
244 virtual ~SbxStdCollection();
245 virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
246 virtual sal_Bool StoreData( SvStream& ) const;
247 virtual void CollAdd( SbxArray* pPar );
248 virtual void CollRemove( SbxArray* pPar );
249 public:
250 SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_FIXCOLLECTION,1);
251 TYPEINFO();
252 SbxStdCollection( const OUString& rClassname, const OUString& rElemClass, sal_Bool=sal_True );
253 SbxStdCollection( const SbxStdCollection& );
254 SbxStdCollection& operator=( const SbxStdCollection& );
255 virtual void Insert( SbxVariable* );
256 const OUString& GetElementClass() const { return aElemClass; }
259 SV_IMPL_REF(SbxBase)
261 SV_IMPL_REF(SbxVariable)
263 #ifndef SBX_ARRAY_DECL_DEFINED
264 #define SBX_ARRAY_DECL_DEFINED
265 SV_DECL_REF(SbxArray)
266 #endif
267 SV_IMPL_REF(SbxArray)
269 #ifndef SBX_INFO_DECL_DEFINED
270 #define SBX_INFO_DECL_DEFINED
271 SV_DECL_REF(SbxInfo)
272 #endif
273 SV_IMPL_REF(SbxInfo)
275 SV_DECL_REF(SbxDimArray)
276 SV_IMPL_REF(SbxDimArray)
278 #endif
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */