LibreOffice Module svl (master) 1
zforlist.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#ifndef INCLUDED_SVL_ZFORLIST_HXX
20#define INCLUDED_SVL_ZFORLIST_HXX
21
22#include <config_options.h>
23#include <svl/svldllapi.h>
24#include <rtl/ustrbuf.hxx>
25#include <rtl/ustring.hxx>
27#include <i18nlangtag/lang.h>
28#include <com/sun/star/util/NumberFormat.hpp>
30
31#include <map>
32#include <unordered_map>
33
34namespace com::sun::star::i18n { struct Currency; }
35
36class SvNumberformat;
37
38#define SV_COUNTRY_LANGUAGE_OFFSET 10000 // Max count of formats per country/language
39#define SV_MAX_COUNT_STANDARD_FORMATS 100 // Max count of builtin default formats per CL
40
41constexpr size_t NF_MAX_FORMAT_SYMBOLS = 100;
42
46
47constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND = 0xffffffff;
48
49enum class SvNumFormatType : sal_Int16
50{
53 ALL = css::util::NumberFormat::ALL, // 0
56 DEFINED = css::util::NumberFormat::DEFINED, // 1
59 DATE = css::util::NumberFormat::DATE, // 2
62 TIME = css::util::NumberFormat::TIME, // 4
65 CURRENCY = css::util::NumberFormat::CURRENCY, // 8
68 NUMBER = css::util::NumberFormat::NUMBER, // 16
71 SCIENTIFIC = css::util::NumberFormat::SCIENTIFIC, // 32
74 FRACTION = css::util::NumberFormat::FRACTION, // 64
77 PERCENT = css::util::NumberFormat::PERCENT, // 128
80 TEXT = css::util::NumberFormat::TEXT, // 256
83 DATETIME = DATE | TIME, // 6
86 LOGICAL = css::util::NumberFormat::LOGICAL, // 1024
89 UNDEFINED = css::util::NumberFormat::UNDEFINED, // 2048
93 EMPTY = css::util::NumberFormat::EMPTY, // 4096
98 DURATION = css::util::NumberFormat::DURATION, // 8196
99};
100namespace o3tl {
101 template<> struct typed_flags<SvNumFormatType> : is_typed_flags<SvNumFormatType, 0x3dff> {};
102}
103
124{
126
128 NF_NUMBER_STANDARD = NF_NUMBER_START, // Standard/General
133 NF_NUMBER_SYSTEM, // #,##0.00 or whatever is set in System Regional Settings
135
140
145
148 NF_FRACTION_2D, // # ??/??
150
152
155 NF_CURRENCY_1000DEC2, // #,##0.00 DM
156 NF_CURRENCY_1000INT_RED, // #,##0 DM negative in red
157 NF_CURRENCY_1000DEC2_RED, // #,##0.00 DM negative in red
158 NF_CURRENCY_1000DEC2_CCC, // #,##0.00 DEM currency abbreviation
161
164 NF_DATE_SYSTEM_LONG, // Wednesday, 8. October 1997
166 NF_DATE_SYS_DDMMYYYY, // 08.10.1997 THE edit format, formatindex="21"
167 NF_DATE_SYS_DMMMYY, // 8. Oct 97
168 NF_DATE_SYS_DMMMYYYY, // 8. Oct 1997
169 NF_DATE_DIN_DMMMYYYY, // 8. Oct. 1997 DIN
170 NF_DATE_SYS_DMMMMYYYY, // 8. October 1997
171 NF_DATE_DIN_DMMMMYYYY, // 8. October 1997 DIN
172 NF_DATE_SYS_NNDMMMYY, // Wed, 8. Okt 97
173 NF_DATE_DEF_NNDDMMMYY, // Wed 08.Okt 97
174 NF_DATE_SYS_NNDMMMMYYYY, // Wed, 8. Oktober 1997
175 NF_DATE_SYS_NNNNDMMMMYYYY, // Wednesday, 8. Oktober 1997
176 NF_DATE_DIN_MMDD, // 10-08 DIN
177 NF_DATE_DIN_YYMMDD, // 97-10-08 DIN
178 NF_DATE_DIN_YYYYMMDD, // 1997-10-08 DIN
179 NF_DATE_ISO_YYYYMMDD = NF_DATE_DIN_YYYYMMDD, // 1997-10-08 ISO clarify with name, formatindex="33"
182 NF_DATE_MMMM, // October
183 NF_DATE_QQJJ, // 4. Quarter 97
184 NF_DATE_WW, // week of year
186
189 NF_TIME_HHMMSS, // HH:MM:SS
190 NF_TIME_HHMMAMPM, // HH:MM AM/PM
191 NF_TIME_HHMMSSAMPM, // HH:MM:SS AM/PM
192 NF_TIME_HH_MMSS, // [HH]:MM:SS formatindex="43"
193 NF_TIME_MMSS00, // MM:SS,00 formatindex="44"
194 NF_TIME_HH_MMSS00, // [HH]:MM:SS,00 formatindex="45"
196
199 NF_DATETIME_SYS_DDMMYYYY_HHMMSS, // 08.10.1997 01:23:45 THE edit format, formatindex="47"
201
202 NF_BOOLEAN, // BOOLEAN
204
205 NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // == 50, old number of predefined entries, i18npool locale data additions start after this
206
207 // From here on are values of new predefined and built-in formats that are
208 // not in the original NumberFormatIndex.idl
209
210 // XXX Values appended here must also get a corresponding entry in
211 // svl/source/numbers/zforlist.cxx indexTable[] in the same order.
212
213 // XXX The dialog's number format shell assumes start/end spans
214 // (NF_..._START and NF_..._END above) to fill its categories with builtin
215 // formats, make new formats known to svx/source/items/numfmtsh.cxx
216 // SvxNumberFormatShell::FillEListWithStd_Impl(), otherwise they will not
217 // be listed at all. Yes that is ugly.
218 // DATETIME formats need to be added to
219 // SvxNumberFormatShell::FillEListWithDateTime_Impl().
220
221 // New predefined format added to i18npool locale data.
223
224 // No i18npool defined locale data between here and NF_INDEX_TABLE_ENTRIES.
226
231 NF_FRACTION_16, // # ??/16
232 NF_FRACTION_10, // # ??/10
233 NF_FRACTION_100, // # ??/100
234
235 NF_DATETIME_ISO_YYYYMMDD_HHMMSS, // 1997-10-08 01:23:45 ISO (with blank instead of T)
236 NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, // 1997-10-08 01:23:45.678 not quite ISO with locale's separator
237 NF_DATETIME_ISO_YYYYMMDDTHHMMSS, // 1997-10-08T01:23:45 ISO
238 NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, // 1997-10-08T01:23:45,678 ISO with milliseconds and ',' or '.'
239
240 // XXX When adding values here, follow the comment above about
241 // svx/source/items/numfmtsh.cxx
242
243 NF_INDEX_TABLE_ENTRIES // == 62, reserved to not be used in i18npool locale data.
244
245 // XXX Adding values above may increment the reserved area that can't be
246 // used by i18npool's locale data FormatCode definitions, see the
247 // description at i18npool/source/localedata/data/locale.dtd for ELEMENT
248 // FormatCode what the current convention's value is. In that case, the
249 // used formatIndex values in i18npool/source/localedata/data/*.xml will
250 // have to be adjusted.
251 // Overlapping the area will bail out with a check in
252 // SvNumberFormatter::ImpInsertFormat() in debug builds.
254
255
256// #45717# IsNumberFormat( "98-10-24", 30, x ), YMD Format set with DMY
257// International settings doesn't recognize the string as a date.
265{
268
272
276
281
282
286typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable;
287typedef std::unordered_map<sal_uInt16, sal_uInt32> SvNumberFormatterIndexTable;
288typedef std::unordered_map< sal_uInt32, sal_uInt32> SvNumberFormatterMergeMap;
289
290
293class UNLESS_MERGELIBS(SVL_DLLPUBLIC) NfCurrencyEntry final
294{
295 OUString aSymbol;
296 OUString aBankSymbol;
297 LanguageType eLanguage;
298 sal_uInt16 nPositiveFormat;
299 sal_uInt16 nNegativeFormat;
300 sal_uInt16 nDigits;
301 sal_Unicode cZeroChar;
302
303private:
304
305 // nDecimalFormat := 0, 1, 2
306 // #,##0 or #,##0.00 or #,##0.-- is returned
307 SVL_DLLPRIVATE OUString Impl_BuildFormatStringNumChars( const LocaleDataWrapper&, sal_uInt16 nDecimalFormat) const;
308
309public:
310
311 NfCurrencyEntry( const LocaleDataWrapper& rLocaleData,
312 LanguageType eLang );
313 NfCurrencyEntry( const css::i18n::Currency & rCurr,
314 const LocaleDataWrapper& rLocaleData,
315 LanguageType eLang );
316
318 bool operator==( const NfCurrencyEntry& r ) const;
319
320 const OUString& GetSymbol() const { return aSymbol; }
321 const OUString& GetBankSymbol() const { return aBankSymbol; }
322 LanguageType GetLanguage() const { return eLanguage; }
323 sal_uInt16 GetPositiveFormat() const { return nPositiveFormat; }
324 sal_uInt16 GetNegativeFormat() const { return nNegativeFormat; }
325 sal_uInt16 GetDigits() const { return nDigits; }
326
328 void SetLanguage( LanguageType nLang ) { eLanguage = nLang; }
329
333 OUString BuildSymbolString(bool bBank, bool bWithoutExtension = false) const;
334
337 OUString BuildPositiveFormatString(bool bBank, const LocaleDataWrapper&,
338 sal_uInt16 nDecimalFormat = 1) const;
339 OUString BuildNegativeFormatString(bool bBank, const LocaleDataWrapper&,
340 sal_uInt16 nDecimalFormat = 1) const;
341
344 void CompletePositiveFormatString(OUStringBuffer& rStr, bool bBank,
345 sal_uInt16 nPosiFormat) const;
346 void CompleteNegativeFormatString(OUStringBuffer& rStr, bool bBank,
347 sal_uInt16 nNegaFormat) const;
348
350 static void CompletePositiveFormatString(OUStringBuffer& rStr,
351 std::u16string_view rSymStr, sal_uInt16 nPosiFormat);
352 static void CompleteNegativeFormatString(OUStringBuffer& rStr,
353 std::u16string_view rSymStr, sal_uInt16 nNegaFormat);
354
357 static sal_uInt16 GetEffectivePositiveFormat( sal_uInt16 nIntlFormat,
358 sal_uInt16 nCurrFormat, bool bBank );
359 static sal_uInt16 GetEffectiveNegativeFormat( sal_uInt16 nIntlFormat,
360 sal_uInt16 nCurrFormat, bool bBank );
361
363 static sal_Unicode GetEuroSymbol() { return u'\x20AC'; }
364};
365
366typedef std::vector< OUString > NfWSStringsDtor;
367
369enum class SvNumInputOptions : sal_uInt16
370{
371 NONE = 0,
372 LAX_TIME = 1
373};
374namespace o3tl {
375 template<> struct typed_flags<SvNumInputOptions> : is_typed_flags<SvNumInputOptions, 0x0001> {};
376}
377
378
379#endif // INCLUDED_SVL_ZFORLIST_HXX
380
381/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
float u
void SetLanguage(SwWrtShell &rWrtSh, std::u16string_view rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
NONE
DATE
constexpr OUStringLiteral EMPTY
#define SVL_DLLPRIVATE
Definition: svldllapi.h:30
TEXT
constexpr bool operator==(TypedWhichId< T > const &lhs, TypedWhichId< T > rhs)
Definition: typedwhich.hxx:43
sal_uInt16 sal_Unicode
constexpr OUStringLiteral PERCENT(u"Percent")
std::vector< OUString > NfWSStringsDtor
Definition: zforlist.hxx:364
std::unordered_map< sal_uInt16, sal_uInt32 > SvNumberFormatterIndexTable
Definition: zforlist.hxx:287
constexpr size_t NF_MAX_FORMAT_SYMBOLS
Definition: zforlist.hxx:41
std::map< sal_uInt32, SvNumberformat * > SvNumberFormatTable
This table is std::map because it needs to preserve insertion order, because the formats are roughly ...
Definition: zforlist.hxx:286
constexpr sal_uInt32 NF_STANDARD_FORMAT_TEXT
The built-in @ Text format, offset within a locale, key in the locale the number formatter was constr...
Definition: zforlist.hxx:45
SvNumFormatType
MAX_ULONG.
Definition: zforlist.hxx:50
@ UNDEFINED
is used as a return value if no format exists.
@ NUMBER
selects decimal number formats.
@ LOGICAL
selects boolean number formats.
@ CURRENCY
selects currency formats.
@ FRACTION
selects number formats for fractions.
@ SCIENTIFIC
selects scientific number formats.
@ DEFINED
selects only user-defined number formats.
std::unordered_map< sal_uInt32, sal_uInt32 > SvNumberFormatterMergeMap
Definition: zforlist.hxx:288
NfEvalDateFormat
enum values for <method>SvNumberFormatter::SetEvalDateFormat</method>
Definition: zforlist.hxx:265
@ NF_EVALDATEFORMAT_INTL_FORMAT
First try the DateFormat from International.
Definition: zforlist.hxx:275
@ NF_EVALDATEFORMAT_INTL
DateFormat only from International, default.
Definition: zforlist.hxx:267
@ NF_EVALDATEFORMAT_FORMAT
DateFormat only from date format passed to function (if any).
Definition: zforlist.hxx:271
@ NF_EVALDATEFORMAT_FORMAT_INTL
First try the DateFormat from the date format passed.
Definition: zforlist.hxx:279
NfIndexTableOffset
enum values for <method>SvNumberFormatter::GetFormatIndex</method>
Definition: zforlist.hxx:124
@ NF_FRACTION_2
Definition: zforlist.hxx:228
@ NF_TIME_END
Definition: zforlist.hxx:195
@ NF_FRACTION_3D
Definition: zforlist.hxx:227
@ NF_SCIENTIFIC_START
Definition: zforlist.hxx:136
@ NF_DATE_SYSTEM_SHORT
Definition: zforlist.hxx:163
@ NF_SCIENTIFIC_000E00
Definition: zforlist.hxx:138
@ NF_DATETIME_START
Definition: zforlist.hxx:197
@ NF_TIME_HHMMSSAMPM
Definition: zforlist.hxx:191
@ NF_DATETIME_SYS_DDMMYYYY_HHMMSS
Definition: zforlist.hxx:199
@ NF_DATETIME_ISO_YYYYMMDDTHHMMSS000
Definition: zforlist.hxx:238
@ NF_DATE_SYS_DMMMYY
Definition: zforlist.hxx:167
@ NF_DATE_SYS_MMYY
Definition: zforlist.hxx:180
@ NF_CURRENCY_1000DEC2_RED
Definition: zforlist.hxx:157
@ NF_INDEX_TABLE_RESERVED_START
Definition: zforlist.hxx:225
@ NF_TIME_HHMMAMPM
Definition: zforlist.hxx:190
@ NF_DATE_SYS_DMMMMYYYY
Definition: zforlist.hxx:170
@ NF_TIME_MMSS00
Definition: zforlist.hxx:193
@ NF_DATE_DIN_DMMMYYYY
Definition: zforlist.hxx:169
@ NF_NUMBER_DEC2
Definition: zforlist.hxx:130
@ NF_TIME_HH_MMSS00
Definition: zforlist.hxx:194
@ NF_DATE_DIN_MMDD
Definition: zforlist.hxx:176
@ NF_CURRENCY_1000DEC2_DASHED
Definition: zforlist.hxx:159
@ NF_DATE_WW
Definition: zforlist.hxx:184
@ NF_DATE_SYS_DDMMM
Definition: zforlist.hxx:181
@ NF_DATETIME_ISO_YYYYMMDD_HHMMSS000
Definition: zforlist.hxx:236
@ NF_DATE_END
Definition: zforlist.hxx:185
@ NF_DATE_ISO_YYYYMMDD
Definition: zforlist.hxx:179
@ NF_SCIENTIFIC_END
Definition: zforlist.hxx:139
@ NF_NUMBER_END
Definition: zforlist.hxx:134
@ NF_DATE_SYS_NNNNDMMMMYYYY
Definition: zforlist.hxx:175
@ NF_FRACTION_10
Definition: zforlist.hxx:232
@ NF_FRACTION_END
Definition: zforlist.hxx:149
@ NF_FRACTION_START
Definition: zforlist.hxx:146
@ NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS
Definition: zforlist.hxx:205
@ NF_NUMBER_SYSTEM
Definition: zforlist.hxx:133
@ NF_DATE_SYS_NNDMMMYY
Definition: zforlist.hxx:172
@ NF_CURRENCY_START
Definition: zforlist.hxx:153
@ NF_TEXT
Definition: zforlist.hxx:203
@ NF_CURRENCY_1000DEC2
Definition: zforlist.hxx:155
@ NF_INDEX_TABLE_ENTRIES
Definition: zforlist.hxx:243
@ NF_BOOLEAN
Definition: zforlist.hxx:202
@ NF_DATE_DIN_DMMMMYYYY
Definition: zforlist.hxx:171
@ NF_CURRENCY_END
Definition: zforlist.hxx:160
@ NF_TIME_START
Definition: zforlist.hxx:187
@ NF_FRACTION_8
Definition: zforlist.hxx:230
@ NF_DATE_SYS_DDMMYY
Definition: zforlist.hxx:165
@ NF_NUMBER_STANDARD
Definition: zforlist.hxx:128
@ NF_NUMBER_1000DEC2
Definition: zforlist.hxx:132
@ NF_PERCENT_DEC2
Definition: zforlist.hxx:143
@ NF_DATE_QQJJ
Definition: zforlist.hxx:183
@ NF_DATE_DIN_YYMMDD
Definition: zforlist.hxx:177
@ NF_TIME_HHMM
Definition: zforlist.hxx:188
@ NF_DATE_DEF_NNDDMMMYY
Definition: zforlist.hxx:173
@ NF_NUMBER_INT
Definition: zforlist.hxx:129
@ NF_PERCENT_START
Definition: zforlist.hxx:141
@ NF_CURRENCY_1000INT_RED
Definition: zforlist.hxx:156
@ NF_TIME_HH_MMSS
Definition: zforlist.hxx:192
@ NF_NUMERIC_END
Definition: zforlist.hxx:151
@ NF_DATE_SYS_DMMMYYYY
Definition: zforlist.hxx:168
@ NF_FRACTION_1D
Definition: zforlist.hxx:147
@ NF_DATE_DIN_YYYYMMDD
Definition: zforlist.hxx:178
@ NF_CURRENCY_1000INT
Definition: zforlist.hxx:154
@ NF_FRACTION_4
Definition: zforlist.hxx:229
@ NF_DATE_START
Definition: zforlist.hxx:162
@ NF_DATETIME_SYS_DDMMYYYY_HHMM
Definition: zforlist.hxx:222
@ NF_DATE_MMMM
Definition: zforlist.hxx:182
@ NF_TIME_HHMMSS
Definition: zforlist.hxx:189
@ NF_DATE_SYS_NNDMMMMYYYY
Definition: zforlist.hxx:174
@ NF_PERCENT_INT
Definition: zforlist.hxx:142
@ NF_DATETIME_END
Definition: zforlist.hxx:200
@ NF_PERCENT_END
Definition: zforlist.hxx:144
@ NF_SCIENTIFIC_000E000
Definition: zforlist.hxx:137
@ NF_DATETIME_ISO_YYYYMMDD_HHMMSS
Definition: zforlist.hxx:235
@ NF_CURRENCY_1000DEC2_CCC
Definition: zforlist.hxx:158
@ NF_DATE_SYS_DDMMYYYY
Definition: zforlist.hxx:166
@ NF_NUMERIC_START
Definition: zforlist.hxx:125
@ NF_NUMBER_1000INT
Definition: zforlist.hxx:131
@ NF_FRACTION_2D
Definition: zforlist.hxx:148
@ NF_FRACTION_16
Definition: zforlist.hxx:231
@ NF_NUMBER_START
Definition: zforlist.hxx:127
@ NF_DATETIME_ISO_YYYYMMDDTHHMMSS
Definition: zforlist.hxx:237
@ NF_FRACTION_100
Definition: zforlist.hxx:233
@ NF_DATETIME_SYSTEM_SHORT_HHMM
Definition: zforlist.hxx:198
@ NF_DATE_SYSTEM_LONG
Definition: zforlist.hxx:164
SvNumInputOptions
Input options to be used with IsNumberFormat()
Definition: zforlist.hxx:370
@ LAX_TIME
allow input of minutes or seconds >59
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
Definition: zforlist.hxx:47
#define SV_MAX_COUNT_STANDARD_FORMATS
Definition: zforlist.hxx:39