LibreOffice Module i18npool (master) 1
localedata.hxx
Go to the documentation of this file.
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
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
40namespace com::sun::star::beans { struct PropertyValue; }
41namespace com::sun::star::container { class XIndexAccess; }
42namespace com::sun::star::i18n { struct Currency; }
43namespace com::sun::star::i18n { struct Currency2; }
44namespace com::sun::star::i18n { struct FormatElement; }
45namespace com::sun::star::lang { struct Locale; }
46
47struct LocaleDataLookupTableItem;
48
49namespace i18npool {
50
52{
53 const char* dllName;
54 osl::Module *module;
55 const char* localeName;
56 css::lang::Locale aLocale;
57
58 LocaleDataLookupTableItem(const char *name, osl::Module* m, const char* lname) : dllName(name), module(m), localeName(lname)
59 {
60 }
61 bool equals(const css::lang::Locale& rLocale) const
62 {
63 return (rLocale == aLocale);
64 }
65};
66
67class LocaleDataImpl final : public cppu::WeakImplHelper
68<
69 css::i18n::XLocaleData5,
70 css::lang::XServiceInfo
71>
72{
73public:
75 virtual ~LocaleDataImpl() override;
76
78
79 static css::uno::Sequence< css::i18n::CalendarItem > downcastCalendarItems( const css::uno::Sequence< css::i18n::CalendarItem2 > & rCi );
80 static css::i18n::Calendar downcastCalendar( const css::i18n::Calendar2 & rC );
81
84 static OUString getFirstLocaleServiceName( const css::lang::Locale & rLocale );
87 static ::std::vector< OUString > getFallbackLocaleServiceNames( const css::lang::Locale & rLocale );
88
89 virtual css::i18n::LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const css::lang::Locale& rLocale ) override;
90 virtual css::i18n::LocaleDataItem SAL_CALL getLocaleItem( const css::lang::Locale& rLocale ) override;
91 virtual css::uno::Sequence< css::i18n::Calendar2 > SAL_CALL getAllCalendars2( const css::lang::Locale& rLocale ) override;
92 virtual css::uno::Sequence< css::i18n::Calendar > SAL_CALL getAllCalendars( const css::lang::Locale& rLocale ) override;
93 virtual css::uno::Sequence< css::i18n::Currency > SAL_CALL getAllCurrencies( const css::lang::Locale& rLocale ) override;
94 virtual css::uno::Sequence< css::i18n::Currency2 > SAL_CALL getAllCurrencies2( const css::lang::Locale& rLocale ) override;
95 virtual css::uno::Sequence< css::i18n::FormatElement > SAL_CALL getAllFormats( const css::lang::Locale& rLocale ) override;
96 virtual css::uno::Sequence< css::i18n::Implementation > SAL_CALL getCollatorImplementations( const css::lang::Locale& rLocale ) override;
98 OUString getCollatorRuleByAlgorithm( const css::lang::Locale& rLocale, std::u16string_view algorithm );
99 virtual css::uno::Sequence< OUString > SAL_CALL getTransliterations( const css::lang::Locale& rLocale ) override;
100 virtual css::i18n::ForbiddenCharacters SAL_CALL getForbiddenCharacters( const css::lang::Locale& rLocale ) override;
101 virtual css::uno::Sequence< OUString > SAL_CALL getReservedWord( const css::lang::Locale& rLocale ) override ;
103 css::uno::Sequence< OUString > getBreakIteratorRules( const css::lang::Locale& rLocale ) ;
104 virtual css::uno::Sequence< css::lang::Locale > SAL_CALL getAllInstalledLocaleNames() override;
105
106 virtual css::uno::Sequence< OUString > SAL_CALL getSearchOptions( const css::lang::Locale& rLocale ) override;
107 virtual css::uno::Sequence< OUString > SAL_CALL getCollationOptions( const css::lang::Locale& rLocale ) override;
109 css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getContinuousNumberingLevels( const css::lang::Locale& rLocale );
111 css::uno::Sequence< css::uno::Reference< css::container::XIndexAccess > > getOutlineNumberingLevels( const css::lang::Locale& rLocale );
112
113 // XLocaleData4
114 virtual css::uno::Sequence< OUString > SAL_CALL getDateAcceptancePatterns( const css::lang::Locale& rLocale ) override;
115
116 // XLocaleData5
117 virtual css::i18n::LocaleDataItem2 SAL_CALL getLocaleItem2( const css::lang::Locale& rLocale ) override;
118
119 // following methods are used by indexentry service
121 css::uno::Sequence< OUString > getIndexAlgorithm( const css::lang::Locale& rLocale );
123 OUString getDefaultIndexAlgorithm( const css::lang::Locale& rLocale );
126 const css::lang::Locale& rLocale, std::u16string_view algorithm );
128 OUString getIndexModuleByAlgorithm( const css::lang::Locale& rLocale, std::u16string_view algorithm );
130 css::uno::Sequence< css::i18n::UnicodeScript > getUnicodeScripts( const css::lang::Locale& rLocale );
132 css::uno::Sequence< OUString > getFollowPageWords( const css::lang::Locale& rLocale );
134 bool hasPhonetic( const css::lang::Locale& rLocale );
136 bool isPhonetic( const css::lang::Locale& rLocale, std::u16string_view algorithm );
138 OUString getHangingCharacters( const css::lang::Locale& rLocale );
139
140 //XServiceInfo
141 virtual OUString SAL_CALL getImplementationName() override;
142 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
143 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
144
145private:
146 ::std::optional< LocaleDataLookupTableItem > moCachedItem;
147 css::i18n::Calendar2 ref_cal;
148 OUString ref_name;
149
151 oslGenericFunction getFunctionSymbol( const css::lang::Locale& rLocale, const char* pFunction );
152 sal_Unicode ** getIndexArray(const css::lang::Locale& rLocale, sal_Int16& indexCount);
153 sal_Unicode ** getIndexArrayForAlgorithm(const css::lang::Locale& rLocale, std::u16string_view rAlgorithm);
155 css::uno::Sequence< css::i18n::CalendarItem2 > &
156 getCalendarItemByName(const OUString& name,
157 const css::lang::Locale& rLocale,
158 const css::uno::Sequence< css::i18n::Calendar2 >& calendarsSeq,
159 sal_Int16 item);
160
164 css::uno::Sequence< css::i18n::CalendarItem2 > getCalendarItems(
165 sal_Unicode const * const * const allCalendars,
166 sal_Int16 & rnOffset,
167 const sal_Int16 nWhichItem,
168 const sal_Int16 nCalendar,
169 const css::lang::Locale & rLocale,
170 const css::uno::Sequence< css::i18n::Calendar2 > & calendarsSeq );
171
172};
173
174}
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< LocaleDataImpl > get()
Definition: localedata.hxx:77
virtual OUString SAL_CALL getImplementationName() override
virtual css::i18n::LanguageCountryInfo SAL_CALL getLanguageCountryInfo(const css::lang::Locale &rLocale) override
virtual css::uno::Sequence< css::i18n::FormatElement > SAL_CALL getAllFormats(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:822
css::uno::Sequence< css::uno::Reference< css::container::XIndexAccess > > getOutlineNumberingLevels(const css::lang::Locale &rLocale)
static css::uno::Sequence< css::i18n::CalendarItem > downcastCalendarItems(const css::uno::Sequence< css::i18n::CalendarItem2 > &rCi)
Definition: localedata.cxx:355
css::uno::Sequence< css::i18n::CalendarItem2 > & getCalendarItemByName(const OUString &name, const css::lang::Locale &rLocale, const css::uno::Sequence< css::i18n::Calendar2 > &calendarsSeq, sal_Int16 item)
Definition: localedata.cxx:626
bool hasPhonetic(const css::lang::Locale &rLocale)
virtual css::uno::Sequence< css::i18n::Currency2 > SAL_CALL getAllCurrencies2(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:783
virtual css::uno::Sequence< OUString > SAL_CALL getDateAcceptancePatterns(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:874
virtual css::uno::Sequence< OUString > SAL_CALL getReservedWord(const css::lang::Locale &rLocale) override
css::i18n::Calendar2 ref_cal
Definition: localedata.hxx:147
virtual ~LocaleDataImpl() override
Definition: localedata.cxx:380
virtual css::uno::Sequence< OUString > SAL_CALL getSearchOptions(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:961
sal_Unicode ** getIndexArrayForAlgorithm(const css::lang::Locale &rLocale, std::u16string_view rAlgorithm)
css::uno::Sequence< OUString > getBreakIteratorRules(const css::lang::Locale &rLocale)
virtual css::uno::Sequence< css::i18n::Currency > SAL_CALL getAllCurrencies(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:815
virtual css::i18n::LocaleDataItem SAL_CALL getLocaleItem(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:386
virtual css::uno::Sequence< OUString > SAL_CALL getTransliterations(const css::lang::Locale &rLocale) override
css::uno::Sequence< OUString > getFollowPageWords(const css::lang::Locale &rLocale)
static ::std::vector< OUString > getFallbackLocaleServiceNames(const css::lang::Locale &rLocale)
Generates fallback strings suitable as parts of service names, excluding the one obtained via getFirs...
virtual css::uno::Sequence< css::i18n::Calendar > SAL_CALL getAllCalendars(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:771
sal_Unicode ** getIndexArray(const css::lang::Locale &rLocale, sal_Int16 &indexCount)
Definition: localedata.cxx:981
virtual css::i18n::LocaleDataItem2 SAL_CALL getLocaleItem2(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:424
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getContinuousNumberingLevels(const css::lang::Locale &rLocale)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString getIndexModuleByAlgorithm(const css::lang::Locale &rLocale, std::u16string_view algorithm)
static OUString getFirstLocaleServiceName(const css::lang::Locale &rLocale)
Generates a <Language>_<Country> or <Variant> (if Language=="qlt") string suitable as part of service...
css::uno::Sequence< css::i18n::CalendarItem2 > getCalendarItems(sal_Unicode const *const *const allCalendars, sal_Int16 &rnOffset, const sal_Int16 nWhichItem, const sal_Int16 nCalendar, const css::lang::Locale &rLocale, const css::uno::Sequence< css::i18n::Calendar2 > &calendarsSeq)
Helper to obtain a sequence of days, months, gmonths or eras.
Definition: localedata.cxx:678
bool isPhonetic(const css::lang::Locale &rLocale, std::u16string_view algorithm)
virtual css::uno::Sequence< OUString > SAL_CALL getCollationOptions(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:941
css::uno::Sequence< css::i18n::UnicodeScript > getUnicodeScripts(const css::lang::Locale &rLocale)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< css::lang::Locale > SAL_CALL getAllInstalledLocaleNames() override
css::uno::Sequence< OUString > getIndexAlgorithm(const css::lang::Locale &rLocale)
Definition: localedata.cxx:991
virtual css::uno::Sequence< css::i18n::Implementation > SAL_CALL getCollatorImplementations(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:918
OUString getHangingCharacters(const css::lang::Locale &rLocale)
OUString getCollatorRuleByAlgorithm(const css::lang::Locale &rLocale, std::u16string_view algorithm)
Definition: localedata.cxx:903
oslGenericFunction getFunctionSymbol(const css::lang::Locale &rLocale, const char *pFunction)
OUString getDefaultIndexAlgorithm(const css::lang::Locale &rLocale)
virtual css::i18n::ForbiddenCharacters SAL_CALL getForbiddenCharacters(const css::lang::Locale &rLocale) override
virtual css::uno::Sequence< css::i18n::Calendar2 > SAL_CALL getAllCalendars2(const css::lang::Locale &rLocale) override
Definition: localedata.cxx:725
OUString getIndexKeysByAlgorithm(const css::lang::Locale &rLocale, std::u16string_view algorithm)
static css::i18n::Calendar downcastCalendar(const css::i18n::Calendar2 &rC)
Definition: localedata.cxx:362
::std::optional< LocaleDataLookupTableItem > moCachedItem
Definition: localedata.hxx:146
const char * name
Constant values shared between i18npool and, for example, the number formatter.
m
bool equals(const css::lang::Locale &rLocale) const
Definition: localedata.hxx:61
LocaleDataLookupTableItem(const char *name, osl::Module *m, const char *lname)
Definition: localedata.hxx:58
unsigned char sal_Bool
sal_uInt16 sal_Unicode