Line data Source code
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 _ZFORLIST_HXX
20 : #define _ZFORLIST_HXX
21 :
22 : #include "svl/svldllapi.h"
23 : #include <rtl/ustrbuf.hxx>
24 : #include <rtl/ustring.hxx>
25 : #include <tools/solar.h>
26 : #include <i18nlangtag/lang.h>
27 : #include <com/sun/star/uno/Reference.hxx>
28 : #include <com/sun/star/lang/Locale.hpp>
29 : #include <com/sun/star/i18n/NumberFormatCode.hpp>
30 : #include <unotools/localedatawrapper.hxx>
31 : #include <unotools/numberformatcodewrapper.hxx>
32 : #include <tools/link.hxx>
33 : #include <svl/ondemand.hxx>
34 : #include <svl/nfkeytab.hxx>
35 :
36 : #include <map>
37 : #include <set>
38 : #include <boost/ptr_container/ptr_vector.hpp>
39 :
40 : class Date;
41 : class SvStream;
42 : class Color;
43 : class CharClass;
44 : class CalendarWrapper;
45 :
46 : class ImpSvNumberformatScan;
47 : class ImpSvNumberInputScan;
48 : class SvNumberformat;
49 :
50 : namespace com { namespace sun { namespace star {
51 : namespace uno {
52 : class XComponentContext;
53 : }
54 : }}}
55 :
56 : #define SV_COUNTRY_LANGUAGE_OFFSET 10000 // Max count of formats per country/language
57 : #define SV_MAX_ANZ_STANDARD_FORMATE 100 // Max count of builtin default formats per CL
58 :
59 : // Format types
60 : #ifndef NUMBERFORMAT_ALL
61 : // also defined in com/sun/star/util/NumberFormat.hpp
62 : //! => put in single .idl file and include here
63 : #define NUMBERFORMAT_ALL 0x000 /// Just for Output of total list, not a real format type
64 : #define NUMBERFORMAT_DEFINED 0x001 /// Format defined by user
65 : #define NUMBERFORMAT_DATE 0x002 /// Number as date
66 : #define NUMBERFORMAT_TIME 0x004 /// Number as time
67 : #define NUMBERFORMAT_CURRENCY 0x008 /// Number as currency
68 : #define NUMBERFORMAT_NUMBER 0x010 /// Any "normal" number format
69 : #define NUMBERFORMAT_SCIENTIFIC 0x020 /// Number as scientific
70 : #define NUMBERFORMAT_FRACTION 0x040 /// Number as fraction
71 : #define NUMBERFORMAT_PERCENT 0x080 /// Number as percent
72 : #define NUMBERFORMAT_TEXT 0x100 /// Text format
73 : #define NUMBERFORMAT_DATETIME 0x006 /// Number as date and time
74 : #define NUMBERFORMAT_LOGICAL 0x400 /// Number as boolean value
75 : #define NUMBERFORMAT_UNDEFINED 0x800 /// Format undefined yet in analyzing
76 : #endif
77 : #define NUMBERFORMAT_ENTRY_NOT_FOUND (sal_uInt32)(0xffffffff) /// MAX_ULONG
78 :
79 :
80 : /** enum values for <method>SvNumberFormatter::GetFormatIndex</method>
81 :
82 : <p>
83 : Builtin standard formats, order should be also the arrangement in the
84 : dialog list box representation.</p>
85 :
86 : <p>
87 : Date specials:<ul>
88 : <li>SYSTEM: As set in System Regional Settings.
89 : <li>SYS: short/long defined, order and separators from System Regional Settings.
90 : <li>DEF: short/long and order defined, separators from System Regional Settings.
91 : <li>DIN: all settings hard coded as DIN (Deutsche Industrie Norm) and EN (European Norm) require.
92 : <li>all other: hard coded
93 : </ul>
94 :
95 : Do NOT insert any new values!
96 : The values here correspond with those in offapi/com/sun/star/i18n/NumberFormatIndex.idl
97 : */
98 : enum NfIndexTableOffset
99 : {
100 : NF_NUMERIC_START = 0,
101 :
102 : NF_NUMBER_START = NF_NUMERIC_START,
103 : NF_NUMBER_STANDARD = NF_NUMBER_START, // Standard/General
104 : NF_NUMBER_INT, // 0
105 : NF_NUMBER_DEC2, // 0.00
106 : NF_NUMBER_1000INT, // #,##0
107 : NF_NUMBER_1000DEC2, // #,##0.00
108 : NF_NUMBER_SYSTEM, // #,##0.00 or whatever is set in System Regional Settings
109 : NF_NUMBER_END = NF_NUMBER_SYSTEM,
110 :
111 : NF_SCIENTIFIC_START,
112 : NF_SCIENTIFIC_000E000 = NF_SCIENTIFIC_START, // 0.00E+000
113 : NF_SCIENTIFIC_000E00, // 0.00E+00
114 : NF_SCIENTIFIC_END = NF_SCIENTIFIC_000E00,
115 :
116 : NF_PERCENT_START,
117 : NF_PERCENT_INT = NF_PERCENT_START, // 0%
118 : NF_PERCENT_DEC2, // 0.00%
119 : NF_PERCENT_END = NF_PERCENT_DEC2,
120 :
121 : NF_FRACTION_START,
122 : NF_FRACTION_1 = NF_FRACTION_START, // # ?/?
123 : NF_FRACTION_2, // # ??/??
124 : NF_FRACTION_END = NF_FRACTION_2,
125 :
126 : NF_NUMERIC_END = NF_FRACTION_END,
127 :
128 : NF_CURRENCY_START,
129 : NF_CURRENCY_1000INT = NF_CURRENCY_START,// #,##0 DM
130 : NF_CURRENCY_1000DEC2, // #,##0.00 DM
131 : NF_CURRENCY_1000INT_RED, // #,##0 DM negative in red
132 : NF_CURRENCY_1000DEC2_RED, // #,##0.00 DM negative in red
133 : NF_CURRENCY_1000DEC2_CCC, // #,##0.00 DEM currency abbreviation
134 : NF_CURRENCY_1000DEC2_DASHED, // #,##0.-- DM
135 : NF_CURRENCY_END = NF_CURRENCY_1000DEC2_DASHED,
136 :
137 : NF_DATE_START,
138 : NF_DATE_SYSTEM_SHORT = NF_DATE_START, // 08.10.97
139 : NF_DATE_SYSTEM_LONG, // Wednesday, 8. October 1997
140 : NF_DATE_SYS_DDMMYY, // 08.10.97
141 : NF_DATE_SYS_DDMMYYYY, // 08.10.1997
142 : NF_DATE_SYS_DMMMYY, // 8. Oct 97
143 : NF_DATE_SYS_DMMMYYYY, // 8. Oct 1997
144 : NF_DATE_DIN_DMMMYYYY, // 8. Oct. 1997 DIN
145 : NF_DATE_SYS_DMMMMYYYY, // 8. October 1997
146 : NF_DATE_DIN_DMMMMYYYY, // 8. October 1997 DIN
147 : NF_DATE_SYS_NNDMMMYY, // Wed, 8. Okt 97
148 : NF_DATE_DEF_NNDDMMMYY, // Wed 08.Okt 97
149 : NF_DATE_SYS_NNDMMMMYYYY, // Wed, 8. Oktober 1997
150 : NF_DATE_SYS_NNNNDMMMMYYYY, // Wednesday, 8. Oktober 1997
151 : NF_DATE_DIN_MMDD, // 10-08 DIN
152 : NF_DATE_DIN_YYMMDD, // 97-10-08 DIN
153 : NF_DATE_DIN_YYYYMMDD, // 1997-10-08 DIN
154 : NF_DATE_SYS_MMYY, // 10.97
155 : NF_DATE_SYS_DDMMM, // 08.Oct
156 : NF_DATE_MMMM, // October
157 : NF_DATE_QQJJ, // 4. Quarter 97
158 : NF_DATE_WW, // week of year
159 : NF_DATE_END = NF_DATE_WW,
160 :
161 : NF_TIME_START,
162 : NF_TIME_HHMM = NF_TIME_START, // HH:MM
163 : NF_TIME_HHMMSS, // HH:MM:SS
164 : NF_TIME_HHMMAMPM, // HH:MM AM/PM
165 : NF_TIME_HHMMSSAMPM, // HH:MM:SS AM/PM
166 : NF_TIME_HH_MMSS, // [HH]:MM:SS
167 : NF_TIME_MMSS00, // MM:SS,00
168 : NF_TIME_HH_MMSS00, // [HH]:MM:SS,00
169 : NF_TIME_END = NF_TIME_HH_MMSS00,
170 :
171 : NF_DATETIME_START,
172 : NF_DATETIME_SYSTEM_SHORT_HHMM = NF_DATETIME_START, // 08.10.97 01:23
173 : NF_DATETIME_SYS_DDMMYYYY_HHMMSS, // 08.10.1997 01:23:45
174 : NF_DATETIME_END = NF_DATETIME_SYS_DDMMYYYY_HHMMSS,
175 :
176 : NF_BOOLEAN, // BOOLEAN
177 : NF_TEXT, // @
178 :
179 : NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // old number of predefined entries, locale data additions start after this
180 :
181 : // From here on are values of new built-in formats that are not in the
182 : // original NumberFormatIndex.idl
183 :
184 : NF_FRACTION_3 = NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // # ?/4
185 : NF_FRACTION_4, // # ?/100
186 :
187 : NF_INDEX_TABLE_ENTRIES
188 : };
189 :
190 :
191 : // #45717# IsNumberFormat( "98-10-24", 30, x ), YMD Format set with DMY
192 : // International settings doesn't recognize the string as a date.
193 : /** enum values for <method>SvNumberFormatter::SetEvalDateFormat</method>
194 :
195 : <p>How <method>ImpSvNumberInputScan::GetDateRef</method> shall take the
196 : DateFormat order (YMD,DMY,MDY) into account, if called from IsNumberFormat
197 : with a date format to match against.
198 : */
199 : enum NfEvalDateFormat
200 : {
201 : /** DateFormat only from International, default. */
202 : NF_EVALDATEFORMAT_INTL,
203 :
204 : /** DateFormat only from date format passed to function (if any).
205 : If no date format is passed then the DateFormat is taken from International. */
206 : NF_EVALDATEFORMAT_FORMAT,
207 :
208 : /** First try the DateFormat from International. If it doesn't match a
209 : valid date try the DateFormat from the date format passed. */
210 : NF_EVALDATEFORMAT_INTL_FORMAT,
211 :
212 : /** First try the DateFormat from the date format passed. If it doesn't
213 : match a valid date try the DateFormat from International. */
214 : NF_EVALDATEFORMAT_FORMAT_INTL
215 : };
216 :
217 :
218 : typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable;
219 : typedef std::map<sal_uInt16, sal_uInt32> SvNumberFormatterIndexTable;
220 :
221 : typedef ::std::map< sal_uInt32, sal_uInt32> SvNumberFormatterMergeMap;
222 :
223 : typedef ::std::set< LanguageType > NfInstalledLocales;
224 :
225 :
226 : /** Language/country dependent currency entries
227 : */
228 : class SVL_DLLPUBLIC NfCurrencyEntry
229 : {
230 : OUString aSymbol; /// currency symbol
231 : OUString aBankSymbol; /// currency abbreviation
232 : LanguageType eLanguage; /// language/country value
233 : sal_uInt16 nPositiveFormat; /// position of symbol
234 : sal_uInt16 nNegativeFormat; /// position of symbol and type and position of negative sign
235 : sal_uInt16 nDigits; /// count of decimal digits
236 : sal_Unicode cZeroChar; /// which character is used for zeros as last decimal digits
237 :
238 : /// not implemented, prevent usage
239 : NfCurrencyEntry( const NfCurrencyEntry& );
240 : /// not implemented, prevent usage
241 : NfCurrencyEntry& operator=( const NfCurrencyEntry& );
242 :
243 : private:
244 :
245 : // nDecimalFormat := 0, 1, 2
246 : // #,##0 or #,##0.00 or #,##0.-- is returned
247 : SVL_DLLPRIVATE OUString Impl_BuildFormatStringNumChars( const LocaleDataWrapper&, sal_uInt16 nDecimalFormat) const;
248 :
249 : public:
250 :
251 : NfCurrencyEntry( const LocaleDataWrapper& rLocaleData,
252 : LanguageType eLang );
253 : NfCurrencyEntry( const ::com::sun::star::i18n::Currency & rCurr,
254 : const LocaleDataWrapper& rLocaleData,
255 : LanguageType eLang );
256 8242 : ~NfCurrencyEntry() {}
257 :
258 : /// Symbols and language identical
259 : bool operator==( const NfCurrencyEntry& r ) const;
260 :
261 8952 : const OUString& GetSymbol() const { return aSymbol; }
262 8342 : const OUString& GetBankSymbol() const { return aBankSymbol; }
263 2532 : LanguageType GetLanguage() const { return eLanguage; }
264 10 : sal_uInt16 GetPositiveFormat() const { return nPositiveFormat; }
265 10 : sal_uInt16 GetNegativeFormat() const { return nNegativeFormat; }
266 320 : sal_uInt16 GetDigits() const { return nDigits; }
267 : sal_Unicode GetZeroChar() const { return cZeroChar; }
268 :
269 : /** [$DM-407] (bBank==false) or [$DEM] (bBank==true)
270 : is returned. If bBank==false and
271 : bWithoutExtension==true only [$DM] */
272 : OUString BuildSymbolString(bool bBank, bool bWithoutExtension = false) const;
273 :
274 : /** #,##0.00 [$DM-407] is returned, separators
275 : from rLoc, incl. minus sign but without [RED] */
276 : OUString BuildPositiveFormatString(bool bBank, const LocaleDataWrapper&,
277 : sal_uInt16 nDecimalFormat = 1) const;
278 : OUString BuildNegativeFormatString(bool bBank, const LocaleDataWrapper&,
279 : sal_uInt16 nDecimalFormat = 1) const;
280 :
281 : /** [$DM-407] (or [$DEM] if bBank==true)
282 : is appended/prepended to rStr, incl. minus sign */
283 : void CompletePositiveFormatString(OUStringBuffer& rStr, bool bBank,
284 : sal_uInt16 nPosiFormat) const;
285 : void CompleteNegativeFormatString(OUStringBuffer& rStr, bool bBank,
286 : sal_uInt16 nNegaFormat) const;
287 :
288 : /// rSymStr is appended/prepended to rStr, incl. minus sign
289 : static void CompletePositiveFormatString(OUStringBuffer& rStr,
290 : const OUString& rSymStr, sal_uInt16 nPosiFormat);
291 : static void CompleteNegativeFormatString(OUStringBuffer& rStr,
292 : const OUString& rSymStr, sal_uInt16 nNegaFormat);
293 :
294 : /** Representation of a currency (symbol position and
295 : negative sign) in other language settings */
296 : static sal_uInt16 GetEffectivePositiveFormat( sal_uInt16 nIntlFormat,
297 : sal_uInt16 nCurrFormat, bool bBank );
298 : static sal_uInt16 GetEffectiveNegativeFormat( sal_uInt16 nIntlFormat,
299 : sal_uInt16 nCurrFormat, bool bBank );
300 :
301 : /// General Unicode Euro symbol
302 0 : static inline sal_Unicode GetEuroSymbol() { return sal_Unicode(0x20AC); }
303 : /** Platform and CharSet dependent Euro symbol,
304 : needed for import/export */
305 : static sal_Char GetEuroSymbol( rtl_TextEncoding eTextEncoding );
306 : };
307 :
308 : typedef boost::ptr_vector<NfCurrencyEntry> NfCurrencyTable;
309 :
310 : typedef std::vector< OUString > NfWSStringsDtor;
311 :
312 : class SvNumberFormatterRegistry_Impl;
313 :
314 : class SVL_DLLPUBLIC SvNumberFormatter
315 : {
316 : public:
317 : /**
318 : * We can't technically have an "infinite" value, so we use an arbitrary
319 : * upper precision threshold to represent the "unlimited" precision.
320 : */
321 : static const sal_uInt16 UNLIMITED_PRECISION;
322 :
323 : /**
324 : * Precision suitable for numbers displayed in input bar, for instance
325 : * Calc's formula input bar.
326 : */
327 : static const sal_uInt16 INPUTSTRING_PRECISION;
328 :
329 : /// Preferred ctor with service manager and language/country enum
330 : SvNumberFormatter(
331 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
332 : LanguageType eLang
333 : );
334 :
335 : ~SvNumberFormatter();
336 :
337 : /// Set CallBack to ColorTable
338 1504 : void SetColorLink( const Link& rColorTableCallBack ) { aColorLink = rColorTableCallBack; }
339 : /// Do the CallBack to ColorTable
340 : Color* GetUserDefColor(sal_uInt16 nIndex);
341 :
342 : /// Change language/country, also input and format scanner
343 : void ChangeIntl( LanguageType eLnge );
344 : /// Change the reference null date
345 : void ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear);
346 : /// Change standard precision
347 : void ChangeStandardPrec(short nPrec);
348 : /// Set zero value suppression
349 0 : void SetNoZero(bool bNZ) { bNoZero = bNZ; }
350 :
351 : /** The language with which the formatter was initialized (system setting),
352 : NOT the current language after a ChangeIntl() */
353 1 : LanguageType GetLanguage() const { return IniLnge; }
354 :
355 : // Determine whether two format types are input compatible or not
356 : bool IsCompatible(short eOldType, short eNewType);
357 :
358 : /** Get table of formats of a specific type of a locale. A format FIndex is
359 : tested whether it has the type and locale requested, if it doesn't
360 : match FIndex returns the default format for the type/locale. If no
361 : specific format is to be selected FIndex may be initialized to 0. */
362 : SvNumberFormatTable& GetEntryTable(short eType,
363 : sal_uInt32& FIndex,
364 : LanguageType eLnge);
365 :
366 : /** Get table of formats of a specific type of a language/country.
367 : FIndex returns the default format of that type.
368 : If the language/country was never touched before new entries are generated */
369 : SvNumberFormatTable& ChangeCL(short eType,
370 : sal_uInt32& FIndex,
371 : LanguageType eLnge);
372 :
373 : /** Get table of formats of the same type as FIndex; eType and rLnge are
374 : set accordingly. An unknown format is set to Standard/General */
375 : SvNumberFormatTable& GetFirstEntryTable(short& eType,
376 : sal_uInt32& FIndex,
377 : LanguageType& rLnge);
378 :
379 : /// Delete an entry including the format it is refering to
380 : void DeleteEntry(sal_uInt32 nKey);
381 :
382 : /** Create new entry of a format code string for language/country.
383 : @return
384 : <TRUE/> if string new and ok and inserted.
385 : <FALSE/> if string already exists or an unresolvable parse error
386 : occurred, in which case nCheckPos is the error position within rString.
387 : If the error occurs at position 0 or rString is empty nCheckPos
388 : will be 1, so an error in the string is always indicated by
389 : nCheckPos not being zero.
390 : The content of the rString variable can be changed and corrected
391 : by the method.
392 : nType contains the type of the format.
393 : nKey contains the index key of the format.
394 : */
395 : bool PutEntry( OUString& rString, sal_Int32& nCheckPos, short& nType, sal_uInt32& nKey,
396 : LanguageType eLnge = LANGUAGE_DONTKNOW );
397 :
398 : /** Same as <method>PutEntry</method> but the format code string is
399 : considered to be of language/country eLnge and is converted to
400 : language/country eNewLnge */
401 : bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos,
402 : short& nType, sal_uInt32& nKey,
403 : LanguageType eLnge, LanguageType eNewLnge );
404 :
405 : /** Same as <method>PutandConvertEntry</method> but the format code string
406 : is considered to be of the System language/country eLnge and is
407 : converted to another System language/country eNewLnge. In this case
408 : the automatic currency is converted too. */
409 : bool PutandConvertEntrySystem( OUString& rString, sal_Int32& nCheckPos,
410 : short& nType, sal_uInt32& nKey,
411 : LanguageType eLnge, LanguageType eNewLnge );
412 :
413 : /** Similar to <method>PutEntry</method> and
414 : <method>PutandConvertEntry</method> or
415 : <method>PutandConvertEntrySystem</method>, the format code string
416 : passed is considered to be of language/country eLnge. If
417 : eLnge==LANGUAGE_SYSTEM the format code has to match eSysLnge, and if
418 : eSysLnge is not the current application locale the format code is
419 : converted to the current locale. Additionally, if the format code
420 : represents an old "automatic" currency format, it is converted to the
421 : new default currency format of the eLnge locale. The rString format
422 : code passed as an argument may get adapted in case eLnge was used (or
423 : is LANGUAGE_SYSTEM and eSysLnge is identical); in case it wasn't the
424 : method works on a copy instead, otherwise the resulting string would
425 : not match eSysLnge anymore.
426 :
427 : <p> This method was introduced to handle the legacy currency formats of
428 : the "autotbl.fmt" file used by Calc and Writer and convert them to
429 : fixed currency codes of the actual currency. Note that in the case of
430 : legacy currency formats no special attribution is converted, only the
431 : default currency format of the locale is chosen, and that new fixed
432 : currency codes are of course not converted to other currencies. The
433 : method may also be used as a general method taking, converting and
434 : inserting almost arbitrary format codes. To insert or use, for example,
435 : the default currency format code matching the current locale, the
436 : method could be called with<br/>
437 :
438 : <code>
439 : GetIndexPuttingAndConverting( "0 $", LANGUAGE_SYSTEM, LANGUAGE_ENGLISH_US, ...);
440 : </code>
441 :
442 : @return
443 : The index key of the resulting number format. If the format code
444 : was empty, could not be converted or has errors, the eLnge locale's
445 : standard number format is chosen instead. The index key is
446 : guaranteed to represent some valid number format. If
447 : rNewInserted==false and rCheckPos>0 the format code has errors
448 : and/or could not be converted.
449 : */
450 : sal_uInt32 GetIndexPuttingAndConverting( OUString & rString, LanguageType eLnge,
451 : LanguageType eSysLnge, short & rType,
452 : bool & rNewInserted, sal_Int32 & rCheckPos );
453 :
454 : /** Create a format code string using format nIndex as a template and
455 : applying other settings (passed from the dialog) */
456 : OUString GenerateFormat(sal_uInt32 nIndex,
457 : LanguageType eLnge = LANGUAGE_DONTKNOW,
458 : bool bThousand = false, bool IsRed = false,
459 : sal_uInt16 nPrecision = 0, sal_uInt16 nAnzLeading = 1);
460 :
461 : /** Analyze an input string
462 : @return
463 : <TRUE/> if input is a number or is matching a format F_Index
464 : F_Index is set to a matching format if number, the value is
465 : returned in fOutNumber
466 : <FALSE/> if input is not a number
467 : */
468 : bool IsNumberFormat( const OUString& sString, sal_uInt32& F_Index, double& fOutNumber );
469 :
470 : /// Format a number according to a format index, return string and color
471 : void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex,
472 : OUString& sOutString, Color** ppColor, bool bUseStarFormat = false );
473 :
474 : /** Format a string according to a format index, return string and color.
475 : Formats only if the format code is of type text or the 4th subcode
476 : of a format code is specified, otherwise sOutString will be == "" */
477 : void GetOutputString( const OUString& sString, sal_uInt32 nFIndex,
478 : OUString& sOutString, Color** ppColor, bool bUseStarFormat = false );
479 :
480 : /** Format a number according to the standard default format matching
481 : the given format index */
482 : void GetInputLineString( const double& fOutNumber,
483 : sal_uInt32 nFIndex, OUString& rOutString );
484 :
485 : /** Format a number according to a format code string to be scanned.
486 : @return
487 : <FALSE/> if format code contains an error
488 : <TRUE/> else, in which case the string and color are returned.
489 : */
490 : bool GetPreviewString(const OUString& sFormatString,
491 : double fPreviewNumber,
492 : OUString& sOutString,
493 : Color** ppColor,
494 : LanguageType eLnge,
495 : bool bUseStarFormat = false );
496 :
497 : /** Same as <method>GetPreviewString</method> but the format code string
498 : may be either language/country eLnge or en_US english US */
499 : bool GetPreviewStringGuess( const OUString& sFormatString, double fPreviewNumber,
500 : OUString& sOutString, Color** ppColor,
501 : LanguageType eLnge = LANGUAGE_DONTKNOW );
502 :
503 : /** Format a string according to a format code string to be scanned.
504 : @return
505 : <FALSE/> if format code contains an error
506 : <TRUE/> else, in which case the string and color are returned.
507 : */
508 : bool GetPreviewString( const OUString& sFormatString, const OUString& sPreviewString,
509 : OUString& sOutString, Color** ppColor,
510 : LanguageType eLnge = LANGUAGE_DONTKNOW );
511 :
512 : /** Test whether the format code string is already present in container
513 : @return
514 : NUMBERFORMAT_ENTRY_NOT_FOUND if not found, else the format index.
515 : */
516 : sal_uInt32 TestNewString( const OUString& sFormatString,
517 : LanguageType eLnge = LANGUAGE_DONTKNOW );
518 :
519 : /// Whether format index nFIndex is of type text or not
520 : bool IsTextFormat(sal_uInt32 nFIndex) const;
521 :
522 : /// Load all formats from a stream
523 : bool Load( SvStream& rStream );
524 : /// Save all formats to a stream
525 : bool Save( SvStream& rStream ) const;
526 :
527 : /// Get additional info of a format index, e.g. for dialog box
528 : void GetFormatSpecialInfo(sal_uInt32 nFormat, bool& bThousand, bool& IsRed,
529 : sal_uInt16& nPrecision, sal_uInt16& nAnzLeading);
530 :
531 : /// Count of decimals
532 : sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat ) const;
533 :
534 : /** Get additional info of a format code string, e.g. for dialog box.
535 : Uses a temporary parse, if possible use only if format code is not
536 : present in container yet, otherwise ineffective.
537 : @return
538 : 0 if format code string parsed without errors, otherwise error
539 : position (like nCheckPos on <method>PutEntry</method>)
540 : */
541 : sal_uInt32 GetFormatSpecialInfo( const OUString&, bool& bThousand, bool& IsRed,
542 : sal_uInt16& nPrecision, sal_uInt16& nAnzLeading,
543 : LanguageType eLnge = LANGUAGE_DONTKNOW );
544 :
545 : /// Check if format code string may be deleted by user
546 : bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW );
547 :
548 : /** Return the format index of the format code string for language/country,
549 : or NUMBERFORMAT_ENTRY_NOT_FOUND */
550 : sal_uInt32 GetEntryKey( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW );
551 :
552 : /// Return the format for a format index
553 : const SvNumberformat* GetEntry( sal_uInt32 nKey ) const;
554 :
555 : /// Return the format index of the standard default number format for language/country
556 : sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW);
557 :
558 : /// Return the format index of the default format of a type for language/country
559 : sal_uInt32 GetStandardFormat(short eType, LanguageType eLnge = LANGUAGE_DONTKNOW);
560 :
561 : /** Return the format index of the default format of a type for language/country.
562 : Maybe not the default format but a special builtin format, e.g. for
563 : NF_TIME_HH_MMSS00, if that format is passed in nFIndex. */
564 : sal_uInt32 GetStandardFormat( sal_uInt32 nFIndex, short eType, LanguageType eLnge );
565 :
566 : /** Return the format index of the default format of a type for language/country.
567 : Maybe not the default format but a special builtin format, e.g. for
568 : NF_TIME_HH_MMSS00, or NF_TIME_HH_MMSS if fNumber >= 1.0 */
569 : sal_uInt32 GetStandardFormat( double fNumber, sal_uInt32 nFIndex, short eType,
570 : LanguageType eLnge );
571 :
572 : /// Whether nFIndex is a special builtin format
573 : bool IsSpecialStandardFormat( sal_uInt32 nFIndex, LanguageType eLnge );
574 :
575 : /** Return the corresponding edit format of a format. */
576 : sal_uInt32 GetEditFormat( double fNumber, sal_uInt32 nFIndex, short eType,
577 : LanguageType eLnge, SvNumberformat* pFormat );
578 :
579 : /// Return the reference date
580 : Date* GetNullDate();
581 : /// Return the standard decimal precision
582 : sal_uInt16 GetStandardPrec();
583 : /// Return whether zero suppression is switched on
584 2 : bool GetNoZero() { return bNoZero; }
585 : /** Get the type of a format (or NUMBERFORMAT_UNDEFINED if no entry),
586 : but with NUMBERFORMAT_DEFINED masked out */
587 : short GetType(sal_uInt32 nFIndex);
588 :
589 : /// As the name says
590 : void ClearMergeTable();
591 : /// Merge in all new entries from rNewTable and return a table of resulting new format indices
592 : SvNumberFormatterIndexTable* MergeFormatter(SvNumberFormatter& rNewTable);
593 :
594 : /// Whether a merge table is present or not
595 : inline bool HasMergeFmtTbl() const;
596 : /// Return the new format index for an old format index, if a merge table exists
597 : inline sal_uInt32 GetMergeFmtIndex( sal_uInt32 nOldFmt ) const;
598 :
599 : /** Convert the ugly old tools' Table type bloated with new'ed sal_uInt32
600 : entries merge table to ::std::map with old index key and new index key.
601 : @ATTENTION! Also clears the old table using ClearMergeTable() */
602 : SvNumberFormatterMergeMap ConvertMergeTableToMap();
603 :
604 : /// Return the last used position ever of a language/country combination
605 : sal_uInt16 GetLastInsertKey(sal_uInt32 CLOffset);
606 :
607 : /** Return the format index of a builtin format for a specific language/country.
608 : If nFormat is not a builtin format nFormat is returned. */
609 : sal_uInt32 GetFormatForLanguageIfBuiltIn( sal_uInt32 nFormat,
610 : LanguageType eLnge = LANGUAGE_DONTKNOW );
611 :
612 : /** Return the format index for a builtin format of a specific language
613 : @see NfIndexTableOffset
614 : */
615 : sal_uInt32 GetFormatIndex( NfIndexTableOffset, LanguageType eLnge = LANGUAGE_DONTKNOW );
616 :
617 : /** Return enum index of a format index of a builtin format,
618 : NF_INDEX_TABLE_ENTRIES if it's not a builtin format.
619 : @see NfIndexTableOffset
620 : */
621 : NfIndexTableOffset GetIndexTableOffset( sal_uInt32 nFormat ) const;
622 :
623 : /** Set evaluation type and order of input date strings
624 : @see NfEvalDateFormat
625 : */
626 1363 : void SetEvalDateFormat( NfEvalDateFormat eEDF ) { eEvalDateFormat = eEDF; }
627 0 : NfEvalDateFormat GetEvalDateFormat() const { return eEvalDateFormat; }
628 :
629 : /** Set TwoDigitYearStart, how the input string scanner handles a two digit year.
630 : Default from VCL: 1930, 30-99 19xx, 00-29 20xx
631 :
632 : <p> Historically (prior to src513e) it was a two digit number determing
633 : until which number the string scanner recognizes a year to be 20xx,
634 : default <= 29 is used by SFX/OfaMiscCfg.
635 : The name Year2000 is kept although the actual functionality is now a
636 : TwoDigitYearStart which might be in any century.
637 : */
638 : void SetYear2000( sal_uInt16 nVal );
639 : sal_uInt16 GetYear2000() const;
640 : static sal_uInt16 GetYear2000Default();
641 :
642 : sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear ) const;
643 : inline static sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear, sal_uInt16 nTwoDigitYearStart );
644 :
645 : /// DEPRICATED: Return first character of the decimal separator of the current language/country
646 0 : sal_Unicode GetDecSep() const { return GetNumDecimalSep()[0]; }
647 : /// Return the decimal separator of the current language/country
648 : OUString GetDecimalSep() const { return GetNumDecimalSep(); }
649 :
650 : /// Return the decimal separator matching the locale of the given format
651 : OUString GetFormatDecimalSep( sal_uInt32 nFormat ) const;
652 :
653 : /// Return a NfCurrencyTable with pointers to <type>NfCurrencyEntry</type> entries
654 : static const NfCurrencyTable& GetTheCurrencyTable();
655 :
656 : /** Searches, according to the default locale currency, an entry of the
657 : CurrencyTable which is <bold>not</bold> the first (LANGUAGE_SYSTEM) entry.
658 : @return
659 : <NULL/> if not found
660 : else pointer to NfCurrencyEntry
661 : */
662 : static const NfCurrencyEntry* MatchSystemCurrency();
663 :
664 : /** Return a NfCurrencyEntry matching a language/country.
665 : If language/country is LANGUAGE_SYSTEM a <method>MatchSystemCurrency</method>
666 : call is tried to get an entry. If that fails or the corresponding
667 : language/country is not present the entry for LANGUAGE_SYSTEM is returned.
668 : */
669 : static const NfCurrencyEntry& GetCurrencyEntry( LanguageType );
670 :
671 : /** Return a NfCurrencyEntry pointer matching a language/country
672 : and currency abbreviation (AKA banking symbol).
673 : This method is meant for the configuration of the default currency.
674 : @return
675 : <NULL/> if not found
676 : else pointer to NfCurrencyEntry
677 : */
678 : static const NfCurrencyEntry* GetCurrencyEntry( const OUString& rAbbrev,
679 : LanguageType eLang );
680 :
681 : /** Return a NfCurrencyEntry pointer matching the symbol
682 : combination of a LegacyOnly currency. Note that this means only that
683 : the currency matching both symbols was once used in the Office, but is
684 : not offered in dialogs anymore. It doesn't even mean that the currency
685 : symbol combination is valid, since the reason for removing it may have
686 : been just that. #i61657#
687 : @return
688 : A matching entry, or else <NULL/>.
689 : */
690 : static const NfCurrencyEntry* GetLegacyOnlyCurrencyEntry( const OUString& rSymbol, const OUString& rAbbrev );
691 :
692 : /** Set the default system currency. The combination of abbreviation and
693 : language must match an existent element of theCurrencyTable. If not,
694 : the SYSTEM (current locale) entry becomes the default.
695 : This method is meant for the configuration of the default currency.
696 : */
697 : static void SetDefaultSystemCurrency( const OUString& rAbbrev, LanguageType eLang );
698 :
699 : /** Get all standard formats for a specific currency, formats are
700 : appended to the NfWSStringsDtor list.
701 : @param bBank
702 : <TRUE/>: generate only format strings with currency abbreviation
703 : <FALSE/>: mixed format strings
704 : @return
705 : position of default format
706 : */
707 : sal_uInt16 GetCurrencyFormatStrings( NfWSStringsDtor&, const NfCurrencyEntry&,
708 : bool bBank ) const;
709 :
710 : /** Whether nFormat is of type NUMBERFORMAT_CURRENCY and the format code
711 : contains a new SYMBOLTYPE_CURRENCY and if so which one [$xxx-nnn].
712 : If ppEntry is not NULL and exactly one entry is found, a [$xxx-nnn] is
713 : returned, even if the format code only contains [$xxx] !
714 : */
715 : bool GetNewCurrencySymbolString( sal_uInt32 nFormat, OUString& rSymbol,
716 : const NfCurrencyEntry** ppEntry = NULL,
717 : bool* pBank = NULL ) const;
718 :
719 : /** Look up the corresponding NfCurrencyEntry matching
720 : rSymbol (may be CurrencySymbol or CurrencyAbbreviation) and possibly
721 : a rExtension (being yyy of [$xxx-yyy]) or a given language/country
722 : value. Tries to match a rSymbol with rExtension first, then with
723 : eFormatLanguage, then rSymbol only. This is because a currency entry
724 : might have been constructed using I18N locale data where a used locale
725 : of a currrency format code must not necessarily match the locale of
726 : the locale data itself, e.g. [$HK$-40C] (being "zh_HK" locale) in
727 : zh_CN locale data. Here the rExtension would have the value 0x40c but
728 : eFormatLanguage of the number format would have the value of zh_CN
729 : locale, the value with which the corresponding CurrencyEntry is
730 : constructed.
731 :
732 : @param bFoundBank
733 : Only used for output.
734 : If the return value is not <NULL/> this value is set to <TRUE/> if
735 : the matching entry was found by comparing rSymbol against the
736 : CurrencyAbbreviation (AKA BankSymbol).
737 : If the return value is <NULL/> the value of bFoundBank is undefined.
738 : @param rSymbol
739 : Currency symbol, preferably obtained of a format by a call to
740 : <method>SvNumberformat::GetNewCurrencySymbol()</method>
741 : @param rExtension
742 : Currency extension, preferably obtained of a format by a call to
743 : <method>SvNumberformat::GetNewCurrencySymbol()</method>
744 : @param eFormatLanguage
745 : The language/country value of the format of which rSymbol and
746 : rExtension are obtained (<method>SvNumberformat::GetLanguage()</method>).
747 : @param bOnlyStringLanguage
748 : If <TRUE/> only entries with language/country of rExtension are
749 : checked, no match on eFormatLanguage. If rExtension is empty all
750 : entries are checked.
751 : @return
752 : The matching entry if unique (in which case bFoundBank is set),
753 : else <NULL/>.
754 : */
755 : static const NfCurrencyEntry* GetCurrencyEntry( bool & bFoundBank,
756 : const OUString& rSymbol,
757 : const OUString& rExtension,
758 : LanguageType eFormatLanguage,
759 : bool bOnlyStringLanguage = false );
760 :
761 : /// Get compatibility ("automatic" old style) currency from I18N locale data
762 : void GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const;
763 :
764 : /// Fill rList with the language/country codes that have been allocated
765 : void GetUsedLanguages( std::vector<sal_uInt16>& rList );
766 :
767 : /// Fill a NfKeywordIndex table with keywords of a language/country
768 : void FillKeywordTable( NfKeywordTable& rKeywords, LanguageType eLang );
769 :
770 : /** Return a keyword for a language/country and NfKeywordIndex
771 : for XML import, to generate number format strings. */
772 : OUString GetKeyword( LanguageType eLnge, sal_uInt16 nIndex );
773 :
774 : /** Return the GENERAL keyword in proper case ("General") for a
775 : language/country, used in XML import */
776 : OUString GetStandardName( LanguageType eLnge );
777 :
778 : /** Check if a specific locale has supported locale data. */
779 : static bool IsLocaleInstalled( LanguageType eLang );
780 :
781 : private:
782 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
783 : LanguageTag maLanguageTag;
784 : SvNumberFormatTable aFTable; // Table of format keys to format entries
785 : typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap;
786 : DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys
787 : SvNumberFormatTable* pFormatTable; // For the UI dialog
788 : SvNumberFormatterIndexTable* pMergeTable; // List of indices for merging two formatters
789 : CharClass* pCharClass; // CharacterClassification
790 : OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between SYSTEM, ENGLISH and other
791 : OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded on demand
792 : OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand
793 : OnDemandNativeNumberWrapper xNatNum; // Native number service loaded on demand
794 : ImpSvNumberInputScan* pStringScanner; // Input string scanner
795 : ImpSvNumberformatScan* pFormatScanner; // Format code string scanner
796 : Link aColorLink; // User defined color table CallBack
797 : sal_uInt32 MaxCLOffset; // Max language/country offset used
798 : sal_uInt32 nDefaultSystemCurrencyFormat; // NewCurrency matching SYSTEM locale
799 : LanguageType IniLnge; // Initialized setting language/country
800 : LanguageType ActLnge; // Current setting language/country
801 : NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation
802 : bool bNoZero; // Zero value suppression
803 :
804 : // cached locale data items needed almost any time
805 : OUString aDecimalSep;
806 : OUString aThousandSep;
807 : OUString aDateSep;
808 :
809 : SVL_DLLPRIVATE static bool bCurrencyTableInitialized;
810 : SVL_DLLPRIVATE static sal_uInt16 nSystemCurrencyPosition;
811 : SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl* pFormatterRegistry;
812 :
813 : // get the registry, create one if none exists
814 : SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl& GetFormatterRegistry();
815 :
816 : // called by ctors
817 : SVL_DLLPRIVATE void ImpConstruct( LanguageType eLang );
818 :
819 : // Changes initialized language/country, clears the entries and generates
820 : // new ones, may ONLY be called by the binary file format load
821 : SVL_DLLPRIVATE void ImpChangeSysCL( LanguageType eLnge, bool bNoAdditionalFormats );
822 :
823 : // Generate builtin formats provided by i18n behind CLOffset,
824 : // if bNoAdditionalFormats==false also generate additional i18n formats.
825 : SVL_DLLPRIVATE void ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditionalFormats );
826 :
827 : // Generate additional formats provided by i18n
828 : SVL_DLLPRIVATE void ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
829 : NumberFormatCodeWrapper& rNumberFormatCode,
830 : bool bAfterChangingSystemCL );
831 :
832 : SVL_DLLPRIVATE SvNumberformat* ImpInsertFormat( const ::com::sun::star::i18n::NumberFormatCode& rCode,
833 : sal_uInt32 nPos,
834 : bool bAfterChangingSystemCL = false,
835 : sal_Int16 nOrgIndex = 0 );
836 : // ImpInsertNewStandardFormat for new (since version ...) builtin formats
837 : SVL_DLLPRIVATE SvNumberformat* ImpInsertNewStandardFormat( const ::com::sun::star::i18n::NumberFormatCode& rCode,
838 : sal_uInt32 nPos,
839 : sal_uInt16 nVersion,
840 : bool bAfterChangingSystemCL = false,
841 : sal_Int16 nOrgIndex = 0 );
842 :
843 : // Return CLOffset or (MaxCLOffset + SV_COUNTRY_LANGUAGE_OFFSET) if new language/country
844 : SVL_DLLPRIVATE sal_uInt32 ImpGetCLOffset(LanguageType eLnge) const;
845 :
846 : // Test whether format code already exists, then return index key,
847 : // otherwise NUMBERFORMAT_ENTRY_NOT_FOUND
848 : SVL_DLLPRIVATE sal_uInt32 ImpIsEntry( const OUString& rString,
849 : sal_uInt32 CLOffset,
850 : LanguageType eLnge );
851 :
852 : // Create builtin formats for language/country if necessary, return CLOffset
853 : SVL_DLLPRIVATE sal_uInt32 ImpGenerateCL( LanguageType eLnge, bool bNoAdditionalFormats = false );
854 :
855 : // Build negative currency format, old compatibility style
856 : SVL_DLLPRIVATE void ImpGetNegCurrFormat(OUStringBuffer& sNegStr, const OUString& rCurrSymbol);
857 : // Build positive currency format, old compatibility style
858 : SVL_DLLPRIVATE void ImpGetPosCurrFormat(OUStringBuffer& sPosStr, const OUString& rCurrSymbol);
859 :
860 : // Create theCurrencyTable with all <type>NfCurrencyEntry</type>
861 : SVL_DLLPRIVATE static void ImpInitCurrencyTable();
862 :
863 : // Return the format index of the currency format of the system locale.
864 : // Format is created if not already present.
865 : SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultSystemCurrencyFormat();
866 :
867 : // Return the format index of the currency format of the current locale.
868 : // Format is created if not already present.
869 : SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultCurrencyFormat();
870 :
871 : // Return the default format for a given type and current locale.
872 : // May ONLY be called from within GetStandardFormat().
873 : SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultFormat( short nType );
874 :
875 : // Return the index in a sequence of format codes matching an enum of
876 : // NfIndexTableOffset. If not found 0 is returned. If the sequence doesn't
877 : // contain any format code elements a default element is created and inserted.
878 : SVL_DLLPRIVATE sal_Int32 ImpGetFormatCodeIndex( ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >& rSeq,
879 : const NfIndexTableOffset nTabOff );
880 :
881 : // Adjust a sequence of format codes to contain only one (THE) default
882 : // instead of multiple defaults for short/medium/long types.
883 : // If there is no medium but a short and a long default the long is taken.
884 : // Return the default index in the sequence.
885 : // Non-PRODUCT version may check locale data for matching defaults in one
886 : // FormatElement group.
887 : SVL_DLLPRIVATE sal_Int32 ImpAdjustFormatCodeDefault( ::com::sun::star::i18n::NumberFormatCode * pFormatArr,
888 : sal_Int32 nCount, bool bCheckCorrectness = true );
889 :
890 : // Obtain the format entry for a given key index.
891 : SVL_DLLPRIVATE SvNumberformat* GetFormatEntry( sal_uInt32 nKey );
892 41829 : SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry( sal_uInt32 nKey ) const
893 : {
894 41829 : return GetEntry( nKey);
895 : }
896 :
897 : // used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry()
898 : #ifndef DBG_UTIL
899 : inline
900 : #endif
901 : static bool ImpLookupCurrencyEntryLoopBody( const NfCurrencyEntry*& pFoundEntry,
902 : bool& bFoundBank, const NfCurrencyEntry* pData,
903 : sal_uInt16 nPos, const OUString& rSymbol );
904 :
905 : // link to be set at <method>SvtSysLocaleOptions::SetCurrencyChangeLink()</method>
906 : DECL_DLLPRIVATE_STATIC_LINK( SvNumberFormatter, CurrencyChangeLink, void* );
907 :
908 : public:
909 :
910 : // own static mutex, may also be used by internal class SvNumberFormatterRegistry_Impl
911 : static ::osl::Mutex& GetMutex();
912 :
913 : // called by SvNumberFormatterRegistry_Impl::Notify if the default system currency changes
914 : void ResetDefaultSystemCurrency();
915 :
916 : // Called by SvNumberFormatterRegistry_Impl::Notify if the system locale's
917 : // date acceptence patterns change.
918 : void InvalidateDateAcceptancePatterns();
919 :
920 : // Replace the SYSTEM language/country format codes. Called upon change of
921 : // the user configurable locale.
922 : // Old compatibility codes are replaced, user defined are converted, and
923 : // new format codes are appended.
924 : void ReplaceSystemCL( LanguageType eOldLanguage );
925 :
926 10179 : inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > GetComponentContext() const
927 : {
928 10179 : return m_xContext;
929 : }
930 :
931 :
932 :
933 : //! The following method is not to be used from outside but must be
934 : //! public for the InputScanner.
935 : // return the current FormatScanner
936 11135 : inline const ImpSvNumberformatScan* GetFormatScanner() const { return pFormatScanner; }
937 :
938 :
939 : //! The following methods are not to be used from outside but must be
940 : //! public for the InputScanner and FormatScanner.
941 :
942 : // return current (!) Locale
943 3910 : inline const LanguageTag& GetLanguageTag() const { return maLanguageTag; }
944 :
945 : // return corresponding Transliteration wrapper
946 12297 : inline const ::utl::TransliterationWrapper* GetTransliteration() const
947 : {
948 12297 : return xTransliteration.get();
949 : }
950 :
951 : // return corresponding Transliteration wrapper with loadModuleByImplName()
952 : inline const ::utl::TransliterationWrapper* GetTransliterationForModule( const OUString& rModule,
953 : LanguageType eLang ) const
954 : {
955 : return xTransliteration.getForModule( rModule, eLang );
956 : }
957 :
958 : // return the corresponding CharacterClassification wrapper
959 1998577 : inline const CharClass* GetCharClass() const { return pCharClass; }
960 :
961 : // return the corresponding LocaleData wrapper
962 1599434 : inline const LocaleDataWrapper* GetLocaleData() const { return xLocaleData.get(); }
963 :
964 : // return the corresponding Calendar wrapper
965 10615 : inline CalendarWrapper* GetCalendar() const { return xCalendar.get(); }
966 :
967 : // return the corresponding NativeNumberSupplier wrapper
968 2 : inline const NativeNumberWrapper* GetNatNum() const { return xNatNum.get(); }
969 :
970 : // cached locale data items
971 :
972 : // return the corresponding decimal separator
973 909516 : inline const OUString& GetNumDecimalSep() const { return aDecimalSep; }
974 :
975 : // return the corresponding group (AKA thousand) separator
976 1042840 : inline const OUString& GetNumThousandSep() const { return aThousandSep; }
977 :
978 : // return the corresponding date separator
979 536492 : inline const OUString& GetDateSep() const { return aDateSep; }
980 :
981 : };
982 :
983 :
984 : // --------------------------- inline --------------------------------------
985 :
986 0 : inline sal_uInt32 SvNumberFormatter::GetMergeFmtIndex( sal_uInt32 nOldFmt ) const
987 : {
988 0 : if (pMergeTable)
989 : {
990 0 : SvNumberFormatterIndexTable::iterator it = pMergeTable->find(nOldFmt);
991 0 : if (it != pMergeTable->end())
992 : {
993 0 : return it->second;
994 : }
995 : }
996 0 : return nOldFmt;
997 : }
998 :
999 7 : inline bool SvNumberFormatter::HasMergeFmtTbl() const
1000 : {
1001 7 : return pMergeTable && !pMergeTable->empty();
1002 : }
1003 :
1004 :
1005 : // static
1006 0 : inline sal_uInt16 SvNumberFormatter::ExpandTwoDigitYear( sal_uInt16 nYear, sal_uInt16 nTwoDigitYearStart )
1007 : {
1008 0 : if ( nYear < 100 )
1009 : {
1010 0 : if ( nYear < (nTwoDigitYearStart % 100) )
1011 : {
1012 0 : return nYear + (((nTwoDigitYearStart / 100) + 1) * 100);
1013 : }
1014 : else
1015 : {
1016 0 : return nYear + ((nTwoDigitYearStart / 100) * 100);
1017 : }
1018 : }
1019 0 : return nYear;
1020 : }
1021 :
1022 : #endif // _ZFORLIST_HXX
1023 :
1024 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|