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 .
19 #ifndef INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
20 #define INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/i18n/XLocaleData5.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <cppu/macros.hxx>
29 #include <com/sun/star/uno/Reference.h>
31 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/i18n/Calendar.hpp>
33 #include <com/sun/star/i18n/FormatElement.hpp>
34 #include <com/sun/star/i18n/Currency.hpp>
35 #include <com/sun/star/lang/Locale.hpp>
36 #include <com/sun/star/i18n/LocaleDataItem2.hpp>
37 #include <com/sun/star/i18n/UnicodeScript.hpp>
38 #include <com/sun/star/uno/RuntimeException.hpp>
39 #include <com/sun/star/uno/XInterface.hpp>
40 #include <rtl/ref.hxx>
41 #include <rtl/ustring.hxx>
44 #include <osl/module.hxx>
47 #include "defaultnumberingprovider.hxx"
48 #include <com/sun/star/style/NumberingType.hpp>
49 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <com/sun/star/text/HoriOrientation.hpp>
52 #include <com/sun/star/uno/Reference.hxx>
53 #include <com/sun/star/container/XIndexAccess.hpp>
54 #include <com/sun/star/lang/XServiceInfo.hpp>
56 struct LocaleDataLookupTableItem
;
60 class LocaleDataImpl
: public cppu::WeakImplHelper
62 css::i18n::XLocaleData5
,
63 css::lang::XServiceInfo
68 virtual ~LocaleDataImpl() override
;
70 static rtl::Reference
<LocaleDataImpl
> get() { return new LocaleDataImpl
; }
72 static css::uno::Sequence
< css::i18n::CalendarItem
> downcastCalendarItems( const css::uno::Sequence
< css::i18n::CalendarItem2
> & rCi
);
73 static css::i18n::Calendar
downcastCalendar( const css::i18n::Calendar2
& rC
);
75 /** Generates a <Language>_<Country> or <Variant> (if Language=="qlt")
76 string suitable as part of service name with all '-' replaced by '_' */
77 static OUString
getFirstLocaleServiceName( const css::lang::Locale
& rLocale
);
78 /** Generates fallback strings suitable as parts of service names,
79 excluding the one obtained via getFirstLocaleServiceName() */
80 static ::std::vector
< OUString
> getFallbackLocaleServiceNames( const css::lang::Locale
& rLocale
);
82 virtual css::i18n::LanguageCountryInfo SAL_CALL
getLanguageCountryInfo( const css::lang::Locale
& rLocale
) override
;
83 virtual css::i18n::LocaleDataItem SAL_CALL
getLocaleItem( const css::lang::Locale
& rLocale
) override
;
84 virtual css::uno::Sequence
< css::i18n::Calendar2
> SAL_CALL
getAllCalendars2( const css::lang::Locale
& rLocale
) override
;
85 virtual css::uno::Sequence
< css::i18n::Calendar
> SAL_CALL
getAllCalendars( const css::lang::Locale
& rLocale
) override
;
86 virtual css::uno::Sequence
< css::i18n::Currency
> SAL_CALL
getAllCurrencies( const css::lang::Locale
& rLocale
) override
;
87 virtual css::uno::Sequence
< css::i18n::Currency2
> SAL_CALL
getAllCurrencies2( const css::lang::Locale
& rLocale
) override
;
88 virtual css::uno::Sequence
< css::i18n::FormatElement
> SAL_CALL
getAllFormats( const css::lang::Locale
& rLocale
) override
;
89 virtual css::uno::Sequence
< css::i18n::Implementation
> SAL_CALL
getCollatorImplementations( const css::lang::Locale
& rLocale
) override
;
90 /// @throws css::uno::RuntimeException
91 OUString
getCollatorRuleByAlgorithm( const css::lang::Locale
& rLocale
, const OUString
& algorithm
);
92 virtual css::uno::Sequence
< OUString
> SAL_CALL
getTransliterations( const css::lang::Locale
& rLocale
) override
;
93 virtual css::i18n::ForbiddenCharacters SAL_CALL
getForbiddenCharacters( const css::lang::Locale
& rLocale
) override
;
94 virtual css::uno::Sequence
< OUString
> SAL_CALL
getReservedWord( const css::lang::Locale
& rLocale
) override
;
95 /// @throws css::uno::RuntimeException
96 css::uno::Sequence
< OUString
> getBreakIteratorRules( const css::lang::Locale
& rLocale
) ;
97 virtual css::uno::Sequence
< css::lang::Locale
> SAL_CALL
getAllInstalledLocaleNames() override
;
99 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSearchOptions( const css::lang::Locale
& rLocale
) override
;
100 virtual css::uno::Sequence
< OUString
> SAL_CALL
getCollationOptions( const css::lang::Locale
& rLocale
) override
;
101 /// @throws css::uno::RuntimeException
102 css::uno::Sequence
< css::uno::Sequence
< css::beans::PropertyValue
> > getContinuousNumberingLevels( const css::lang::Locale
& rLocale
);
103 /// @throws css::uno::RuntimeException
104 css::uno::Sequence
< css::uno::Reference
< css::container::XIndexAccess
> > getOutlineNumberingLevels( const css::lang::Locale
& rLocale
);
107 virtual css::uno::Sequence
< OUString
> SAL_CALL
getDateAcceptancePatterns( const css::lang::Locale
& rLocale
) override
;
110 virtual css::i18n::LocaleDataItem2 SAL_CALL
getLocaleItem2( const css::lang::Locale
& rLocale
) override
;
112 // following methods are used by indexentry service
113 /// @throws css::uno::RuntimeException
114 css::uno::Sequence
< OUString
> getIndexAlgorithm( const css::lang::Locale
& rLocale
);
115 /// @throws css::uno::RuntimeException
116 OUString
getDefaultIndexAlgorithm( const css::lang::Locale
& rLocale
);
117 /// @throws css::uno::RuntimeException
118 OUString
getIndexKeysByAlgorithm( const css::lang::Locale
& rLocale
, const OUString
& algorithm
);
119 /// @throws css::uno::RuntimeException
120 OUString
getIndexModuleByAlgorithm( const css::lang::Locale
& rLocale
, const OUString
& algorithm
);
121 /// @throws css::uno::RuntimeException
122 css::uno::Sequence
< css::i18n::UnicodeScript
> getUnicodeScripts( const css::lang::Locale
& rLocale
);
123 /// @throws css::uno::RuntimeException
124 css::uno::Sequence
< OUString
> getFollowPageWords( const css::lang::Locale
& rLocale
);
125 /// @throws css::uno::RuntimeException
126 bool hasPhonetic( const css::lang::Locale
& rLocale
);
127 /// @throws css::uno::RuntimeException
128 bool isPhonetic( const css::lang::Locale
& rLocale
, const OUString
& algorithm
);
129 /// @throws css::uno::RuntimeException
130 OUString
getHangingCharacters( const css::lang::Locale
& rLocale
);
133 virtual OUString SAL_CALL
getImplementationName() override
;
134 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
135 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
138 ::std::unique_ptr
< LocaleDataLookupTableItem
> cachedItem
;
139 css::i18n::Calendar2 ref_cal
;
142 /// @throws css::uno::RuntimeException
143 oslGenericFunction
getFunctionSymbol( const css::lang::Locale
& rLocale
, const sal_Char
* pFunction
);
144 sal_Unicode
** getIndexArray(const css::lang::Locale
& rLocale
, sal_Int16
& indexCount
);
145 sal_Unicode
** getIndexArrayForAlgorithm(const css::lang::Locale
& rLocale
, const OUString
& rAlgorithm
);
146 /// @throws css::uno::RuntimeException
147 css::uno::Sequence
< css::i18n::CalendarItem2
> &
148 getCalendarItemByName(const OUString
& name
,
149 const css::lang::Locale
& rLocale
,
150 const css::uno::Sequence
< css::i18n::Calendar2
>& calendarsSeq
,
153 /// Helper to obtain a sequence of days, months, gmonths or eras.
155 /// @throws css::uno::RuntimeException
156 css::uno::Sequence
< css::i18n::CalendarItem2
> getCalendarItems(
157 sal_Unicode
const * const * const allCalendars
,
158 sal_Int16
& rnOffset
,
159 const sal_Int16 nWhichItem
,
160 const sal_Int16 nCalendar
,
161 const css::lang::Locale
& rLocale
,
162 const css::uno::Sequence
< css::i18n::Calendar2
> & calendarsSeq
);
168 #endif // INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */