bump product version to 4.2.0.1
[LibreOffice.git] / include / unotools / syslocaleoptions.hxx
blob3821128fd18b43dd5d49cb701f564170d1ce11a5
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_UNOTOOLS_SYSLOCALEOPTIONS_HXX
21 #define INCLUDED_UNOTOOLS_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 <unotools/options.hxx>
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;
40 class SvtSysLocaleOptions_Impl;
41 class SvtListener;
42 namespace osl { class Mutex; }
44 class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSysLocaleOptions : public utl::detail::Options
46 static SvtSysLocaleOptions_Impl* pOptions;
47 static sal_Int32 nRefCount;
49 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
50 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint );
52 public:
54 enum EOption
56 E_LOCALE,
57 E_UILOCALE,
58 E_CURRENCY,
59 E_DATEPATTERNS
61 SvtSysLocaleOptions();
62 virtual ~SvtSysLocaleOptions();
64 // ConfigItem methods
66 bool IsModified();
67 void Commit();
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
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.
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.
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.
94 virtual void BlockBroadcasts( bool bBlock );
96 // config value access methods
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;
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;
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 );
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 );
121 // determine whether the decimal separator defined in the keyboard layout is used
122 // or the one approriate to the locale
123 bool IsDecimalSeparatorAsLocale() const;
124 void SetDecimalSeparatorAsLocale( bool bSet);
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);
131 // convenience methods
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 );
139 /// Create an USD-en-US or EUR-de-DE string
140 static OUString CreateCurrencyConfigString(
141 const OUString& rAbbrev,
142 LanguageType eLang );
144 void GetCurrencyAbbrevAndLanguage(
145 OUString& rAbbrev,
146 LanguageType& eLang ) const
148 GetCurrencyAbbrevAndLanguage( rAbbrev,
149 eLang, GetCurrencyConfigString() );
152 void SetCurrencyAbbrevAndLanguage(
153 const OUString& rAbbrev,
154 LanguageType eLang )
156 SetCurrencyConfigString(
157 CreateCurrencyConfigString(
158 rAbbrev, eLang ) );
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.
167 static void SetCurrencyChangeLink( const Link& rLink );
168 static const Link& GetCurrencyChangeLink();
170 /** return the readonly state of the queried option. */
171 bool IsReadOnly( EOption eOption ) const;
174 #endif // INCLUDED_UNOTOOLS_SYSLOCALEOPTIONS_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */