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 .
21 #ifndef INCLUDED_BASIC_SBXDEF_HXX
22 #define INCLUDED_BASIC_SBXDEF_HXX
26 #include <tools/errcode.hxx>
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
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)
52 SbxVARIANT
= 12, // * Display for variant datatype
53 SbxDATAOBJECT
= 13, // * Common data object w/o ref count
55 SbxCHAR
= 16, // * signed char
56 SbxBYTE
= 17, // * unsigned char
57 SbxUSHORT
= 18, // * unsigned short (sal_uInt16)
58 SbxULONG
= 19, // * unsigned long (sal_uInt32)
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
64 SbxINT
= 22, // * signed machine-dependent int
65 SbxUINT
= 23, // * unsigned machine-dependent int
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
75 SbxLPWSTR
= 31, // wide null terminated string
76 SbxCoreSTRING
= 32, // from 1997-4-10 for GetCoreString(), only for converting<
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
84 SbxVECTOR
= 0x1000, // simple counted array
85 SbxARRAY
= 0x2000, // array
86 SbxBYREF
= 0x4000, // access by reference
88 SbxSV1
= 128, // first defined data type for StarView
89 SbxMEMORYSTREAM
, // SvMemoryStream
90 SbxSTORAGE
, // SvStorage
92 SbxUSER1
= 256, // first user defined data type
93 SbxUSERn
= 2047 // last user defined data type
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;
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
115 SbxXOR
, // this ^ var
116 SbxEQV
, // ~this ^ var
117 SbxIMP
, // ~this | var
118 SbxNOT
, // ~this (var is ignored)
120 // String concatenation:
121 SbxCAT
, // this & var (VBA: this + var)
125 SbxNE
, // this <> var
128 SbxLE
, // this <= var
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
139 // from 1996/3/20: New error messages
140 typedef sal_uIntPtr SbxError
; // Preserve old type
145 // New error codes per define
146 #define ERRCODE_SBX_OK ERRCODE_NONE // processed
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
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
215 #define SBX_READ 0x0001 // Read permission
216 #define SBX_WRITE 0x0002 // Write permission
217 #define SBX_READWRITE 0x0003 // Read/Write permission
218 #define SBX_DONTSTORE 0x0004 // Don't store object
219 #define SBX_MODIFIED 0x0008 // Object was changed
220 #define SBX_FIXED 0x0010 // Fixed data type (SbxVariable)
221 #define SBX_CONST 0x0020 // Definition of const value
222 #define SBX_OPTIONAL 0x0040 // Parameter is optional
223 #define SBX_HIDDEN 0x0080 // Element is invisible
224 #define SBX_INVISIBLE 0x0100 // Element is not found by Find()
225 #define SBX_EXTSEARCH 0x0200 // Object is searched completely
226 #define SBX_EXTFOUND 0x0400 // Variable was found through extended search
227 #define SBX_GBLSEARCH 0x0800 // Global search via Parents
228 #define SBX_RESERVED 0x1000 // reserved
229 #define SBX_PRIVATE 0x1000 // #110004, #112015, cannot conflict with SBX_RESERVED
230 #define SBX_NO_BROADCAST 0x2000 // No broadcast on Get/Put
231 #define SBX_REFERENCE 0x4000 // Parameter is Reference (DLL-call)
232 #define SBX_NO_MODIFY 0x8000 // SetModified is suppressed
233 #define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN
234 #define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one
235 // is used for objects, the other for variables only
236 #define SBX_VAR_TO_DIM 0x2000 // Same value as SBX_NO_BROADCAST, cannot conflict as
237 // used for variables without broadcaster only
240 #define SBX_HINT_DYING SFX_HINT_DYING
241 #define SBX_HINT_DATAWANTED SFX_HINT_USER00
242 #define SBX_HINT_DATACHANGED SFX_HINT_DATACHANGED
243 #define SBX_HINT_CONVERTED SFX_HINT_USER01
244 #define SBX_HINT_INFOWANTED SFX_HINT_USER02
245 #define SBX_HINT_OBJECTCHANGED SFX_HINT_USER03
247 // List of all creators for Load/Store
249 #define SBXCR_SBX 0x20584253 // SBX(blank)
251 // List of predefined SBX-IDs. New SBX-IDs must be precisly defined so that
252 // they are unique within the Stream and appropriate Factory.
254 #define SBXID_VALUE 0x4E4E // NN: SbxValue
255 #define SBXID_VARIABLE 0x4156 // VA: SbxVariable
256 #define SBXID_ARRAY 0x5241 // AR: SbxArray
257 #define SBXID_DIMARRAY 0x4944 // DI: SbxDimArray
258 #define SBXID_OBJECT 0x424F // OB: SbxObject
259 #define SBXID_COLLECTION 0x4F43 // CO: SbxCollection
260 #define SBXID_FIXCOLLECTION 0x4346 // FC: SbxStdCollection
261 #define SBXID_METHOD 0x454D // ME: SbxMethod
262 #define SBXID_PROPERTY 0x5250 // PR: SbxProperty
264 // StarBASIC restricts the base data type to different intervals.
265 // These intervals are fixed to create 'portability and independent
266 // of the implementation. Only type double is greedy and takes
269 #define SbxMAXCHAR ((sal_Unicode)65535)
270 #define SbxMINCHAR (0)
271 #define SbxMAXBYTE ( 255)
272 #define SbxMAXINT ( 32767)
273 #define SbxMININT (-32768)
274 #define SbxMAXUINT ((sal_uInt16) 65535)
275 #define SbxMAXLNG ( 2147483647)
276 #define SbxMINLNG ((sal_Int32)(-2147483647-1))
277 #define SbxMAXULNG ((sal_uInt32) 0xffffffff)
279 #define SbxMAXSALUINT64 SAL_MAX_UINT64
280 #define SbxMAXSALINT64 SAL_MAX_INT64
281 #define SbxMINSALINT64 SAL_MIN_INT64
283 // Currency stored as SbxSALINT64 == sal_Int64
284 // value range limits are ~(2^63 - 1)/10000
285 // fixed precision has 4 digits right of decimal pt
286 #define CURRENCY_FACTOR (10000)
287 #define CURRENCY_FACTOR_SQUARE (100000000)
289 // TODO effective MAX/MINCURR limits:
290 // true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double
291 #define SbxMAXCURR ( 922337203685477.5807)
292 #define SbxMINCURR (-922337203685477.5808)
294 #define SbxMAXSNG ( 3.402823e+38)
295 #define SbxMINSNG (-3.402823e+38)
296 #define SbxMAXSNG2 ( 1.175494351e-38)
297 #define SbxMINSNG2 (-1.175494351e-38)
299 // Max valid offset index of a Sbx-Array (due to 64K limit)
300 #define SBX_MAXINDEX 0x3FF0
301 #define SBX_MAXINDEX32 SbxMAXLNG
303 // The numeric values of sal_True and FALSE
304 enum SbxBOOL
{ SbxFALSE
= 0, SbxTRUE
= -1 };
306 #endif //ifndef __RSC
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */