nss: upgrade to release 3.73
[LibreOffice.git] / include / unotools / intlwrapper.hxx
blob49d1f8bf5438f6532c9de79bd4ca0d91e70f9c38
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_INTLWRAPPER_HXX
21 #define INCLUDED_UNOTOOLS_INTLWRAPPER_HXX
23 #include <unotools/unotoolsdllapi.h>
24 #include <com/sun/star/uno/Reference.h>
26 #include <i18nlangtag/languagetag.hxx>
27 #include <memory>
29 namespace com::sun::star::uno { class XComponentContext; }
31 class CollatorWrapper;
32 class LocaleDataWrapper;
34 /**
35 A wrapper of I18N wrappers. Using this is more expensive than using some
36 single wrapper classes so use it only if you must pass a single pointer
37 without knowing in advance what is needed, e.g. for
38 SfxPoolItem::GetPresentation(). Remember that this wrapper was only created
39 for convenience to bypass some oddities, if possible don't use it. <p>
41 Implemented are only the const get...() methods of the wrappers, which are
42 loaded on demand, for consistency reasons no change of locale is possible.
43 Only default calendar and default collator are supported. <p>
45 One exception though is the calendar wrapper: to be able to set a value and
46 retrieve calendar values it is not const, so methods using this should
47 reset the calendar to the previous value if it isn't sure where the
48 IntlWrapper did come from. <p>
50 class UNOTOOLS_DLLPUBLIC IntlWrapper
52 private:
53 LanguageTag maLanguageTag;
54 css::uno::Reference< css::uno::XComponentContext > m_xContext;
56 std::unique_ptr<LocaleDataWrapper> pLocaleData;
57 std::unique_ptr<CollatorWrapper> pCollator;
58 std::unique_ptr<CollatorWrapper> pCaseCollator;
60 void ImplNewLocaleData() const;
61 void ImplNewCollator( bool bCaseSensitive ) const;
63 public:
64 IntlWrapper(const LanguageTag& rLanguageTag);
65 ~IntlWrapper();
67 const LocaleDataWrapper* getLocaleData() const
69 if ( !pLocaleData )
70 ImplNewLocaleData();
71 return pLocaleData.get();
73 /// case insensitive collator, simple IGNORE_CASE
74 const CollatorWrapper* getCollator() const
76 if ( !pCollator )
77 ImplNewCollator( false );
78 return pCollator.get();
80 /// case sensitive collator
81 const CollatorWrapper* getCaseCollator() const
83 if ( !pCaseCollator )
84 ImplNewCollator( true );
85 return pCaseCollator.get();
89 #endif // INCLUDED_UNOTOOLS_INTLWRAPPER_HXX
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */