LibreOffice Module basic (master) 1
sbxdef.hxx
Go to the documentation of this file.
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
25#include <sal/types.h>
26
27enum class SbxClassType { // SBX-class-IDs (order is important!)
28 DontCare = 1, // don't care (search, not 0 due to StarBASIC)
29 Array, // Array of SbxVariables
30 Value, // simple value
31 Variable, // Variable (from here there is Broadcaster)
32 Method, // Method (Function or Sub)
33 Property, // Property
34 Object // Object
35};
36
38 SbxEMPTY = 0, // * Uninitialized
39 SbxNULL = 1, // * Contains no valid data
40 SbxINTEGER = 2, // * Integer (sal_Int16)
41 SbxLONG = 3, // * Long integer (sal_Int32)
42 SbxSINGLE = 4, // * Single-precision floating point number (float)
43 SbxDOUBLE = 5, // * Double-precision floating point number (double)
44 SbxCURRENCY = 6, // Currency (sal_Int64)
45 SbxDATE = 7, // * Date (double)
46 SbxSTRING = 8, // * String (StarView)
47 SbxOBJECT = 9, // * SbxBase object pointer
48 SbxERROR = 10, // * Error (sal_uInt16)
49 SbxBOOL = 11, // * Boolean (0 or -1)
50
51 SbxVARIANT = 12, // * Display for variant datatype
52 SbxDATAOBJECT = 13, // * Common data object w/o ref count
53
54 SbxCHAR = 16, // * signed char
55 SbxBYTE = 17, // * unsigned char
56 SbxUSHORT = 18, // * unsigned short (sal_uInt16)
57 SbxULONG = 19, // * unsigned long (sal_uInt32)
58
59 SbxINT = 22, // * signed machine-dependent int
60 SbxUINT = 23, // * unsigned machine-dependent int
61
62 SbxVOID = 24, // * no value (= SbxEMPTY)
63 SbxHRESULT = 25, // HRESULT
64 SbxPOINTER = 26, // generic pointer
65 SbxDIMARRAY = 27, // dimensioned array
66 SbxCARRAY = 28, // C style array
67 SbxUSERDEF = 29, // user defined
68 SbxLPSTR = 30, // * null terminated string
69
70 SbxLPWSTR = 31, // wide null terminated string
71 SbxCoreSTRING = 32, // from 1997-4-10 for GetCoreString(), only for converting<
72
73 SbxWSTRING = 33, // from 2000-10-4 Reimplemented for backwards compatibility (#78919)
74 SbxWCHAR = 34, // from 2000-10-4 Reimplemented for backwards compatibility (#78919)
75 SbxSALINT64 = 35, // for currency internal, signed 64-bit int and UNO hyper
76 SbxSALUINT64= 36, // for currency internal, unsigned 64-bit int and UNO unsigned hyper
77 SbxDECIMAL = 37, // for UNO/automation Decimal
78
79 SbxVECTOR = 0x1000, // simple counted array
80 SbxARRAY = 0x2000, // array
81 SbxBYREF = 0x4000, // access by reference
82
83 // tdf#79426, tdf#125180
84 SbxMISSING = 0x8000, // Parameter is missing
85};
86
87const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000;
88const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000;
89const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible
90const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000;
91
93 // Arithmetical:
94 SbxEXP, // this ^ var
95 SbxMUL, // this * var
96 SbxDIV, // this / var
97 SbxMOD, // this MOD var (max INT32!)
98 SbxPLUS, // this + var
99 SbxMINUS, // this - var
100 SbxNEG, // -this (var is ignored)
101 SbxIDIV, // this / var (both operands max. sal_Int32!)
102 // Boolean operators (max sal_Int32!):
103 // Boolean operators (TODO deprecate this limit: max INT32!)
104 SbxAND, // this & var
105 SbxOR, // this | var
106 SbxXOR, // this ^ var
107 SbxEQV, // ~this ^ var
108 SbxIMP, // ~this | var
109 SbxNOT, // ~this (var is ignored)
110
111 // String concatenation:
112 SbxCAT, // this & var (VBA: this + var)
113
114 // Comparisons:
115 SbxEQ, // this = var
116 SbxNE, // this <> var
117 SbxLT, // this < var
118 SbxGT, // this > var
119 SbxLE, // this <= var
120 SbxGE // this >= var
122
123enum class SbxNameType { // Type of the questioned name of a variable
124 NONE, // plain name
125 CaseInsensitive, // plain name - case insensitive
126 ShortTypes, // Name%(A%,B$)
127};
128
129
130// Flag-Bits:
131enum class SbxFlagBits {
132 NONE = 0x0000,
133 Read = 0x0001, // Read permission
134 Write = 0x0002, // Write permission
135 ReadWrite = 0x0003, // Read/Write permission
136 DontStore = 0x0004, // Don't store object
137 Modified = 0x0008, // Object was changed
138 Fixed = 0x0010, // Fixed data type (SbxVariable)
139 Const = 0x0020, // Definition of const value
140 Optional = 0x0040, // Parameter is optional
141 Hidden = 0x0080, // Element is invisible
142 Invisible = 0x0100, // Element is not found by Find()
143 ExtSearch = 0x0200, // Object is searched completely
144 ExtFound = 0x0400, // Variable was found through extended search
145 GlobalSearch = 0x0800, // Global search via Parents
146 Reserved = 0x1000, // reserved
147 Private = 0x1000, // #110004, #112015, cannot conflict with SbxFlagBits::Reserved
148 NoBroadcast = 0x2000, // No broadcast on Get/Put
149 Reference = 0x4000, // Parameter is Reference (DLL-call)
150 NoModify = 0x8000, // SetModified is suppressed
151 WithEvents = 0x0080, // Same value as unused SbxFlagBits::Hidden
152 DimAsNew = 0x0800, // Same value as SbxFlagBits::GlobalSearch, cannot conflict as one
153 // is used for objects, the other for variables only
154 VarToDim = 0x2000, // Same value as SbxFlagBits::NoBroadcast, cannot conflict as
155 // used for variables without broadcaster only
156};
157namespace o3tl
158{
159 template<> struct typed_flags<SbxFlagBits> : is_typed_flags<SbxFlagBits, 0xffff> {};
160}
161
162// List of all creators for Load/Store
163
164constexpr auto SBXCR_SBX = 0x20584253; // SBX(blank)
165
166// List of predefined SBX-IDs. New SBX-IDs must be precisely defined so that
167// they are unique within the Stream and appropriate Factory.
168
169constexpr auto SBXID_VALUE = 0x4E4E; // NN: SbxValue
170constexpr auto SBXID_VARIABLE = 0x4156; // VA: SbxVariable
171constexpr auto SBXID_ARRAY = 0x5241; // AR: SbxArray
172constexpr auto SBXID_DIMARRAY = 0x4944; // DI: SbxDimArray
173constexpr auto SBXID_OBJECT = 0x424F; // OB: SbxObject
174constexpr auto SBXID_COLLECTION = 0x4F43; // CO: SbxCollection
175constexpr auto SBXID_FIXCOLLECTION = 0x4346; // FC: SbxStdCollection
176constexpr auto SBXID_METHOD = 0x454D; // ME: SbxMethod
177constexpr auto SBXID_PROPERTY = 0x5250; // PR: SbxProperty
178
179// StarBASIC restricts the base data type to different intervals.
180// These intervals are fixed to create 'portability and independent
181// of the implementation. Only type double is greedy and takes
182// what it gets.
183
184constexpr auto SbxMAXCHAR = u'\xFFFF';
185constexpr auto SbxMINCHAR = 0;
186constexpr auto SbxMAXBYTE = 255;
187constexpr auto SbxMAXINT = 32767;
188constexpr auto SbxMININT = -32768;
189constexpr sal_uInt16 SbxMAXUINT = 65535;
190constexpr auto SbxMAXLNG = 2147483647;
191constexpr sal_Int32 SbxMINLNG = -2147483647-1;
192constexpr sal_uInt32 SbxMAXULNG = 0xffffffff;
193
194 // Currency stored as SbxSALINT64 == sal_Int64
195 // value range limits are ~(2^63 - 1)/10000
196 // fixed precision has 4 digits right of decimal pt
197constexpr auto CURRENCY_FACTOR = 10000;
198constexpr auto CURRENCY_FACTOR_SQUARE = 100000000;
199
200// TODO effective MAX/MINCURR limits:
201// true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double
202constexpr auto SbxMAXCURR = 922337203685477.5807;
203constexpr auto SbxMINCURR = -922337203685477.5808;
204
205constexpr auto SbxMAXSNG = 3.402823e+38;
206constexpr auto SbxMINSNG = -3.402823e+38;
207constexpr auto SbxMAXSNG2 = 1.175494351e-38;
208constexpr auto SbxMINSNG2 = -1.175494351e-38;
209
210// Max valid offset index of a Sbx-Array (due to 64K limit)
211constexpr auto SBX_MAXINDEX = 0x3FF0;
212constexpr auto SBX_MAXINDEX32 = SbxMAXLNG;
213
214// The numeric values of sal_True and FALSE
215enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 };
216
217#endif
218
219/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
float u
NONE
Value
Reference
Array
Invisible
constexpr auto SbxMINSNG2
Definition: sbxdef.hxx:208
SbxNameType
Definition: sbxdef.hxx:123
constexpr auto SbxMAXSNG2
Definition: sbxdef.hxx:207
constexpr sal_uInt32 SbxMAXULNG
Definition: sbxdef.hxx:192
constexpr auto SbxMINSNG
Definition: sbxdef.hxx:206
constexpr auto SBXID_PROPERTY
Definition: sbxdef.hxx:177
constexpr auto SBXID_VARIABLE
Definition: sbxdef.hxx:170
constexpr auto SBXID_ARRAY
Definition: sbxdef.hxx:171
constexpr auto SbxMINCURR
Definition: sbxdef.hxx:203
constexpr auto SbxMAXLNG
Definition: sbxdef.hxx:190
constexpr sal_Int32 SbxMINLNG
Definition: sbxdef.hxx:191
SbxBOOL
Definition: sbxdef.hxx:215
@ SbxFALSE
Definition: sbxdef.hxx:215
@ SbxTRUE
Definition: sbxdef.hxx:215
constexpr auto SBXID_METHOD
Definition: sbxdef.hxx:176
constexpr auto SbxMAXCHAR
Definition: sbxdef.hxx:184
constexpr auto SbxMAXINT
Definition: sbxdef.hxx:187
constexpr auto SbxMAXCURR
Definition: sbxdef.hxx:202
constexpr auto SBXID_VALUE
Definition: sbxdef.hxx:169
constexpr auto SBXID_FIXCOLLECTION
Definition: sbxdef.hxx:175
const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG
Definition: sbxdef.hxx:88
constexpr sal_uInt16 SbxMAXUINT
Definition: sbxdef.hxx:189
const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG
Definition: sbxdef.hxx:87
constexpr auto CURRENCY_FACTOR_SQUARE
Definition: sbxdef.hxx:198
const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG
Definition: sbxdef.hxx:90
SbxOperator
Definition: sbxdef.hxx:92
@ SbxMOD
Definition: sbxdef.hxx:97
@ SbxAND
Definition: sbxdef.hxx:104
@ SbxGT
Definition: sbxdef.hxx:118
@ SbxGE
Definition: sbxdef.hxx:120
@ SbxEQ
Definition: sbxdef.hxx:115
@ SbxLT
Definition: sbxdef.hxx:117
@ SbxNEG
Definition: sbxdef.hxx:100
@ SbxMUL
Definition: sbxdef.hxx:95
@ SbxPLUS
Definition: sbxdef.hxx:98
@ SbxIMP
Definition: sbxdef.hxx:108
@ SbxXOR
Definition: sbxdef.hxx:106
@ SbxCAT
Definition: sbxdef.hxx:112
@ SbxOR
Definition: sbxdef.hxx:105
@ SbxEQV
Definition: sbxdef.hxx:107
@ SbxIDIV
Definition: sbxdef.hxx:101
@ SbxNE
Definition: sbxdef.hxx:116
@ SbxNOT
Definition: sbxdef.hxx:109
@ SbxMINUS
Definition: sbxdef.hxx:99
@ SbxDIV
Definition: sbxdef.hxx:96
@ SbxLE
Definition: sbxdef.hxx:119
@ SbxEXP
Definition: sbxdef.hxx:94
const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG
Definition: sbxdef.hxx:89
SbxDataType
Definition: sbxdef.hxx:37
@ SbxOBJECT
Definition: sbxdef.hxx:47
@ SbxSALINT64
Definition: sbxdef.hxx:75
@ SbxLONG
Definition: sbxdef.hxx:41
@ SbxVECTOR
Definition: sbxdef.hxx:79
@ SbxCARRAY
Definition: sbxdef.hxx:66
@ SbxARRAY
Definition: sbxdef.hxx:80
@ SbxSALUINT64
Definition: sbxdef.hxx:76
@ SbxHRESULT
Definition: sbxdef.hxx:63
@ SbxNULL
Definition: sbxdef.hxx:39
@ SbxDIMARRAY
Definition: sbxdef.hxx:65
@ SbxBYTE
Definition: sbxdef.hxx:55
@ SbxEMPTY
Definition: sbxdef.hxx:38
@ SbxWCHAR
Definition: sbxdef.hxx:74
@ SbxMISSING
Definition: sbxdef.hxx:84
@ SbxUINT
Definition: sbxdef.hxx:60
@ SbxUSERDEF
Definition: sbxdef.hxx:67
@ SbxDECIMAL
Definition: sbxdef.hxx:77
@ SbxVOID
Definition: sbxdef.hxx:62
@ SbxLPWSTR
Definition: sbxdef.hxx:70
@ SbxULONG
Definition: sbxdef.hxx:57
@ SbxUSHORT
Definition: sbxdef.hxx:56
@ SbxERROR
Definition: sbxdef.hxx:48
@ SbxDATE
Definition: sbxdef.hxx:45
@ SbxPOINTER
Definition: sbxdef.hxx:64
@ SbxCURRENCY
Definition: sbxdef.hxx:44
@ SbxLPSTR
Definition: sbxdef.hxx:68
@ SbxVARIANT
Definition: sbxdef.hxx:51
@ SbxINT
Definition: sbxdef.hxx:59
@ SbxWSTRING
Definition: sbxdef.hxx:73
@ SbxDATAOBJECT
Definition: sbxdef.hxx:52
@ SbxSINGLE
Definition: sbxdef.hxx:42
@ SbxCoreSTRING
Definition: sbxdef.hxx:71
@ SbxBYREF
Definition: sbxdef.hxx:81
@ SbxCHAR
Definition: sbxdef.hxx:54
@ SbxSTRING
Definition: sbxdef.hxx:46
@ SbxINTEGER
Definition: sbxdef.hxx:40
@ SbxDOUBLE
Definition: sbxdef.hxx:43
constexpr auto SBX_MAXINDEX32
Definition: sbxdef.hxx:212
SbxClassType
Definition: sbxdef.hxx:27
constexpr auto SBXID_COLLECTION
Definition: sbxdef.hxx:174
SbxFlagBits
Definition: sbxdef.hxx:131
constexpr auto SBXID_OBJECT
Definition: sbxdef.hxx:173
constexpr auto SbxMINCHAR
Definition: sbxdef.hxx:185
constexpr auto CURRENCY_FACTOR
Definition: sbxdef.hxx:197
constexpr auto SBX_MAXINDEX
Definition: sbxdef.hxx:211
constexpr auto SBXCR_SBX
Definition: sbxdef.hxx:164
constexpr auto SbxMAXBYTE
Definition: sbxdef.hxx:186
constexpr auto SbxMAXSNG
Definition: sbxdef.hxx:205
constexpr auto SbxMININT
Definition: sbxdef.hxx:188
constexpr auto SBXID_DIMARRAY
Definition: sbxdef.hxx:172
Method