bump product version to 4.1.6.2
[LibreOffice.git] / include / unotools / syslocaleoptions.hxx
blob8c9378938ce0d3602c3e0dbeffc713bd1c4f5318
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
21 #define INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
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 <tools/string.hxx>
31 #include <unotools/options.hxx>
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 const sal_uLong SYSLOCALEOPTIONS_HINT_DATEPATTERNS = 0x00000010;
39 const sal_uLong SYSLOCALEOPTIONS_HINT_IGNORELANG = 0x00000020;
41 class SvtSysLocaleOptions_Impl;
42 class SvtListener;
43 namespace osl { class Mutex; }
45 class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSysLocaleOptions : public utl::detail::Options
47 static SvtSysLocaleOptions_Impl* pOptions;
48 static sal_Int32 nRefCount;
50 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
51 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint );
53 public:
55 enum EOption
57 E_LOCALE,
58 E_UILOCALE,
59 E_CURRENCY,
60 E_DATEPATTERNS
62 SvtSysLocaleOptions();
63 virtual ~SvtSysLocaleOptions();
65 // ConfigItem methods
67 sal_Bool IsModified();
68 void Commit();
70 /** Add a listener to react on config changes
71 which are broadcasted in a SfxSimpleHint
72 @return
73 <TRUE/> if added
74 <FALSE/> if not added
77 /** Block broadcasts and accumulate hints. This may be useful if, for
78 example, the locale and currency are changed and the currency was
79 empty before, since changing the locale with an empty currency does
80 also broadcast a change hint for the currency which would result in
81 two currency changes broadcasted.
83 @param bBlock
84 <TRUE/>: broadcasts are blocked until reversed.
85 <FALSE/>: broadcasts are not blocked anymore. Pending hints are
86 broadcasted if no other instance blocks the broadcast.
88 @ATTENTION
89 All SvtSysLocaleOptions instances point to exactly one refcounted
90 internal representation instance and broadcast blocks are counted.
91 Thus if you issue a BlockBroadcasts(sal_True) you MUST issue a matching
92 BlockBroadcasts(sal_False) or otherwise pending hints would never be
93 broadcasted again.
95 virtual void BlockBroadcasts( bool bBlock );
97 // config value access methods
99 /// The config string may be empty to denote the SYSTEM locale
100 const OUString& GetLocaleConfigString() const;
101 void SetLocaleConfigString( const OUString& rStr );
102 /** Get locale set, if empty denotes SYSTEM locale, not resolved
103 to the real locale. */
104 LanguageTag GetLanguageTag() const;
105 /** Get locale set, always resolved to the real locale. */
106 const LanguageTag& GetRealLanguageTag() const;
108 /// The config string may be empty to denote the SYSTEM locale
109 void SetUILocaleConfigString( const OUString& rStr );
110 /** Get UI locale set, always resolved to the real locale. */
111 const LanguageTag& GetRealUILanguageTag() const;
113 /// The config string may be empty to denote the default currency of the locale
114 const OUString& GetCurrencyConfigString() const;
115 void SetCurrencyConfigString( const OUString& rStr );
117 /** The config string may be empty to denote the default
118 DateAcceptancePatterns of the locale */
119 const OUString& GetDatePatternsConfigString() const;
120 void SetDatePatternsConfigString( const OUString& rStr );
122 // determine whether the decimal separator defined in the keyboard layout is used
123 // or the one approriate to the locale
124 sal_Bool IsDecimalSeparatorAsLocale() const;
125 void SetDecimalSeparatorAsLocale( sal_Bool bSet);
127 // determine whether to ignore changes to the system keyboard/locale/language when
128 // determining the language for newly entered text
129 sal_Bool IsIgnoreLanguageChange() const;
130 void SetIgnoreLanguageChange( sal_Bool bSet);
132 // convenience methods
134 /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string
135 static void GetCurrencyAbbrevAndLanguage(
136 String& rAbbrev,
137 LanguageType& eLang,
138 const OUString& rConfigString );
140 /// Create an USD-en-US or EUR-de-DE string
141 static OUString CreateCurrencyConfigString(
142 const String& rAbbrev,
143 LanguageType eLang );
145 void GetCurrencyAbbrevAndLanguage(
146 String& rAbbrev,
147 LanguageType& eLang ) const
149 GetCurrencyAbbrevAndLanguage( rAbbrev,
150 eLang, GetCurrencyConfigString() );
153 void SetCurrencyAbbrevAndLanguage(
154 const String& rAbbrev,
155 LanguageType eLang )
157 SetCurrencyConfigString(
158 CreateCurrencyConfigString(
159 rAbbrev, eLang ) );
162 /** Set a link to a method to be called whenever the default currency
163 changes. This can be only one method, and normally it is the static
164 link method which calls SvNumberFormatter::SetDefaultSystemCurrency().
165 This is needed because the number formatter isn't part of the svl light
166 library, otherwise we could call SetDefaultSystemCurrency() directly.
168 static void SetCurrencyChangeLink( const Link& rLink );
169 static const Link& GetCurrencyChangeLink();
171 /** return the readonly state of the queried option. */
172 sal_Bool IsReadOnly( EOption eOption ) const;
175 #endif // INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */