1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_SYSLOCALE_HXX
21 #define INCLUDED_UNOTOOLS_SYSLOCALE_HXX
23 #include <unotools/unotoolsdllapi.h>
24 #include <rtl/textenc.h>
30 class LocaleDataWrapper
;
31 class SvtSysLocale_Impl
;
32 class SvtSysLocaleOptions
;
34 namespace osl
{ class Mutex
; }
37 SvtSysLocale provides a refcounted single instance of an application wide
38 LocaleDataWrapper and <type>CharClass</type> which always
39 follow the locale as it is currently configured by the user. You may use
40 it anywhere to access the locale data elements like decimal separator and
41 simple date formatting and so on. Constructing and destructing a
42 SvtSysLocale is not expensive as long as there is at least one instance
45 class UNOTOOLS_DLLPUBLIC SvtSysLocale
47 friend class SvtSysLocale_Impl
; // access to mutex
49 std::shared_ptr
<SvtSysLocale_Impl
> pImpl
;
51 UNOTOOLS_DLLPRIVATE
static ::osl::Mutex
& GetMutex();
57 const LocaleDataWrapper
& GetLocaleData() const;
58 const CharClass
& GetCharClass() const;
60 /** It is safe to store the pointers locally and use them AS LONG AS THE
61 INSTANCE OF SvtSysLocale LIVES!
62 It is a faster access but be sure what you do!
64 const LocaleDataWrapper
* GetLocaleDataPtr() const;
65 const CharClass
* GetCharClassPtr() const;
66 SvtSysLocaleOptions
& GetOptions() const;
67 const LanguageTag
& GetLanguageTag() const;
68 const LanguageTag
& GetUILanguageTag() const;
70 /** Get the best MIME encoding matching the system locale, or if that isn't
71 determinable one that matches the UI locale, or UTF8 if everything else
74 static rtl_TextEncoding
GetBestMimeEncoding();
77 #endif // INCLUDED_SVTOOLS_SYSLOCALE_HXX
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */