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