LCOV - code coverage report
Current view: top level - include/svl - zforlist.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 44 65.9 %
Date: 2014-11-03 Functions: 25 30 83.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10