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 : :
20 : : #ifndef INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
21 : : #define INCLUDED_SVTOOLS_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 <i18npool/lang.h>
29 : : #include <tools/string.hxx>
30 : : #include <unotools/options.hxx>
31 : : #include <com/sun/star/lang/Locale.hpp>
32 : :
33 : : // bits for broadcasting hints of changes in a SfxSimpleHint, may be combined
34 : : const sal_uLong SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001;
35 : : const sal_uLong SYSLOCALEOPTIONS_HINT_CURRENCY = 0x00000002;
36 : : const sal_uLong SYSLOCALEOPTIONS_HINT_UILOCALE = 0x00000004;
37 : : const sal_uLong SYSLOCALEOPTIONS_HINT_DECSEP = 0x00000008;
38 : :
39 : : class SvtSysLocaleOptions_Impl;
40 : : class SvtListener;
41 : : namespace osl { class Mutex; }
42 : :
43 : : class UNOTOOLS_DLLPUBLIC SvtSysLocaleOptions: public utl::detail::Options
44 : : {
45 : : static SvtSysLocaleOptions_Impl* pOptions;
46 : : static sal_Int32 nRefCount;
47 : :
48 : : UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
49 : : virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint );
50 : :
51 : : public:
52 : :
53 : : enum EOption
54 : : {
55 : : E_LOCALE,
56 : : E_UILOCALE,
57 : : E_CURRENCY
58 : : };
59 : : SvtSysLocaleOptions();
60 : : virtual ~SvtSysLocaleOptions();
61 : :
62 : : // ConfigItem methods
63 : :
64 : : sal_Bool IsModified();
65 : : void Commit();
66 : :
67 : : /** Add a listener to react on config changes
68 : : which are broadcasted in a SfxSimpleHint
69 : : @return
70 : : <TRUE/> if added
71 : : <FALSE/> if not added
72 : : */
73 : :
74 : : /** Block broadcasts and accumulate hints. This may be useful if, for
75 : : example, the locale and currency are changed and the currency was
76 : : empty before, since changing the locale with an empty currency does
77 : : also broadcast a change hint for the currency which would result in
78 : : two currency changes broadcasted.
79 : :
80 : : @param bBlock
81 : : <TRUE/>: broadcasts are blocked until reversed.
82 : : <FALSE/>: broadcasts are not blocked anymore. Pending hints are
83 : : broadcasted if no other instance blocks the broadcast.
84 : :
85 : : @ATTENTION
86 : : All SvtSysLocaleOptions instances point to exactly one refcounted
87 : : internal representation instance and broadcast blocks are counted.
88 : : Thus if you issue a BlockBroadcasts(sal_True) you MUST issue a matching
89 : : BlockBroadcasts(sal_False) or otherwise pending hints would never be
90 : : broadcasted again.
91 : : */
92 : : virtual void BlockBroadcasts( bool bBlock );
93 : :
94 : : // config value access methods
95 : :
96 : : /// The config string may be empty to denote the SYSTEM locale
97 : : const ::rtl::OUString& GetLocaleConfigString() const;
98 : : void SetLocaleConfigString( const ::rtl::OUString& rStr );
99 : : com::sun::star::lang::Locale GetLocale() const;
100 : : com::sun::star::lang::Locale GetRealLocale() const;
101 : : LanguageType GetRealLanguage() const;
102 : :
103 : : /// The config string may be empty to denote the SYSTEM locale
104 : : void SetUILocaleConfigString( const ::rtl::OUString& rStr );
105 : : com::sun::star::lang::Locale GetRealUILocale() const;
106 : : LanguageType GetRealUILanguage() const;
107 : :
108 : : /// The config string may be empty to denote the default currency of the locale
109 : : const ::rtl::OUString& GetCurrencyConfigString() const;
110 : : void SetCurrencyConfigString( const ::rtl::OUString& rStr );
111 : : // determine whether the decimal separator defined in the keyboard layout is used
112 : : // or the one approriate to the locale
113 : : sal_Bool IsDecimalSeparatorAsLocale() const;
114 : : void SetDecimalSeparatorAsLocale( sal_Bool bSet);
115 : :
116 : : // convenience methods
117 : :
118 : : /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string
119 : : static void GetCurrencyAbbrevAndLanguage(
120 : : String& rAbbrev,
121 : : LanguageType& eLang,
122 : : const ::rtl::OUString& rConfigString );
123 : :
124 : : /// Create an USD-en-US or EUR-de-DE string
125 : : static ::rtl::OUString CreateCurrencyConfigString(
126 : : const String& rAbbrev,
127 : : LanguageType eLang );
128 : :
129 : 36 : void GetCurrencyAbbrevAndLanguage(
130 : : String& rAbbrev,
131 : : LanguageType& eLang ) const
132 : : {
133 : : GetCurrencyAbbrevAndLanguage( rAbbrev,
134 : 36 : eLang, GetCurrencyConfigString() );
135 : 36 : }
136 : :
137 : : void SetCurrencyAbbrevAndLanguage(
138 : : const String& rAbbrev,
139 : : LanguageType eLang )
140 : : {
141 : : SetCurrencyConfigString(
142 : : CreateCurrencyConfigString(
143 : : rAbbrev, eLang ) );
144 : : }
145 : :
146 : : /** Set a link to a method to be called whenever the default currency
147 : : changes. This can be only one method, and normally it is the static
148 : : link method which calls SvNumberFormatter::SetDefaultSystemCurrency().
149 : : This is needed because the number formatter isn't part of the svl light
150 : : library, otherwise we could call SetDefaultSystemCurrency() directly.
151 : : */
152 : : static void SetCurrencyChangeLink( const Link& rLink );
153 : : static const Link& GetCurrencyChangeLink();
154 : :
155 : : /** return the readonly state of the queried option. */
156 : : sal_Bool IsReadOnly( EOption eOption ) const;
157 : : };
158 : :
159 : : #endif // INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
160 : :
161 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|