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