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 #include <o3tl/typed_flags_set.hxx> 25 #include <sal/types.h> 26 27 enum 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 37 enum SbxDataType { 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 87 const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; 88 const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000; 89 const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible 90 const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000; 91 92 enum SbxOperator { 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 121 }; 122 123 enum 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: 131 enum 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 }; 157 namespace o3tl 158 { 159 template<> struct typed_flags<SbxFlagBits> : is_typed_flags<SbxFlagBits, 0xffff> {}; 160 } 161 162 // List of all creators for Load/Store 163 164 constexpr 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 169 constexpr auto SBXID_VALUE = 0x4E4E; // NN: SbxValue 170 constexpr auto SBXID_VARIABLE = 0x4156; // VA: SbxVariable 171 constexpr auto SBXID_ARRAY = 0x5241; // AR: SbxArray 172 constexpr auto SBXID_DIMARRAY = 0x4944; // DI: SbxDimArray 173 constexpr auto SBXID_OBJECT = 0x424F; // OB: SbxObject 174 constexpr auto SBXID_COLLECTION = 0x4F43; // CO: SbxCollection 175 constexpr auto SBXID_FIXCOLLECTION = 0x4346; // FC: SbxStdCollection 176 constexpr auto SBXID_METHOD = 0x454D; // ME: SbxMethod 177 constexpr 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 184 constexpr auto SbxMAXCHAR = u'\xFFFF'; 185 constexpr auto SbxMINCHAR = 0; 186 constexpr auto SbxMAXBYTE = 255; 187 constexpr auto SbxMAXINT = 32767; 188 constexpr auto SbxMININT = -32768; 189 constexpr sal_uInt16 SbxMAXUINT = 65535; 190 constexpr auto SbxMAXLNG = 2147483647; 191 constexpr sal_Int32 SbxMINLNG = -2147483647-1; 192 constexpr 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 197 constexpr auto CURRENCY_FACTOR = 10000; 198 constexpr 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 202 constexpr auto SbxMAXCURR = 922337203685477.5807; 203 constexpr auto SbxMINCURR = -922337203685477.5808; 204 205 constexpr auto SbxMAXSNG = 3.402823e+38; 206 constexpr auto SbxMINSNG = -3.402823e+38; 207 constexpr auto SbxMAXSNG2 = 1.175494351e-38; 208 constexpr auto SbxMINSNG2 = -1.175494351e-38; 209 210 // Max valid offset index of a Sbx-Array (due to 64K limit) 211 constexpr auto SBX_MAXINDEX = 0x3FF0; 212 constexpr auto SBX_MAXINDEX32 = SbxMAXLNG; 213 214 // The numeric values of sal_True and FALSE 215 enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 }; 216 217 #endif 218 219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 220
