/src/libreoffice/i18npool/inc/localedata.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #pragma once |
20 | | |
21 | | #include <com/sun/star/i18n/XLocaleData5.hpp> |
22 | | |
23 | | |
24 | | #include <cppuhelper/implbase.hxx> |
25 | | |
26 | | #include <com/sun/star/uno/Sequence.h> |
27 | | #include <com/sun/star/i18n/Calendar.hpp> |
28 | | #include <com/sun/star/i18n/LocaleDataItem2.hpp> |
29 | | #include <com/sun/star/i18n/UnicodeScript.hpp> |
30 | | #include <rtl/ref.hxx> |
31 | | #include <rtl/ustring.hxx> |
32 | | #include <vector> |
33 | | #include <string_view> |
34 | | #include <optional> |
35 | | #include <osl/module.hxx> |
36 | | |
37 | | |
38 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
39 | | |
40 | | namespace com::sun::star::beans { struct PropertyValue; } |
41 | | namespace com::sun::star::container { class XIndexAccess; } |
42 | | |
43 | | namespace i18npool { |
44 | | |
45 | | enum class DataLocaleLibrary { |
46 | | EN, |
47 | | ES, |
48 | | EURO, |
49 | | OTHERS |
50 | | }; |
51 | | |
52 | | |
53 | | struct LocaleDataLookupTableItem |
54 | | { |
55 | | DataLocaleLibrary dllName; |
56 | | osl::Module *module; |
57 | | const char* localeName; |
58 | | css::lang::Locale aLocale; |
59 | | |
60 | | LocaleDataLookupTableItem(DataLocaleLibrary name, osl::Module* m, const char* lname) : dllName(std::move(name)), module(m), localeName(lname) |
61 | 0 | { |
62 | 0 | } |
63 | | bool equals(const css::lang::Locale& rLocale) const |
64 | 0 | { |
65 | 0 | return (rLocale == aLocale); |
66 | 0 | } |
67 | | }; |
68 | | |
69 | | class LocaleDataImpl final : public cppu::WeakImplHelper |
70 | | < |
71 | | css::i18n::XLocaleData5, |
72 | | css::lang::XServiceInfo |
73 | | > |
74 | | { |
75 | | public: |
76 | | LocaleDataImpl(); |
77 | | virtual ~LocaleDataImpl() override; |
78 | | |
79 | 331k | static rtl::Reference<LocaleDataImpl> get() { return new LocaleDataImpl; } |
80 | | |
81 | | static css::uno::Sequence< css::i18n::CalendarItem > downcastCalendarItems( const css::uno::Sequence< css::i18n::CalendarItem2 > & rCi ); |
82 | | static css::i18n::Calendar downcastCalendar( const css::i18n::Calendar2 & rC ); |
83 | | |
84 | | /** Generates a <Language>_<Country> or <Variant> (if Language=="qlt") |
85 | | string suitable as part of service name with all '-' replaced by '_' */ |
86 | | static OUString getFirstLocaleServiceName( const css::lang::Locale & rLocale ); |
87 | | /** Generates fallback strings suitable as parts of service names, |
88 | | excluding the one obtained via getFirstLocaleServiceName() */ |
89 | | static ::std::vector< OUString > getFallbackLocaleServiceNames( const css::lang::Locale & rLocale ); |
90 | | |
91 | | virtual css::i18n::LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const css::lang::Locale& rLocale ) override; |
92 | | virtual css::i18n::LocaleDataItem SAL_CALL getLocaleItem( const css::lang::Locale& rLocale ) override; |
93 | | virtual css::uno::Sequence< css::i18n::Calendar2 > SAL_CALL getAllCalendars2( const css::lang::Locale& rLocale ) override; |
94 | | virtual css::uno::Sequence< css::i18n::Calendar > SAL_CALL getAllCalendars( const css::lang::Locale& rLocale ) override; |
95 | | virtual css::uno::Sequence< css::i18n::Currency > SAL_CALL getAllCurrencies( const css::lang::Locale& rLocale ) override; |
96 | | virtual css::uno::Sequence< css::i18n::Currency2 > SAL_CALL getAllCurrencies2( const css::lang::Locale& rLocale ) override; |
97 | | virtual css::uno::Sequence< css::i18n::FormatElement > SAL_CALL getAllFormats( const css::lang::Locale& rLocale ) override; |
98 | | virtual css::uno::Sequence< css::i18n::Implementation > SAL_CALL getCollatorImplementations( const css::lang::Locale& rLocale ) override; |
99 | | /// @throws css::uno::RuntimeException |
100 | | OUString getCollatorRuleByAlgorithm( const css::lang::Locale& rLocale, std::u16string_view algorithm ); |
101 | | virtual css::uno::Sequence< OUString > SAL_CALL getTransliterations( const css::lang::Locale& rLocale ) override; |
102 | | virtual css::i18n::ForbiddenCharacters SAL_CALL getForbiddenCharacters( const css::lang::Locale& rLocale ) override; |
103 | | virtual css::uno::Sequence< OUString > SAL_CALL getReservedWord( const css::lang::Locale& rLocale ) override ; |
104 | | /// @throws css::uno::RuntimeException |
105 | | css::uno::Sequence< OUString > getBreakIteratorRules( const css::lang::Locale& rLocale ) ; |
106 | | virtual css::uno::Sequence< css::lang::Locale > SAL_CALL getAllInstalledLocaleNames() override; |
107 | | |
108 | | virtual css::uno::Sequence< OUString > SAL_CALL getSearchOptions( const css::lang::Locale& rLocale ) override; |
109 | | virtual css::uno::Sequence< OUString > SAL_CALL getCollationOptions( const css::lang::Locale& rLocale ) override; |
110 | | /// @throws css::uno::RuntimeException |
111 | | css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getContinuousNumberingLevels( const css::lang::Locale& rLocale ); |
112 | | /// @throws css::uno::RuntimeException |
113 | | css::uno::Sequence< css::uno::Reference< css::container::XIndexAccess > > getOutlineNumberingLevels( const css::lang::Locale& rLocale ); |
114 | | |
115 | | // XLocaleData4 |
116 | | virtual css::uno::Sequence< OUString > SAL_CALL getDateAcceptancePatterns( const css::lang::Locale& rLocale ) override; |
117 | | |
118 | | // XLocaleData5 |
119 | | virtual css::i18n::LocaleDataItem2 SAL_CALL getLocaleItem2( const css::lang::Locale& rLocale ) override; |
120 | | |
121 | | // following methods are used by indexentry service |
122 | | /// @throws css::uno::RuntimeException |
123 | | css::uno::Sequence< OUString > getIndexAlgorithm( const css::lang::Locale& rLocale ); |
124 | | /// @throws css::uno::RuntimeException |
125 | | OUString getDefaultIndexAlgorithm( const css::lang::Locale& rLocale ); |
126 | | /// @throws css::uno::RuntimeException |
127 | | OUString getIndexKeysByAlgorithm( |
128 | | const css::lang::Locale& rLocale, std::u16string_view algorithm ); |
129 | | /// @throws css::uno::RuntimeException |
130 | | OUString getIndexModuleByAlgorithm( const css::lang::Locale& rLocale, std::u16string_view algorithm ); |
131 | | /// @throws css::uno::RuntimeException |
132 | | css::uno::Sequence< css::i18n::UnicodeScript > getUnicodeScripts( const css::lang::Locale& rLocale ); |
133 | | /// @throws css::uno::RuntimeException |
134 | | css::uno::Sequence< OUString > getFollowPageWords( const css::lang::Locale& rLocale ); |
135 | | /// @throws css::uno::RuntimeException |
136 | | bool hasPhonetic( const css::lang::Locale& rLocale ); |
137 | | /// @throws css::uno::RuntimeException |
138 | | bool isPhonetic( const css::lang::Locale& rLocale, std::u16string_view algorithm ); |
139 | | /// @throws css::uno::RuntimeException |
140 | | OUString getHangingCharacters( const css::lang::Locale& rLocale ); |
141 | | |
142 | | //XServiceInfo |
143 | | virtual OUString SAL_CALL getImplementationName() override; |
144 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
145 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
146 | | |
147 | | private: |
148 | | ::std::optional< LocaleDataLookupTableItem > moCachedItem; |
149 | | css::i18n::Calendar2 ref_cal; |
150 | | OUString ref_name; |
151 | | |
152 | | /// @throws css::uno::RuntimeException |
153 | | oslGenericFunction getFunctionSymbol( const css::lang::Locale& rLocale, const char* pFunction ); |
154 | | OUString const * getIndexArray(const css::lang::Locale& rLocale, sal_Int16& indexCount); |
155 | | OUString const * getIndexArrayForAlgorithm(const css::lang::Locale& rLocale, std::u16string_view rAlgorithm); |
156 | | /// @throws css::uno::RuntimeException |
157 | | css::uno::Sequence< css::i18n::CalendarItem2 > & |
158 | | getCalendarItemByName(const OUString& name, |
159 | | const css::lang::Locale& rLocale, |
160 | | const css::uno::Sequence< css::i18n::Calendar2 >& calendarsSeq, |
161 | | sal_Int16 item); |
162 | | |
163 | | /// Helper to obtain a sequence of days, months, gmonths or eras. |
164 | | /// |
165 | | /// @throws css::uno::RuntimeException |
166 | | css::uno::Sequence< css::i18n::CalendarItem2 > getCalendarItems( |
167 | | OUString const * allCalendars, |
168 | | sal_Int16 & rnOffset, |
169 | | const sal_Int16 nWhichItem, |
170 | | const sal_Int16 nCalendar, |
171 | | const css::lang::Locale & rLocale, |
172 | | const css::uno::Sequence< css::i18n::Calendar2 > & calendarsSeq ); |
173 | | |
174 | | }; |
175 | | |
176 | | } |
177 | | |
178 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |