1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/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 <basic/basicdllapi.h>
34 #include <boost/ptr_container/ptr_vector.hpp>
49 // Parameter information
52 const OUString aName
; // Name of the parameter
53 SbxBaseRef aTypeRef
; // Object, if object type
54 SbxDataType eType
; // Data type
55 SbxFlagBits nFlags
; // Flag-Bits
56 sal_uInt32 nUserData
; // IDs etc.
57 SbxParamInfo( const OUString
& s
, SbxDataType t
, SbxFlagBits n
, SbxBase
* b
= NULL
)
58 : aName( s
), aTypeRef( b
), eType( t
), nFlags( n
), nUserData( 0 ) {}
62 typedef boost::ptr_vector
<SbxParamInfo
> SbxParams
;
64 class BASIC_DLLPUBLIC SbxInfo
: public SvRefBase
66 friend class SbxVariable
;
67 friend class SbMethod
;
75 bool LoadData( SvStream
&, sal_uInt16
);
76 bool StoreData( SvStream
& ) const;
80 SbxInfo( const OUString
&, sal_uInt32
);
82 void AddParam( const OUString
&, SbxDataType
, SbxFlagBits
=SBX_READ
);
83 const SbxParamInfo
* GetParam( sal_uInt16 n
) const; // index starts with 1!
84 const OUString
& GetComment() const { return aComment
; }
85 const OUString
& GetHelpFile() const { return aHelpFile
; }
86 sal_uInt32
GetHelpId() const { return nHelpId
; }
88 void SetComment( const OUString
& r
) { aComment
= r
; }
89 void SetHelpFile( const OUString
& r
) { aHelpFile
= r
; }
90 void SetHelpId( sal_uInt32 nId
) { nHelpId
= nId
; }
93 class BASIC_DLLPUBLIC SbxHint
: public SfxSimpleHint
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
;
106 virtual void Broadcast( sal_uIntPtr
) SAL_OVERRIDE
;
107 virtual void SFX_NOTIFY( SfxBroadcaster
& rBC
, const TypeId
& rBCType
,
108 const SfxHint
& rHint
, const TypeId
& rHintType
) SAL_OVERRIDE
;
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.
120 class BASIC_DLLPUBLIC SbxArray
: public SbxBase
122 typedef std::vector
<SbxVarEntry
*> VarEntriesType
;
124 // #100883 Method to set method directly to parameter array
125 friend class SbMethod
;
126 friend class SbClassModuleObject
;
127 friend SbxObject
* cloneTypeObjectImpl( const SbxObject
& rTypeObj
);
128 BASIC_DLLPRIVATE
void PutDirect( SbxVariable
* pVar
, sal_uInt32 nIdx
);
130 VarEntriesType
* mpVarEntries
; // The variables
133 SbxDataType eType
; // Data type of the array
135 virtual bool LoadData( SvStream
&, sal_uInt16
) SAL_OVERRIDE
;
136 virtual bool StoreData( SvStream
& ) const SAL_OVERRIDE
;
139 SBX_DECL_PERSIST_NODATA(SBXCR_SBX
,SBXID_ARRAY
,1);
141 SbxArray( SbxDataType
=SbxVARIANT
);
142 SbxArray( const SbxArray
& );
143 SbxArray
& operator=( const SbxArray
& );
144 virtual void Clear() SAL_OVERRIDE
;
145 sal_uInt16
Count() const;
146 virtual SbxDataType
GetType() const SAL_OVERRIDE
;
147 virtual SbxClassType
GetClass() const SAL_OVERRIDE
;
148 SbxVariableRef
& GetRef( sal_uInt16
);
149 SbxVariable
* Get( sal_uInt16
);
150 void Put( SbxVariable
*, sal_uInt16
);
151 void Insert( SbxVariable
*, sal_uInt16
);
152 void Remove( sal_uInt16
);
153 void Remove( SbxVariable
* );
154 void Merge( SbxArray
* );
155 OUString
GetAlias( sal_uInt16
);
156 void PutAlias( const OUString
&, sal_uInt16
);
157 SbxVariable
* FindUserData( sal_uInt32 nUserData
);
158 SbxVariable
* Find( const OUString
&, SbxClassType
);
160 // Additional methods for 32-bit indices
161 sal_uInt32
Count32() const;
162 SbxVariableRef
& GetRef32( sal_uInt32
);
163 SbxVariable
* Get32( sal_uInt32
);
164 void Put32( SbxVariable
*, sal_uInt32
);
165 void Insert32( SbxVariable
*, sal_uInt32
);
166 void Remove32( sal_uInt32
);
169 // SbxDimArray is an array that can dimensioned using BASIC conventions.
170 struct SbxDim
{ // an array-dimension:
171 sal_Int32 nLbound
, nUbound
; // Limitations
172 sal_Int32 nSize
; // Number of elements
175 class BASIC_DLLPUBLIC SbxDimArray
: public SbxArray
177 std::vector
<SbxDim
> m_vDimensions
; // Dimension table
178 BASIC_DLLPRIVATE
void AddDimImpl32( sal_Int32
, sal_Int32
, bool bAllowSize0
);
181 sal_uInt16
Offset( const short* );
182 sal_uInt32
Offset32( const sal_Int32
* );
183 sal_uInt32
Offset32( SbxArray
* );
184 virtual bool LoadData( SvStream
&, sal_uInt16
) SAL_OVERRIDE
;
185 virtual bool StoreData( SvStream
& ) const SAL_OVERRIDE
;
186 virtual ~SbxDimArray();
188 SBX_DECL_PERSIST_NODATA(SBXCR_SBX
,SBXID_DIMARRAY
,1);
190 SbxDimArray( SbxDataType
=SbxVARIANT
);
191 SbxDimArray( const SbxDimArray
& );
192 SbxDimArray
& operator=( const SbxDimArray
& );
193 virtual void Clear() SAL_OVERRIDE
;
194 using SbxArray::GetRef
;
196 SbxVariable
* Get( const short* );
198 void Put( SbxVariable
*, const short* );
199 SbxVariable
* Get( SbxArray
* );
201 short GetDims() const { return m_vDimensions
.size();}
202 void AddDim( short, short );
203 void unoAddDim( short, short );
204 bool GetDim( short, short&, short& ) const;
206 using SbxArray::GetRef32
;
207 using SbxArray::Get32
;
208 SbxVariable
* Get32( const sal_Int32
* );
209 using SbxArray::Put32
;
210 void Put32( SbxVariable
*, const sal_Int32
* );
211 void AddDim32( sal_Int32
, sal_Int32
);
212 void unoAddDim32( sal_Int32
, sal_Int32
);
213 bool GetDim32( sal_Int32
, sal_Int32
&, sal_Int32
& ) const;
214 bool hasFixedSize() { return mbHasFixedSize
; };
215 void setHasFixedSize( bool bHasFixedSize
) {mbHasFixedSize
= bHasFixedSize
; };
218 class BASIC_DLLPUBLIC SbxCollection
: public SbxObject
220 BASIC_DLLPRIVATE
void Initialize();
222 virtual ~SbxCollection();
223 virtual bool LoadData( SvStream
&, sal_uInt16
) SAL_OVERRIDE
;
224 virtual void SFX_NOTIFY( SfxBroadcaster
& rBC
, const TypeId
& rBCType
,
225 const SfxHint
& rHint
, const TypeId
& rHintType
) SAL_OVERRIDE
;
226 // Overridable methods (why not pure virtual?):
227 virtual void CollAdd( SbxArray
* pPar
);
228 void CollItem( SbxArray
* pPar
);
229 virtual void CollRemove( SbxArray
* pPar
);
232 SBX_DECL_PERSIST_NODATA(SBXCR_SBX
,SBXID_COLLECTION
,1);
234 SbxCollection( const OUString
& rClassname
);
235 SbxCollection( const SbxCollection
& );
236 SbxCollection
& operator=( const SbxCollection
& );
237 virtual SbxVariable
* FindUserData( sal_uInt32 nUserData
) SAL_OVERRIDE
;
238 virtual SbxVariable
* Find( const OUString
&, SbxClassType
) SAL_OVERRIDE
;
239 virtual void Clear() SAL_OVERRIDE
;
242 class BASIC_DLLPUBLIC SbxStdCollection
: public SbxCollection
247 virtual ~SbxStdCollection();
248 virtual bool LoadData( SvStream
&, sal_uInt16
) SAL_OVERRIDE
;
249 virtual bool StoreData( SvStream
& ) const SAL_OVERRIDE
;
250 virtual void CollAdd( SbxArray
* pPar
) SAL_OVERRIDE
;
251 virtual void CollRemove( SbxArray
* pPar
) SAL_OVERRIDE
;
253 SBX_DECL_PERSIST_NODATA(SBXCR_SBX
,SBXID_FIXCOLLECTION
,1);
255 SbxStdCollection( const OUString
& rClassname
, const OUString
& rElemClass
, bool=true );
256 SbxStdCollection( const SbxStdCollection
& );
257 SbxStdCollection
& operator=( const SbxStdCollection
& );
258 virtual void Insert( SbxVariable
* ) SAL_OVERRIDE
;
259 const OUString
& GetElementClass() const { return aElemClass
; }
262 #ifndef SBX_ARRAY_DECL_DEFINED
263 #define SBX_ARRAY_DECL_DEFINED
264 typedef tools::SvRef
<SbxArray
> SbxArrayRef
;
267 #ifndef SBX_INFO_DECL_DEFINED
268 #define SBX_INFO_DECL_DEFINED
269 typedef tools::SvRef
<SbxInfo
> SbxInfoRef
;
272 typedef tools::SvRef
<SbxDimArray
> SbxDimArrayRef
;
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */