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, // SotStorage
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_NO_OBJECT ERRCODE_SBX_NO_OBJECT
192 : #define SbxERR_BAD_INDEX ERRCODE_SBX_BAD_INDEX
193 : #define SbxERR_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT
194 : #define SbxERR_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE
195 : #define SbxERR_PROP_READONLY ERRCODE_SBX_PROP_READONLY
196 : #define SbxERR_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY
197 : #define SbxERR_NO_METHOD ERRCODE_SBX_NO_METHOD
198 : #define SbxERR_BAD_ACTION ERRCODE_SBX_BAD_ACTION
199 : #define SbxERR_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS
200 :
201 :
202 : // Flag-Bits:
203 : enum SbxFlagBits {
204 : SBX_NONE = 0x0000,
205 : SBX_READ = 0x0001, // Read permission
206 : SBX_WRITE = 0x0002, // Write permission
207 : SBX_READWRITE = 0x0003, // Read/Write permission
208 : SBX_DONTSTORE = 0x0004, // Don't store object
209 : SBX_MODIFIED = 0x0008, // Object was changed
210 : SBX_FIXED = 0x0010, // Fixed data type (SbxVariable)
211 : SBX_CONST = 0x0020, // Definition of const value
212 : SBX_OPTIONAL = 0x0040, // Parameter is optional
213 : SBX_HIDDEN = 0x0080, // Element is invisible
214 : SBX_INVISIBLE = 0x0100, // Element is not found by Find()
215 : SBX_EXTSEARCH = 0x0200, // Object is searched completely
216 : SBX_EXTFOUND = 0x0400, // Variable was found through extended search
217 : SBX_GBLSEARCH = 0x0800, // Global search via Parents
218 : SBX_RESERVED = 0x1000, // reserved
219 : SBX_PRIVATE = 0x1000, // #110004, #112015, cannot conflict with SBX_RESERVED
220 : SBX_NO_BROADCAST = 0x2000, // No broadcast on Get/Put
221 : SBX_REFERENCE = 0x4000, // Parameter is Reference (DLL-call)
222 : SBX_NO_MODIFY = 0x8000, // SetModified is suppressed
223 : SBX_WITH_EVENTS = 0x0080, // Same value as unused SBX_HIDDEN
224 : SBX_DIM_AS_NEW = 0x0800, // Same value as SBX_GBLSEARCH, cannot conflict as one
225 : // is used for objects, the other for variables only
226 : SBX_VAR_TO_DIM = 0x2000, // Same value as SBX_NO_BROADCAST, cannot conflict as
227 : // used for variables without broadcaster only
228 : };
229 : // make combining these type-safe
230 7921 : inline SbxFlagBits operator| (SbxFlagBits lhs, SbxFlagBits rhs)
231 : {
232 7921 : return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
233 : }
234 9154576 : inline SbxFlagBits operator& (SbxFlagBits lhs, SbxFlagBits rhs)
235 : {
236 9154576 : return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
237 : }
238 2407284 : inline SbxFlagBits& operator|= (SbxFlagBits& lhs, SbxFlagBits rhs)
239 : {
240 2407284 : lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
241 2407284 : return lhs;
242 : }
243 1024151 : inline SbxFlagBits operator~ (SbxFlagBits rhs)
244 : {
245 1024151 : return static_cast<SbxFlagBits>(0xffff & ~(static_cast<sal_uInt16>(rhs)));
246 : }
247 1024151 : inline SbxFlagBits& operator&= (SbxFlagBits& lhs, SbxFlagBits rhs)
248 : {
249 1024151 : lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
250 1024151 : return lhs;
251 : }
252 :
253 : // Broadcaster-IDs:
254 : #define SBX_HINT_DYING SFX_HINT_DYING
255 : #define SBX_HINT_DATAWANTED SFX_HINT_USER00
256 : #define SBX_HINT_DATACHANGED SFX_HINT_DATACHANGED
257 : #define SBX_HINT_CONVERTED SFX_HINT_USER01
258 : #define SBX_HINT_INFOWANTED SFX_HINT_USER02
259 : #define SBX_HINT_OBJECTCHANGED SFX_HINT_USER03
260 :
261 : // List of all creators for Load/Store
262 :
263 : #define SBXCR_SBX 0x20584253 // SBX(blank)
264 :
265 : // List of predefined SBX-IDs. New SBX-IDs must be precisely defined so that
266 : // they are unique within the Stream and appropriate Factory.
267 :
268 : #define SBXID_VALUE 0x4E4E // NN: SbxValue
269 : #define SBXID_VARIABLE 0x4156 // VA: SbxVariable
270 : #define SBXID_ARRAY 0x5241 // AR: SbxArray
271 : #define SBXID_DIMARRAY 0x4944 // DI: SbxDimArray
272 : #define SBXID_OBJECT 0x424F // OB: SbxObject
273 : #define SBXID_COLLECTION 0x4F43 // CO: SbxCollection
274 : #define SBXID_FIXCOLLECTION 0x4346 // FC: SbxStdCollection
275 : #define SBXID_METHOD 0x454D // ME: SbxMethod
276 : #define SBXID_PROPERTY 0x5250 // PR: SbxProperty
277 :
278 : // StarBASIC restricts the base data type to different intervals.
279 : // These intervals are fixed to create 'portability and independent
280 : // of the implementation. Only type double is greedy and takes
281 : // what it gets.
282 :
283 : #define SbxMAXCHAR ((sal_Unicode)65535)
284 : #define SbxMINCHAR (0)
285 : #define SbxMAXBYTE ( 255)
286 : #define SbxMAXINT ( 32767)
287 : #define SbxMININT (-32768)
288 : #define SbxMAXUINT ((sal_uInt16) 65535)
289 : #define SbxMAXLNG ( 2147483647)
290 : #define SbxMINLNG ((sal_Int32)(-2147483647-1))
291 : #define SbxMAXULNG ((sal_uInt32) 0xffffffff)
292 :
293 : #define SbxMAXSALUINT64 SAL_MAX_UINT64
294 : #define SbxMAXSALINT64 SAL_MAX_INT64
295 : #define SbxMINSALINT64 SAL_MIN_INT64
296 :
297 : // Currency stored as SbxSALINT64 == sal_Int64
298 : // value range limits are ~(2^63 - 1)/10000
299 : // fixed precision has 4 digits right of decimal pt
300 : #define CURRENCY_FACTOR (10000)
301 : #define CURRENCY_FACTOR_SQUARE (100000000)
302 :
303 : // TODO effective MAX/MINCURR limits:
304 : // true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double
305 : #define SbxMAXCURR ( 922337203685477.5807)
306 : #define SbxMINCURR (-922337203685477.5808)
307 :
308 : #define SbxMAXSNG ( 3.402823e+38)
309 : #define SbxMINSNG (-3.402823e+38)
310 : #define SbxMAXSNG2 ( 1.175494351e-38)
311 : #define SbxMINSNG2 (-1.175494351e-38)
312 :
313 : // Max valid offset index of a Sbx-Array (due to 64K limit)
314 : #define SBX_MAXINDEX 0x3FF0
315 : #define SBX_MAXINDEX32 SbxMAXLNG
316 :
317 : // The numeric values of sal_True and FALSE
318 : enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 };
319 :
320 : #endif //ifndef __RSC
321 :
322 : #endif
323 :
324 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|