LCOV - code coverage report
Current view: top level - include/unotools - syslocaleoptions.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3 3 100.0 %
Date: 2014-04-11 Functions: 1 1 100.0 %
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             : 
      20             : #ifndef INCLUDED_UNOTOOLS_SYSLOCALEOPTIONS_HXX
      21             : #define INCLUDED_UNOTOOLS_SYSLOCALEOPTIONS_HXX
      22             : 
      23             : #include <unotools/unotoolsdllapi.h>
      24             : #include <sal/types.h>
      25             : #include <rtl/ustring.hxx>
      26             : #include <tools/solar.h>
      27             : #include <tools/link.hxx>
      28             : #include <i18nlangtag/lang.h>
      29             : #include <i18nlangtag/languagetag.hxx>
      30             : #include <unotools/options.hxx>
      31             : 
      32             : // bits for broadcasting hints of changes in a SfxSimpleHint, may be combined
      33             : const sal_uLong SYSLOCALEOPTIONS_HINT_LOCALE       = 0x00000001;
      34             : const sal_uLong SYSLOCALEOPTIONS_HINT_CURRENCY     = 0x00000002;
      35             : const sal_uLong SYSLOCALEOPTIONS_HINT_UILOCALE     = 0x00000004;
      36             : const sal_uLong SYSLOCALEOPTIONS_HINT_DECSEP       = 0x00000008;
      37             : const sal_uLong SYSLOCALEOPTIONS_HINT_DATEPATTERNS = 0x00000010;
      38             : const sal_uLong SYSLOCALEOPTIONS_HINT_IGNORELANG   = 0x00000020;
      39             : 
      40             : class SvtSysLocaleOptions_Impl;
      41             : class SvtListener;
      42             : namespace osl { class Mutex; }
      43             : 
      44             : class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSysLocaleOptions : public utl::detail::Options
      45             : {
      46             :     static  SvtSysLocaleOptions_Impl*   pOptions;
      47             :     static  sal_Int32                   nRefCount;
      48             : 
      49             :     UNOTOOLS_DLLPRIVATE static  ::osl::Mutex&       GetMutex();
      50             :     virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint ) SAL_OVERRIDE;
      51             : 
      52             : public:
      53             : 
      54             :     enum EOption
      55             :     {
      56             :         E_LOCALE,
      57             :         E_UILOCALE,
      58             :         E_CURRENCY,
      59             :         E_DATEPATTERNS
      60             :     };
      61             :                                 SvtSysLocaleOptions();
      62             :                                 virtual ~SvtSysLocaleOptions();
      63             : 
      64             :     // ConfigItem methods
      65             : 
      66             :             bool                IsModified();
      67             :             void                Commit();
      68             : 
      69             :                                 /** Add a listener to react on config changes
      70             :                                     which are broadcasted in a SfxSimpleHint
      71             :                                     @return
      72             :                                         <TRUE/> if added
      73             :                                         <FALSE/> if not added
      74             :                                  */
      75             : 
      76             :     /** Block broadcasts and accumulate hints. This may be useful if, for
      77             :         example, the locale and currency are changed and the currency was
      78             :         empty before, since changing the locale with an empty currency does
      79             :         also broadcast a change hint for the currency which would result in
      80             :         two currency changes broadcasted.
      81             : 
      82             :         @param bBlock
      83             :             <TRUE/>: broadcasts are blocked until reversed.
      84             :             <FALSE/>: broadcasts are not blocked anymore. Pending hints are
      85             :             broadcasted if no other instance blocks the broadcast.
      86             : 
      87             :         @ATTENTION
      88             :         All SvtSysLocaleOptions instances point to exactly one refcounted
      89             :         internal representation instance and broadcast blocks are counted.
      90             :         Thus if you issue a BlockBroadcasts(true) you MUST issue a matching
      91             :         BlockBroadcasts(false) or otherwise pending hints would never be
      92             :         broadcasted again.
      93             :      */
      94             :        virtual void             BlockBroadcasts( bool bBlock ) SAL_OVERRIDE;
      95             : 
      96             :     // config value access methods
      97             : 
      98             :     /// The config string may be empty to denote the SYSTEM locale
      99             :             const OUString&     GetLocaleConfigString() const;
     100             :             void                SetLocaleConfigString( const OUString& rStr );
     101             :             /** Get locale set, if empty denotes SYSTEM locale, not resolved
     102             :                 to the real locale. */
     103             :             LanguageTag         GetLanguageTag() const;
     104             :             /** Get locale set, always resolved to the real locale. */
     105             :             const LanguageTag&  GetRealLanguageTag() const;
     106             : 
     107             :     /// The config string may be empty to denote the SYSTEM locale
     108             :             void                SetUILocaleConfigString( const OUString& rStr );
     109             :             /** Get UI locale set, always resolved to the real locale. */
     110             :             const LanguageTag&  GetRealUILanguageTag() const;
     111             : 
     112             :     /// The config string may be empty to denote the default currency of the locale
     113             :             const OUString&     GetCurrencyConfigString() const;
     114             :             void                SetCurrencyConfigString( const OUString& rStr );
     115             : 
     116             :     /** The config string may be empty to denote the default
     117             :         DateAcceptancePatterns of the locale */
     118             :             const OUString&     GetDatePatternsConfigString() const;
     119             :             void                SetDatePatternsConfigString( const OUString& rStr );
     120             : 
     121             :     // determine whether the decimal separator defined in the keyboard layout is used
     122             :     // or the one appropriate to the locale
     123             :             bool                IsDecimalSeparatorAsLocale() const;
     124             :             void                SetDecimalSeparatorAsLocale( bool bSet);
     125             : 
     126             :     // determine whether to ignore changes to the system keyboard/locale/language when
     127             :     // determining the language for newly entered text
     128             :             bool                IsIgnoreLanguageChange() const;
     129             :             void                SetIgnoreLanguageChange( bool bSet);
     130             : 
     131             :     // convenience methods
     132             : 
     133             :     /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string
     134             :     static  void                GetCurrencyAbbrevAndLanguage(
     135             :                                     OUString& rAbbrev,
     136             :                                     LanguageType& eLang,
     137             :                                     const OUString& rConfigString );
     138             : 
     139             :     /// Create an USD-en-US or EUR-de-DE string
     140             :     static  OUString            CreateCurrencyConfigString(
     141             :                                     const OUString& rAbbrev,
     142             :                                     LanguageType eLang );
     143             : 
     144          26 :             void                GetCurrencyAbbrevAndLanguage(
     145             :                                         OUString& rAbbrev,
     146             :                                         LanguageType& eLang ) const
     147             :                                     {
     148             :                                         GetCurrencyAbbrevAndLanguage( rAbbrev,
     149          26 :                                             eLang, GetCurrencyConfigString() );
     150          26 :                                     }
     151             : 
     152             :             void                SetCurrencyAbbrevAndLanguage(
     153             :                                         const OUString& rAbbrev,
     154             :                                         LanguageType eLang )
     155             :                                     {
     156             :                                         SetCurrencyConfigString(
     157             :                                             CreateCurrencyConfigString(
     158             :                                             rAbbrev, eLang ) );
     159             :                                     }
     160             : 
     161             :     /** Set a link to a method to be called whenever the default currency
     162             :         changes. This can be only one method, and normally it is the static
     163             :         link method which calls SvNumberFormatter::SetDefaultSystemCurrency().
     164             :         This is needed because the number formatter isn't part of the svl light
     165             :         library, otherwise we could call SetDefaultSystemCurrency() directly.
     166             :      */
     167             :     static  void                SetCurrencyChangeLink( const Link& rLink );
     168             :     static  const Link&         GetCurrencyChangeLink();
     169             : 
     170             :     /** return the readonly state of the queried option. */
     171             :             bool                IsReadOnly( EOption eOption ) const;
     172             : };
     173             : 
     174             : #endif // INCLUDED_UNOTOOLS_SYSLOCALEOPTIONS_HXX
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10