LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/svl - zforlist.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 43 60.5 %
Date: 2012-08-25 Functions: 23 30 76.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 20 15.0 %

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

Generated by: LCOV version 1.10