Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #ifndef INCLUDED_BASIC_SBXDEF_HXX
22 : #define INCLUDED_BASIC_SBXDEF_HXX
23 :
24 :
25 : #ifndef __RSC
26 : #include <tools/errcode.hxx>
27 :
28 : enum SbxClassType { // SBX-class-IDs (order is important!)
29 : SbxCLASS_DONTCARE = 1, // don't care (search, not 0 due to StarBASIC)
30 : SbxCLASS_ARRAY, // Array of SbxVariables
31 : SbxCLASS_VALUE, // simple value
32 : SbxCLASS_VARIABLE, // Variable (from here there is Broadcaster)
33 : SbxCLASS_METHOD, // Method (Function or Sub)
34 : SbxCLASS_PROPERTY, // Property
35 : SbxCLASS_OBJECT // Object
36 : };
37 :
38 : enum SbxDataType {
39 : SbxEMPTY = 0, // * Uninitialized
40 : SbxNULL = 1, // * Contains no valid data
41 : SbxINTEGER = 2, // * Integer (sal_Int16)
42 : SbxLONG = 3, // * Long integer (sal_Int32)
43 : SbxSINGLE = 4, // * Single-precision floating point number (float)
44 : SbxDOUBLE = 5, // * Double-precision floating point number (double)
45 : SbxCURRENCY = 6, // Currency (sal_Int64)
46 : SbxDATE = 7, // * Date (double)
47 : SbxSTRING = 8, // * String (StarView)
48 : SbxOBJECT = 9, // * SbxBase object pointer
49 : SbxERROR = 10, // * Error (sal_uInt16)
50 : SbxBOOL = 11, // * Boolean (0 or -1)
51 :
52 : SbxVARIANT = 12, // * Display for variant datatype
53 : SbxDATAOBJECT = 13, // * Common data object w/o ref count
54 :
55 : SbxCHAR = 16, // * signed char
56 : SbxBYTE = 17, // * unsigned char
57 : SbxUSHORT = 18, // * unsigned short (sal_uInt16)
58 : SbxULONG = 19, // * unsigned long (sal_uInt32)
59 :
60 : //deprecated: // old 64bit types kept for backward compatibility in file I/O
61 : SbxLONG64 = 20, // moved to SbxSALINT64 as 64bit int
62 : SbxULONG64 = 21, // moved to SbxSALUINT64 as 64bit int
63 :
64 : SbxINT = 22, // * signed machine-dependent int
65 : SbxUINT = 23, // * unsigned machine-dependent int
66 :
67 : SbxVOID = 24, // * no value (= SbxEMPTY)
68 : SbxHRESULT = 25, // HRESULT
69 : SbxPOINTER = 26, // generic pointer
70 : SbxDIMARRAY = 27, // dimensioned array
71 : SbxCARRAY = 28, // C style array
72 : SbxUSERDEF = 29, // user defined
73 : SbxLPSTR = 30, // * null terminated string
74 :
75 : SbxLPWSTR = 31, // wide null terminated string
76 : SbxCoreSTRING = 32, // from 1997-4-10 for GetCoreString(), only for converting<
77 :
78 : SbxWSTRING = 33, // from 2000-10-4 Reimplemented for backwards compatibility (#78919)
79 : SbxWCHAR = 34, // from 2000-10-4 Reimplemented for backwards compatibility (#78919)
80 : SbxSALINT64 = 35, // for currency internal, signed 64-bit int and UNO hyper
81 : SbxSALUINT64= 36, // for currency internal, unsigned 64-bit int and UNO unsigned hyper
82 : SbxDECIMAL = 37, // for UNO/automation Decimal
83 :
84 : SbxVECTOR = 0x1000, // simple counted array
85 : SbxARRAY = 0x2000, // array
86 : SbxBYREF = 0x4000, // access by reference
87 :
88 : SbxSV1 = 128, // first defined data type for StarView
89 : SbxMEMORYSTREAM, // SvMemoryStream
90 : SbxSTORAGE, // SvStorage
91 :
92 : SbxUSER1 = 256, // first user defined data type
93 : SbxUSERn = 2047 // last user defined data type
94 : };
95 :
96 : const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000;
97 : const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000;
98 : const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible
99 : const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000;
100 :
101 : enum SbxOperator {
102 : // Arithmetical:
103 : SbxEXP, // this ^ var
104 : SbxMUL, // this * var
105 : SbxDIV, // this / var
106 : SbxMOD, // this MOD var (max INT32!)
107 : SbxPLUS, // this + var
108 : SbxMINUS, // this - var
109 : SbxNEG, // -this (var is ignored)
110 : SbxIDIV, // this / var (both operands max. sal_Int32!)
111 : // Boolean operators (max sal_Int32!):
112 : // Boolean operators (TODO deprecate this limit: max INT32!)
113 : SbxAND, // this & var
114 : SbxOR, // this | var
115 : SbxXOR, // this ^ var
116 : SbxEQV, // ~this ^ var
117 : SbxIMP, // ~this | var
118 : SbxNOT, // ~this (var is ignored)
119 :
120 : // String concatenation:
121 : SbxCAT, // this & var (VBA: this + var)
122 :
123 : // Comparisons:
124 : SbxEQ, // this = var
125 : SbxNE, // this <> var
126 : SbxLT, // this < var
127 : SbxGT, // this > var
128 : SbxLE, // this <= var
129 : SbxGE // this >= var
130 : };
131 :
132 : enum SbxNameType { // Type of the questioned name of a variable
133 : SbxNAME_NONE, // plain name
134 : SbxNAME_SHORT, // Name(A,B)
135 : SbxNAME_SHORT_TYPES, // Name%(A%,B$)
136 : SbxNAME_LONG_TYPES // Name(A As Integer, B As String) As Integer
137 : };
138 :
139 : // from 1996/3/20: New error messages
140 : typedef sal_uIntPtr SbxError; // Preserve old type
141 :
142 : #endif
143 :
144 :
145 : // New error codes per define
146 : #define ERRCODE_SBX_OK ERRCODE_NONE // processed
147 :
148 : #define ERRCODE_SBX_SYNTAX (1UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_COMPILER)
149 : #define ERRCODE_SBX_NOTIMP (2UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED)
150 : #define ERRCODE_SBX_OVERFLOW (3UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // overflow
151 : #define ERRCODE_SBX_BOUNDS (4UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid array index
152 : #define ERRCODE_SBX_ZERODIV (5UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Division by zero
153 : #define ERRCODE_SBX_CONVERSION (6UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // wrong data type
154 : #define ERRCODE_SBX_BAD_PARAMETER (7UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // invalid Parameter
155 : #define ERRCODE_SBX_PROC_UNDEFINED (8UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Sub or Func not def
156 : #define ERRCODE_SBX_ERROR (9UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_UNKNOWN) // generic object error
157 : #define ERRCODE_SBX_NO_OBJECT (10UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object var not object
158 : #define ERRCODE_SBX_CANNOT_LOAD (11UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_CREATE) // Object init/load fail
159 : #define ERRCODE_SBX_BAD_INDEX (12UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid object index
160 : #define ERRCODE_SBX_NO_ACTIVE_OBJECT (13UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Object not active
161 : #define ERRCODE_SBX_BAD_PROP_VALUE (14UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Bad property value
162 : #define ERRCODE_SBX_PROP_READONLY (15UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_READ) // Property is read only
163 : #define ERRCODE_SBX_PROP_WRITEONLY (16UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_WRITE) // Property is write only
164 : #define ERRCODE_SBX_INVALID_OBJECT (17UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object reference
165 : #define ERRCODE_SBX_NO_METHOD (18UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Property oder Methode unbekannt
166 : #define ERRCODE_SBX_INVALID_USAGE_OBJECT (19UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object usage
167 : #define ERRCODE_SBX_NO_OLE (20UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // No OLE-Object
168 : #define ERRCODE_SBX_BAD_METHOD (21UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Method not supported
169 : #define ERRCODE_SBX_OLE_ERROR (22UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // OLE Automation Error
170 : #define ERRCODE_SBX_BAD_ACTION (23UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Action not supported
171 : #define ERRCODE_SBX_NO_NAMED_ARGS (24UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // No named arguments
172 : #define ERRCODE_SBX_BAD_LOCALE (25UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Locale not supported
173 : #define ERRCODE_SBX_NAMED_NOT_FOUND (26UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Unknown named argument
174 : #define ERRCODE_SBX_NOT_OPTIONAL (27UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Argument not optional
175 : #define ERRCODE_SBX_WRONG_ARGS (28UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid number of arguments
176 : #define ERRCODE_SBX_NOT_A_COLL (29UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object contains no elements
177 : #define LAST_SBX_ERROR_ID 29UL
178 :
179 : #ifndef __RSC
180 :
181 : // Map old codes to new ones
182 : #define SbxERR_OK ERRCODE_SBX_OK
183 : #define SbxERR_SYNTAX ERRCODE_SBX_SYNTAX
184 : #define SbxERR_NOTIMP ERRCODE_SBX_NOTIMP
185 : #define SbxERR_OVERFLOW ERRCODE_SBX_OVERFLOW
186 : #define SbxERR_BOUNDS ERRCODE_SBX_BOUNDS
187 : #define SbxERR_ZERODIV ERRCODE_SBX_ZERODIV
188 : #define SbxERR_CONVERSION ERRCODE_SBX_CONVERSION
189 : #define SbxERR_BAD_PARAMETER ERRCODE_SBX_BAD_PARAMETER
190 : #define SbxERR_PROC_UNDEFINED ERRCODE_SBX_PROC_UNDEFINED
191 : #define SbxERR_ERROR ERRCODE_SBX_ERROR
192 : #define SbxERR_NO_OBJECT ERRCODE_SBX_NO_OBJECT
193 : #define SbxERR_CANNOT_LOAD ERRCODE_SBX_CANNOT_LOAD
194 : #define SbxERR_BAD_INDEX ERRCODE_SBX_BAD_INDEX
195 : #define SbxERR_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT
196 : #define SbxERR_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE
197 : #define SbxERR_PROP_READONLY ERRCODE_SBX_PROP_READONLY
198 : #define SbxERR_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY
199 : #define SbxERR_INVALID_OBJECT ERRCODE_SBX_INVALID_OBJECT
200 : #define SbxERR_NO_METHOD ERRCODE_SBX_NO_METHOD
201 : #define SbxERR_INVALID_USAGE_OBJECT ERRCODE_SBX_INVALID_USAGE_OBJECT
202 : #define SbxERR_NO_OLE ERRCODE_SBX_NO_OLE
203 : #define SbxERR_BAD_METHOD ERRCODE_SBX_BAD_METHOD
204 : #define SbxERR_OLE_ERROR ERRCODE_SBX_OLE_ERROR
205 : #define SbxERR_BAD_ACTION ERRCODE_SBX_BAD_ACTION
206 : #define SbxERR_NO_NAMED_ARGS ERRCODE_SBX_NO_NAMED_ARGS
207 : #define SbxERR_BAD_LOCALE ERRCODE_SBX_BAD_LOCALE
208 : #define SbxERR_NAMED_NOT_FOUND ERRCODE_SBX_NAMED_NOT_FOUND
209 : #define SbxERR_NOT_OPTIONAL ERRCODE_SBX_NOT_OPTIONAL
210 : #define SbxERR_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS
211 : #define SbxERR_NOT_A_COLL ERRCODE_SBX_NOT_A_COLL
212 :
213 :
214 : // Flag-Bits:
215 : enum SbxFlagBits {
216 : SBX_NONE = 0x0000,
217 : SBX_READ = 0x0001, // Read permission
218 : SBX_WRITE = 0x0002, // Write permission
219 : SBX_READWRITE = 0x0003, // Read/Write permission
220 : SBX_DONTSTORE = 0x0004, // Don't store object
221 : SBX_MODIFIED = 0x0008, // Object was changed
222 : SBX_FIXED = 0x0010, // Fixed data type (SbxVariable)
223 : SBX_CONST = 0x0020, // Definition of const value
224 : SBX_OPTIONAL = 0x0040, // Parameter is optional
225 : SBX_HIDDEN = 0x0080, // Element is invisible
226 : SBX_INVISIBLE = 0x0100, // Element is not found by Find()
227 : SBX_EXTSEARCH = 0x0200, // Object is searched completely
228 : SBX_EXTFOUND = 0x0400, // Variable was found through extended search
229 : SBX_GBLSEARCH = 0x0800, // Global search via Parents
230 : SBX_RESERVED = 0x1000, // reserved
231 : SBX_PRIVATE = 0x1000, // #110004, #112015, cannot conflict with SBX_RESERVED
232 : SBX_NO_BROADCAST = 0x2000, // No broadcast on Get/Put
233 : SBX_REFERENCE = 0x4000, // Parameter is Reference (DLL-call)
234 : SBX_NO_MODIFY = 0x8000, // SetModified is suppressed
235 : SBX_WITH_EVENTS = 0x0080, // Same value as unused SBX_HIDDEN
236 : SBX_DIM_AS_NEW = 0x0800, // Same value as SBX_GBLSEARCH, cannot conflict as one
237 : // is used for objects, the other for variables only
238 : SBX_VAR_TO_DIM = 0x2000, // Same value as SBX_NO_BROADCAST, cannot conflict as
239 : // used for variables without broadcaster only
240 : };
241 : // make combining these type-safe
242 13648 : inline SbxFlagBits operator| (SbxFlagBits lhs, SbxFlagBits rhs)
243 : {
244 13648 : return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
245 : }
246 16311014 : inline SbxFlagBits operator& (SbxFlagBits lhs, SbxFlagBits rhs)
247 : {
248 16311014 : return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
249 : }
250 4215542 : inline SbxFlagBits& operator|= (SbxFlagBits& lhs, SbxFlagBits rhs)
251 : {
252 4215542 : lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
253 4215542 : return lhs;
254 : }
255 1802948 : inline SbxFlagBits operator~ (SbxFlagBits rhs)
256 : {
257 1802948 : return static_cast<SbxFlagBits>(0xffff & ~(static_cast<sal_uInt16>(rhs)));
258 : }
259 1802948 : inline SbxFlagBits& operator&= (SbxFlagBits& lhs, SbxFlagBits rhs)
260 : {
261 1802948 : lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
262 1802948 : return lhs;
263 : }
264 :
265 : // Broadcaster-IDs:
266 : #define SBX_HINT_DYING SFX_HINT_DYING
267 : #define SBX_HINT_DATAWANTED SFX_HINT_USER00
268 : #define SBX_HINT_DATACHANGED SFX_HINT_DATACHANGED
269 : #define SBX_HINT_CONVERTED SFX_HINT_USER01
270 : #define SBX_HINT_INFOWANTED SFX_HINT_USER02
271 : #define SBX_HINT_OBJECTCHANGED SFX_HINT_USER03
272 :
273 : // List of all creators for Load/Store
274 :
275 : #define SBXCR_SBX 0x20584253 // SBX(blank)
276 :
277 : // List of predefined SBX-IDs. New SBX-IDs must be precisly defined so that
278 : // they are unique within the Stream and appropriate Factory.
279 :
280 : #define SBXID_VALUE 0x4E4E // NN: SbxValue
281 : #define SBXID_VARIABLE 0x4156 // VA: SbxVariable
282 : #define SBXID_ARRAY 0x5241 // AR: SbxArray
283 : #define SBXID_DIMARRAY 0x4944 // DI: SbxDimArray
284 : #define SBXID_OBJECT 0x424F // OB: SbxObject
285 : #define SBXID_COLLECTION 0x4F43 // CO: SbxCollection
286 : #define SBXID_FIXCOLLECTION 0x4346 // FC: SbxStdCollection
287 : #define SBXID_METHOD 0x454D // ME: SbxMethod
288 : #define SBXID_PROPERTY 0x5250 // PR: SbxProperty
289 :
290 : // StarBASIC restricts the base data type to different intervals.
291 : // These intervals are fixed to create 'portability and independent
292 : // of the implementation. Only type double is greedy and takes
293 : // what it gets.
294 :
295 : #define SbxMAXCHAR ((sal_Unicode)65535)
296 : #define SbxMINCHAR (0)
297 : #define SbxMAXBYTE ( 255)
298 : #define SbxMAXINT ( 32767)
299 : #define SbxMININT (-32768)
300 : #define SbxMAXUINT ((sal_uInt16) 65535)
301 : #define SbxMAXLNG ( 2147483647)
302 : #define SbxMINLNG ((sal_Int32)(-2147483647-1))
303 : #define SbxMAXULNG ((sal_uInt32) 0xffffffff)
304 :
305 : #define SbxMAXSALUINT64 SAL_MAX_UINT64
306 : #define SbxMAXSALINT64 SAL_MAX_INT64
307 : #define SbxMINSALINT64 SAL_MIN_INT64
308 :
309 : // Currency stored as SbxSALINT64 == sal_Int64
310 : // value range limits are ~(2^63 - 1)/10000
311 : // fixed precision has 4 digits right of decimal pt
312 : #define CURRENCY_FACTOR (10000)
313 : #define CURRENCY_FACTOR_SQUARE (100000000)
314 :
315 : // TODO effective MAX/MINCURR limits:
316 : // true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double
317 : #define SbxMAXCURR ( 922337203685477.5807)
318 : #define SbxMINCURR (-922337203685477.5808)
319 :
320 : #define SbxMAXSNG ( 3.402823e+38)
321 : #define SbxMINSNG (-3.402823e+38)
322 : #define SbxMAXSNG2 ( 1.175494351e-38)
323 : #define SbxMINSNG2 (-1.175494351e-38)
324 :
325 : // Max valid offset index of a Sbx-Array (due to 64K limit)
326 : #define SBX_MAXINDEX 0x3FF0
327 : #define SBX_MAXINDEX32 SbxMAXLNG
328 :
329 : // The numeric values of sal_True and FALSE
330 : enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 };
331 :
332 : #endif //ifndef __RSC
333 :
334 : #endif
335 :
336 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|