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