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