xref: /AOO41X/main/basic/inc/basic/sbx.hxx (revision 234bd5c559aaf7abbd02d045859137b774cd8b34)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SBXCLASS_HXX
25 #define _SBXCLASS_HXX
26 
27 #include "tools/ref.hxx"
28 #include "svl/svarray.hxx"
29 #include "svl/smplhint.hxx"
30 #include "svl/lstner.hxx"
31 #include <basic/sbxdef.hxx>
32 #include <basic/sbxform.hxx>
33 
34 #ifndef __SBX_SBXOBJECT_HXX
35 #include <basic/sbxobj.hxx>
36 #endif
37 #include <basic/sbxprop.hxx>
38 #include <basic/sbxmeth.hxx>
39 
40 class BigInt;
41 class String;
42 class UniString;
43 class SvStream;
44 class SbxBase;
45 class SbxVariable;
46 class SbxProperty;
47 class SbxMethod;
48 class SbxObject;
49 class SbxArray;
50 class SbxDimArray;
51 class SbxFactory;
52 struct SbxINT64;
53 struct SbxUINT64;
54 
55 class SfxBroadcaster;
56 class SvDispatch;
57 
58 ///////////////////////////////////////////////////////////////////////////
59 
60 ////////////////////////////////////////////////////////////////////////////
61 
62 #ifndef __SBX_SBXPARAMINFO
63 #define __SBX_SBXPARAMINFO
64 
65 // Parameter information
66 struct SbxParamInfo
67 {
68     const String aName;          // Name of the parameter
69     SbxBaseRef   aTypeRef;       // Object, if object type
70     SbxDataType  eType;          // Data type
71     sal_uInt16       nFlags;         // Flag-Bits
72     sal_uInt32       nUserData;      // IDs etc.
SbxParamInfoSbxParamInfo73     SbxParamInfo( const String& s, SbxDataType t, sal_uInt16 n, SbxBase* b = NULL )
74     : aName( s ), aTypeRef( b ), eType( t ), nFlags( n ), nUserData( 0 ) {}
~SbxParamInfoSbxParamInfo75     ~SbxParamInfo() {}
76 };
77 
78 //#if 0 // _SOLAR__PRIVATE
79 SV_DECL_PTRARR_DEL(SbxParams,SbxParamInfo*,4,4)
80 //#else
81 //typedef SvPtrarr SbxParams;
82 //#endif
83 
84 #endif
85 
86 #ifndef __SBX_SBXINFO
87 #define __SBX_SBXINFO
88 
89 class SbxInfo : public SvRefBase
90 {
91     friend class SbxVariable;
92     friend class SbMethod;
93 
94     String          aComment;
95     String          aHelpFile;
96     sal_uInt32          nHelpId;
97     SbxParams       aParams;
98 
99 protected:
100     sal_Bool LoadData( SvStream&, sal_uInt16 );
101     sal_Bool StoreData( SvStream& ) const;
102     virtual ~SbxInfo();
103 public:
104     SbxInfo();
105     SbxInfo( const String&, sal_uInt32 );
106 
107     void                AddParam( const String&, SbxDataType, sal_uInt16=SBX_READ );
108     void                AddParam( const SbxParamInfo& );
109     const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
GetComment() const110     const String&       GetComment() const              { return aComment; }
GetHelpFile() const111     const String&       GetHelpFile() const             { return aHelpFile; }
GetHelpId() const112     sal_uInt32              GetHelpId() const               { return nHelpId;   }
113 
SetComment(const String & r)114     void                SetComment( const String& r )   { aComment = r; }
SetHelpFile(const String & r)115     void                SetHelpFile( const String& r )  { aHelpFile = r; }
SetHelpId(sal_uInt32 nId)116     void                SetHelpId( sal_uInt32 nId )         { nHelpId = nId; }
117 };
118 
119 #endif
120 
121 #ifndef __SBX_SBXHINT_HXX
122 #define __SBX_SBXHINT_HXX
123 
124 class SbxHint : public SfxSimpleHint
125 {
126     SbxVariable* pVar;
127 public:
128     TYPEINFO();
SbxHint(sal_uIntPtr n,SbxVariable * v)129     SbxHint( sal_uIntPtr n, SbxVariable* v ) : SfxSimpleHint( n ), pVar( v ) {}
GetVar() const130     SbxVariable* GetVar() const { return pVar; }
131 };
132 
133 #endif
134 
135 #ifndef __SBX_SBXALIAS_HXX
136 #define __SBX_SBXALIAS_HXX
137 
138 // SbxAlias is an alias for a var or object
139 class SbxAlias : public SbxVariable, public SfxListener
140 {
141     SbxVariableRef xAlias;
142     virtual ~SbxAlias();
143     virtual void Broadcast( sal_uIntPtr );
144     virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
145                              const SfxHint& rHint, const TypeId& rHintType );
146 public:
147     SbxAlias( const String& rName, SbxVariable* pOriginal );
148     SbxAlias( const SbxAlias& );
149     SbxAlias& operator=( const SbxAlias& );
150 };
151 
152 #endif
153 
154 #ifndef __SBX_SBXARRAY
155 #define __SBX_SBXARRAY
156 
157 // SbxArray ist ein eindimensionales, dynamisches Array
158 // von SbxVariablen. Put()/Insert() konvertieren die Variablen in den
159 // angegebenen Datentyp, falls er nicht SbxVARIANT ist.
160 
161 class SbxVarRefs;
162 class SbxVariableRef;
163 
164 class SbxArrayImpl;
165 
166 class SbxArray : public SbxBase
167 {
168 // #100883 Method to set method directly to parameter array
169     friend class SbMethod;
170     friend class SbClassModuleObject;
171     friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
172     void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
173 
174     SbxArrayImpl* mpSbxArrayImpl; // Impl data
175     SbxVarRefs*   pData;          // The variables
176 
177 protected:
178     SbxDataType eType;            // Data type of the array
179     virtual ~SbxArray();
180     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
181     virtual sal_Bool StoreData( SvStream& ) const;
182 
183 public:
184     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_ARRAY,1);
185     TYPEINFO();
186     SbxArray( SbxDataType=SbxVARIANT );
187     SbxArray( const SbxArray& );
188     SbxArray& operator=( const SbxArray& );
189     virtual void Clear();
190     sal_uInt16 Count() const;
191     virtual SbxDataType GetType() const;
192     virtual SbxClassType GetClass() const;
193     SbxVariableRef& GetRef( sal_uInt16 );
194     SbxVariable* Get( sal_uInt16 );
195     void Put( SbxVariable*, sal_uInt16 );
196     void Insert( SbxVariable*, sal_uInt16 );
197     void Remove( sal_uInt16 );
198     void Remove( SbxVariable* );
199     void Merge( SbxArray* );
200     const String& GetAlias( sal_uInt16 );
201     void PutAlias( const String&, sal_uInt16 );
202     SbxVariable* FindUserData( sal_uInt32 nUserData );
203     virtual SbxVariable* Find( const String&, SbxClassType );
204 
205     // Additional methods for 32-bit indices
206     sal_uInt32 Count32() const;
207     SbxVariableRef& GetRef32( sal_uInt32 );
208     SbxVariable* Get32( sal_uInt32 );
209     void Put32( SbxVariable*, sal_uInt32 );
210     void Insert32( SbxVariable*, sal_uInt32 );
211     void Remove32( sal_uInt32 );
212 };
213 
214 #endif
215 
216 #ifndef __SBX_SBXDIMARRAY_HXX
217 #define __SBX_SBXDIMARRAY_HXX
218 
219 // SbxDimArray is an array that can dimensioned using BASIC conventions.
220 struct SbxDim;
221 
222 class SbxDimArrayImpl;
223 
224 class SbxDimArray : public SbxArray
225 {
226     SbxDimArrayImpl* mpSbxDimArrayImpl;   // Impl data
227 
228     SbxDim* pFirst, *pLast;               // Links to Dimension table
229     short   nDim;                         // Number of dimensions
230     void   AddDimImpl32( sal_Int32, sal_Int32, sal_Bool bAllowSize0 );
231     bool mbHasFixedSize;
232 protected:
233     sal_uInt16  Offset( const short* );
234     sal_uInt32  Offset32( const sal_Int32* );
235     sal_uInt16  Offset( SbxArray* );
236     sal_uInt32  Offset32( SbxArray* );
237     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
238     virtual sal_Bool StoreData( SvStream& ) const;
239     virtual ~SbxDimArray();
240 public:
241     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DIMARRAY,1);
242     TYPEINFO();
243     SbxDimArray( SbxDataType=SbxVARIANT );
244     SbxDimArray( const SbxDimArray& );
245     SbxDimArray& operator=( const SbxDimArray& );
246     virtual void Clear();
247     using SbxArray::GetRef;
248     SbxVariableRef& GetRef( const short* );
249     using SbxArray::Get;
250     SbxVariable* Get( const short* );
251     using SbxArray::Put;
252     void Put( SbxVariable*, const short* );
253     SbxVariableRef& GetRef( SbxArray* );
254     SbxVariable* Get( SbxArray* );
255     void Put( SbxVariable*, SbxArray* );
256 
GetDims() const257     short  GetDims() const { return nDim;  }
258     void   AddDim( short, short );
259     void   unoAddDim( short, short );
260     sal_Bool   GetDim( short, short&, short& ) const;
261 
262     using SbxArray::GetRef32;
263     SbxVariableRef& GetRef32( const sal_Int32* );
264     using SbxArray::Get32;
265     SbxVariable* Get32( const sal_Int32* );
266     using SbxArray::Put32;
267     void Put32( SbxVariable*, const sal_Int32* );
268     void   AddDim32( sal_Int32, sal_Int32 );
269     void   unoAddDim32( sal_Int32, sal_Int32 );
270     sal_Bool   GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
hasFixedSize()271         bool hasFixedSize() { return mbHasFixedSize; };
setHasFixedSize(bool bHasFixedSize)272         void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
273 };
274 
275 #endif
276 
277 #ifndef __SBX_SBXCOLLECTION_HXX
278 #define __SBX_SBXCOLLECTION_HXX
279 
280 class SbxCollection : public SbxObject
281 {
282     void Initialize();
283 protected:
284     virtual ~SbxCollection();
285     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
286     virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
287                              const SfxHint& rHint, const TypeId& rHintType );
288     // Overridable methods (why not pure virtual?):
289     virtual void CollAdd( SbxArray* pPar );
290     virtual void CollItem( SbxArray* pPar );
291     virtual void CollRemove( SbxArray* pPar );
292 
293 public:
294     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_COLLECTION,1);
295     TYPEINFO();
296     SbxCollection( const String& rClassname );
297     SbxCollection( const SbxCollection& );
298     SbxCollection& operator=( const SbxCollection& );
299     virtual SbxVariable* FindUserData( sal_uInt32 nUserData );
300     virtual SbxVariable* Find( const String&, SbxClassType );
301     virtual void Clear();
302 };
303 
304 #endif
305 
306 #ifndef __SBX_SBXSTDCOLLECTION_HXX
307 #define __SBX_SBXSTDCOLLECTION_HXX
308 
309 class SbxStdCollection : public SbxCollection
310 {
311 protected:
312     String aElemClass;
313     sal_Bool   bAddRemoveOk;
314     virtual ~SbxStdCollection();
315     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
316     virtual sal_Bool StoreData( SvStream& ) const;
317     virtual void CollAdd( SbxArray* pPar );
318     virtual void CollRemove( SbxArray* pPar );
319 public:
320     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_FIXCOLLECTION,1);
321     TYPEINFO();
322     SbxStdCollection
323         ( const String& rClassname, const String& rElemClass, sal_Bool=sal_True );
324     SbxStdCollection( const SbxStdCollection& );
325     SbxStdCollection& operator=( const SbxStdCollection& );
326     virtual void Insert( SbxVariable* );
GetElementClass() const327     const String& GetElementClass() const { return aElemClass; }
328 };
329 
330 #endif
331 
332 #ifndef __SBX_SBXREFS_HXX
333 #define __SBX_SBXREFS_HXX
334 
335 SV_IMPL_REF(SbxBase)
336 
337 SV_IMPL_REF(SbxVariable)
338 
339 #ifndef SBX_ARRAY_DECL_DEFINED
340 #define SBX_ARRAY_DECL_DEFINED
341 SV_DECL_REF(SbxArray)
342 #endif
343 #ifndef SBX_ARRAY_IMPL_DEFINED
344 #define SBX_ARRAY_IMPL_DEFINED
345 SV_IMPL_REF(SbxArray)
346 #endif
347 
348 #ifndef SBX_INFO_DECL_DEFINED
349 #define SBX_INFO_DECL_DEFINED
350 SV_DECL_REF(SbxInfo)
351 #endif
352 #ifndef SBX_INFO_IMPL_DEFINED
353 #define SBX_INFO_IMPL_DEFINED
354 SV_IMPL_REF(SbxInfo)
355 #endif
356 
357 #ifndef SBX_DIMARRAY_DECL_DEFINED
358 #define SBX_DIMARRAY_DECL_DEFINED
359 SV_DECL_REF(SbxDimArray)
360 #endif
361 SV_IMPL_REF(SbxDimArray)
362 
363 #endif
364 
365 #endif
366