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 <config_options.h>
24 #include <tools/ref.hxx>
25 #include <svl/hint.hxx>
27 #include <basic/sbxdef.hxx>
28 #include <basic/sbxobj.hxx>
29 #include <basic/basicdllapi.h>
38 // Parameter information
41 const OUString aName
; // Name of the parameter
42 SbxDataType eType
; // Data type
43 SbxFlagBits nFlags
; // Flag-Bits
44 sal_uInt32 nUserData
; // IDs etc.
45 SbxParamInfo( const OUString
& s
, SbxDataType t
, SbxFlagBits n
)
46 : aName( s
), eType( t
), nFlags( n
), nUserData( 0 ) {}
49 typedef std::vector
<std::unique_ptr
<SbxParamInfo
>> SbxParams
;
51 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC
) SbxInfo
: public SvRefBase
53 friend class SbxVariable
;
54 friend class SbMethod
;
61 SbxInfo(SbxInfo
const&) = delete;
62 void operator=(SbxInfo
const&) = delete;
65 void LoadData( SvStream
&, sal_uInt16
);
66 void StoreData( SvStream
& ) const;
67 virtual ~SbxInfo() override
;
70 SbxInfo( const OUString
&, sal_uInt32
);
72 void AddParam( const OUString
&, SbxDataType
, SbxFlagBits
=SbxFlagBits::Read
);
73 const SbxParamInfo
* GetParam( sal_uInt16 n
) const; // index starts with 1!
74 const OUString
& GetComment() const { return aComment
; }
75 const OUString
& GetHelpFile() const { return aHelpFile
; }
76 sal_uInt32
GetHelpId() const { return nHelpId
; }
78 void SetComment( const OUString
& r
) { aComment
= r
; }
81 class BASIC_DLLPUBLIC SbxHint final
: public SfxHint
85 SbxHint( SfxHintId n
, SbxVariable
* v
) : SfxHint( n
), pVar( v
) {}
86 SbxVariable
* GetVar() const { return pVar
; }
89 // SbxArray is an unidimensional, dynamic Array
90 // The variables convert from SbxVariablen. Put()/Insert() into the
91 // declared datatype, if they are not SbxVARIANT.
95 class BASIC_DLLPUBLIC SbxArray
: public SbxBase
97 // #100883 Method to set method directly to parameter array
98 friend class SbMethod
;
99 friend class SbClassModuleObject
;
100 friend SbxObject
* cloneTypeObjectImpl( const SbxObject
& rTypeObj
);
101 BASIC_DLLPRIVATE
void PutDirect( SbxVariable
* pVar
, sal_uInt32 nIdx
);
103 std::vector
<SbxVarEntry
> mVarEntries
; // The variables
104 SbxDataType eType
; // Data type of the array
107 virtual ~SbxArray() override
;
108 virtual bool LoadData( SvStream
&, sal_uInt16
) override
;
109 virtual bool StoreData( SvStream
& ) const override
;
112 SBX_DECL_PERSIST_NODATA(SBXID_ARRAY
,1);
113 SbxArray( SbxDataType
=SbxVARIANT
);
114 SbxArray( const SbxArray
& ) = delete;
115 SbxArray
& operator=( const SbxArray
& );
116 virtual void Clear() override
;
117 sal_uInt32
Count32() const;
118 virtual SbxDataType
GetType() const override
;
119 SbxVariableRef
& GetRef32( sal_uInt32
);
120 SbxVariable
* Get32( sal_uInt32
);
121 void Put32( SbxVariable
*, sal_uInt32
);
122 void Insert32( SbxVariable
*, sal_uInt32
);
123 void Remove( sal_uInt32
);
124 void Remove( SbxVariable
const * );
125 void Merge( SbxArray
* );
126 OUString
GetAlias32( sal_uInt32
);
127 void PutAlias32( const OUString
&, sal_uInt32
);
128 SbxVariable
* Find( const OUString
&, SbxClassType
);
131 // SbxDimArray is an array that can dimensioned using BASIC conventions.
132 struct SbxDim
{ // an array-dimension:
133 sal_Int32 nLbound
, nUbound
; // Limitations
134 sal_Int32 nSize
; // Number of elements
137 class BASIC_DLLPUBLIC SbxDimArray final
: public SbxArray
139 std::vector
<SbxDim
> m_vDimensions
; // Dimension table
140 BASIC_DLLPRIVATE
void AddDimImpl32( sal_Int32
, sal_Int32
, bool bAllowSize0
);
143 sal_uInt32
Offset32( const sal_Int32
* );
144 sal_uInt32
Offset32( SbxArray
* );
145 virtual bool LoadData( SvStream
&, sal_uInt16
) override
;
146 virtual bool StoreData( SvStream
& ) const override
;
147 virtual ~SbxDimArray() override
;
149 SBX_DECL_PERSIST_NODATA(SBXID_DIMARRAY
,1);
150 SbxDimArray( SbxDataType
=SbxVARIANT
);
151 SbxDimArray( const SbxDimArray
& ) = delete;
152 SbxDimArray
& operator=( const SbxDimArray
& );
153 virtual void Clear() override
;
154 SbxVariable
* Get( SbxArray
* );
156 using SbxArray::GetRef32
;
157 using SbxArray::Get32
;
158 SbxVariable
* Get32( const sal_Int32
* );
159 using SbxArray::Put32
;
160 void Put32( SbxVariable
*, const sal_Int32
* );
161 sal_Int32
GetDims32() const { return m_vDimensions
.size(); }
162 void AddDim32( sal_Int32
, sal_Int32
);
163 void unoAddDim32( sal_Int32
, sal_Int32
);
164 bool GetDim32( sal_Int32
, sal_Int32
&, sal_Int32
& ) const;
165 bool hasFixedSize() const { return mbHasFixedSize
; };
166 void setHasFixedSize( bool bHasFixedSize
) {mbHasFixedSize
= bHasFixedSize
; };
169 class SbxCollection
: public SbxObject
173 virtual ~SbxCollection() override
;
174 virtual bool LoadData( SvStream
&, sal_uInt16
) override
;
175 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
176 // Overridable methods (why not pure virtual?):
177 virtual void CollAdd( SbxArray
* pPar
);
178 void CollItem( SbxArray
* pPar
);
179 virtual void CollRemove( SbxArray
* pPar
);
182 SBX_DECL_PERSIST_NODATA(SBXID_COLLECTION
,1);
184 SbxCollection( const SbxCollection
& );
185 SbxCollection
& operator=( const SbxCollection
& );
186 virtual SbxVariable
* Find( const OUString
&, SbxClassType
) override
;
187 virtual void Clear() override
;
190 class SbxStdCollection final
: public SbxCollection
194 virtual ~SbxStdCollection() override
;
195 virtual bool LoadData( SvStream
&, sal_uInt16
) override
;
196 virtual bool StoreData( SvStream
& ) const override
;
197 virtual void CollAdd( SbxArray
* pPar
) override
;
198 virtual void CollRemove( SbxArray
* pPar
) override
;
200 SBX_DECL_PERSIST_NODATA(SBXID_FIXCOLLECTION
,1);
202 SbxStdCollection( const SbxStdCollection
& );
203 SbxStdCollection
& operator=( const SbxStdCollection
& );
204 virtual void Insert( SbxVariable
* ) override
;
207 typedef tools::SvRef
<SbxArray
> SbxArrayRef
;
208 typedef tools::SvRef
<SbxInfo
> SbxInfoRef
;
209 typedef tools::SvRef
<SbxDimArray
> SbxDimArrayRef
;
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */