sw: fail loading when the fallback text detection fails
[LibreOffice.git] / include / unotools / syslocaleoptions.hxx
blob5f5e57540485718ede940b6b67ff1190c9e0b943
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 <i18nlangtag/lang.h>
27 #include <i18nlangtag/languagetag.hxx>
28 #include <unotools/options.hxx>
30 class SvtSysLocaleOptions_Impl;
31 class LinkParamNone;
32 template <typename Arg, typename Ret> class Link;
34 class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtSysLocaleOptions final : public utl::detail::Options
36 std::shared_ptr<SvtSysLocaleOptions_Impl> pImpl;
38 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, ConfigurationHints nHint ) override;
40 public:
42 enum class EOption
44 Locale,
45 Currency,
46 DatePatterns
48 SvtSysLocaleOptions();
49 virtual ~SvtSysLocaleOptions() override;
51 // ConfigItem methods
53 bool IsModified() const;
54 void Commit();
56 /** Add a listener to react on config changes
57 which are broadcasted in a SfxSimpleHint
58 @return
59 <TRUE/> if added
60 <FALSE/> if not added
63 /** Block broadcasts and accumulate hints. This may be useful if, for
64 example, the locale and currency are changed and the currency was
65 empty before, since changing the locale with an empty currency does
66 also broadcast a change hint for the currency which would result in
67 two currency changes broadcasted.
69 @param bBlock
70 <TRUE/>: broadcasts are blocked until reversed.
71 <FALSE/>: broadcasts are not blocked anymore. Pending hints are
72 broadcasted if no other instance blocks the broadcast.
74 @ATTENTION
75 All SvtSysLocaleOptions instances point to exactly one refcounted
76 internal representation instance and broadcast blocks are counted.
77 Thus if you issue a BlockBroadcasts(true) you MUST issue a matching
78 BlockBroadcasts(false) or otherwise pending hints would never be
79 broadcasted again.
81 virtual void BlockBroadcasts( bool bBlock ) override;
83 // config value access methods
85 /// The config string may be empty to denote the SYSTEM locale
86 void SetLocaleConfigString( const OUString& rStr );
87 /** Get locale set, not resolved to the real locale. */
88 LanguageTag GetLanguageTag() const;
89 /** Get locale set, always resolved to the real locale. */
90 const LanguageTag& GetRealLanguageTag() const;
92 /// The config string may be empty to denote the SYSTEM locale
93 void SetUILocaleConfigString( const OUString& rStr );
94 /** Get UI locale set, always resolved to the real locale. */
95 const LanguageTag& GetRealUILanguageTag() const;
97 /// The config string may be empty to denote the default currency of the locale
98 const OUString& GetCurrencyConfigString() const;
99 void SetCurrencyConfigString( const OUString& rStr );
101 /** The config string may be empty to denote the default
102 DateAcceptancePatterns of the locale */
103 const OUString& GetDatePatternsConfigString() const;
104 void SetDatePatternsConfigString( const OUString& rStr );
106 // determine whether the decimal separator defined in the keyboard layout is used
107 // or the one appropriate to the locale
108 bool IsDecimalSeparatorAsLocale() const;
109 void SetDecimalSeparatorAsLocale( bool bSet);
111 // determine whether to ignore changes to the system keyboard/locale/language when
112 // determining the language for newly entered text
113 bool IsIgnoreLanguageChange() const;
114 void SetIgnoreLanguageChange( bool bSet);
116 // convenience methods
118 /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string
119 static void GetCurrencyAbbrevAndLanguage(
120 OUString& rAbbrev,
121 LanguageType& eLang,
122 const OUString& rConfigString );
124 /// Create an USD-en-US or EUR-de-DE string
125 static OUString CreateCurrencyConfigString(
126 const OUString& rAbbrev,
127 LanguageType eLang );
129 void GetCurrencyAbbrevAndLanguage(
130 OUString& rAbbrev,
131 LanguageType& eLang ) const
133 GetCurrencyAbbrevAndLanguage( rAbbrev,
134 eLang, GetCurrencyConfigString() );
137 /** Set a link to a method to be called whenever the default currency
138 changes. This can be only one method, and normally it is the static
139 link method which calls SvNumberFormatter::SetDefaultSystemCurrency().
140 This is needed because the number formatter isn't part of the svl light
141 library, otherwise we could call SetDefaultSystemCurrency() directly.
143 static void SetCurrencyChangeLink( const Link<LinkParamNone*,void>& rLink );
144 static const Link<LinkParamNone*,void>& GetCurrencyChangeLink();
146 /** return the readonly state of the queried option. */
147 bool IsReadOnly( EOption eOption ) const;
150 #endif // INCLUDED_UNOTOOLS_SYSLOCALEOPTIONS_HXX
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */