Line data Source code
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 : #ifndef INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
20 : #define INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
21 :
22 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 :
24 : #include <comphelper/processfactory.hxx>
25 :
26 : #include <com/sun/star/i18n/XLocaleData4.hpp>
27 :
28 :
29 : #include <cppuhelper/implbase2.hxx>
30 : #include <cppu/macros.hxx>
31 : #include <com/sun/star/uno/Reference.h>
32 :
33 : #include <com/sun/star/uno/Sequence.h>
34 : #include <com/sun/star/i18n/Calendar.hpp>
35 : #include <com/sun/star/i18n/FormatElement.hpp>
36 : #include <com/sun/star/i18n/Currency.hpp>
37 : #include <com/sun/star/lang/Locale.hpp>
38 : #include <com/sun/star/i18n/LocaleDataItem.hpp>
39 : #include <com/sun/star/i18n/UnicodeScript.hpp>
40 : #include <com/sun/star/uno/RuntimeException.hpp>
41 : #include <com/sun/star/uno/XInterface.hpp>
42 : #include <rtl/ustring.hxx>
43 : #include <vector>
44 : #include <memory>
45 : #include <osl/module.hxx>
46 :
47 :
48 : #include <defaultnumberingprovider.hxx>
49 : #include <com/sun/star/style/NumberingType.hpp>
50 : #include <com/sun/star/beans/PropertyValue.hpp>
51 : #include <com/sun/star/text/HoriOrientation.hpp>
52 :
53 : #include <com/sun/star/uno/Reference.hxx>
54 : #include <com/sun/star/container/XIndexAccess.hpp>
55 : #include <com/sun/star/lang/XServiceInfo.hpp>
56 :
57 : struct LocaleDataLookupTableItem;
58 :
59 : namespace com { namespace sun { namespace star { namespace i18n {
60 :
61 85493054 : inline bool operator ==(const com::sun::star::lang::Locale& l1, const com::sun::star::lang::Locale& l2) {
62 85493054 : return l1.Language == l2.Language && l1.Country == l2.Country && l1.Variant == l2.Variant;
63 : };
64 :
65 : class LocaleDataImpl : public cppu::WeakImplHelper2
66 : <
67 : com::sun::star::i18n::XLocaleData4,
68 : com::sun::star::lang::XServiceInfo
69 : >
70 : {
71 : public:
72 : LocaleDataImpl();
73 : virtual ~LocaleDataImpl();
74 :
75 : static com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > downcastCalendarItems( const com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > & rCi );
76 : static com::sun::star::i18n::Calendar downcastCalendar( const com::sun::star::i18n::Calendar2 & rC );
77 :
78 : /** Generates a <Language>_<Country> or <Variant> (if Language=="qlt")
79 : string suitable as part of service name with all '-' replaced by '_' */
80 : static OUString getFirstLocaleServiceName( const com::sun::star::lang::Locale & rLocale );
81 : /** Generates fallback strings suitable as parts of service names,
82 : excluding the one obtained via getFirstLocaleServiceName() */
83 : static ::std::vector< OUString > getFallbackLocaleServiceNames( const com::sun::star::lang::Locale & rLocale );
84 :
85 : virtual LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual LocaleDataItem SAL_CALL getLocaleItem( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual com::sun::star::uno::Sequence< Calendar2 > SAL_CALL getAllCalendars2( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 : virtual com::sun::star::uno::Sequence< Calendar > SAL_CALL getAllCalendars( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 : virtual com::sun::star::uno::Sequence< Currency > SAL_CALL getAllCurrencies( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual com::sun::star::uno::Sequence< Currency2 > SAL_CALL getAllCurrencies2( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 : virtual com::sun::star::uno::Sequence< FormatElement > SAL_CALL getAllFormats( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 : virtual com::sun::star::uno::Sequence< Implementation > SAL_CALL getCollatorImplementations( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 : virtual OUString SAL_CALL getCollatorRuleByAlgorithm( const com::sun::star::lang::Locale& rLocale, const OUString& algorithm ) throw(com::sun::star::uno::RuntimeException);
94 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getTransliterations( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 : virtual ForbiddenCharacters SAL_CALL getForbiddenCharacters( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getReservedWord( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
97 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getBreakIteratorRules( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException) ;
98 : virtual com::sun::star::uno::Sequence< com::sun::star::lang::Locale > SAL_CALL getAllInstalledLocaleNames() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 :
100 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSearchOptions( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getCollationOptions( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< beans::PropertyValue > > SAL_CALL getContinuousNumberingLevels( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
103 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Reference< container::XIndexAccess > > SAL_CALL getOutlineNumberingLevels( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
104 :
105 : // XLocaleData4
106 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getDateAcceptancePatterns( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : // following methods are used by indexentry service
109 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getIndexAlgorithm( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
110 : virtual OUString SAL_CALL getDefaultIndexAlgorithm( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
111 : virtual OUString SAL_CALL getIndexKeysByAlgorithm( const com::sun::star::lang::Locale& rLocale, const OUString& algorithm ) throw(com::sun::star::uno::RuntimeException);
112 : virtual OUString SAL_CALL getIndexModuleByAlgorithm( const com::sun::star::lang::Locale& rLocale, const OUString& algorithm ) throw(com::sun::star::uno::RuntimeException);
113 : virtual com::sun::star::uno::Sequence< UnicodeScript > SAL_CALL getUnicodeScripts( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
114 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getFollowPageWords( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
115 : virtual bool SAL_CALL hasPhonetic( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
116 : virtual bool SAL_CALL isPhonetic( const com::sun::star::lang::Locale& rLocale, const OUString& algorithm ) throw(com::sun::star::uno::RuntimeException);
117 : virtual OUString SAL_CALL getHangingCharacters( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
118 :
119 : //XServiceInfo
120 : virtual OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
121 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
122 : virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
123 :
124 : private :
125 : friend bool operator ==(const com::sun::star::lang::Locale& l1, const com::sun::star::lang::Locale& l2);
126 :
127 : ::std::unique_ptr< LocaleDataLookupTableItem > cachedItem;
128 :
129 : oslGenericFunction SAL_CALL getFunctionSymbol( const com::sun::star::lang::Locale& rLocale, const sal_Char* pFunction ) throw( com::sun::star::uno::RuntimeException );
130 : oslGenericFunction SAL_CALL getFunctionSymbolByName( const OUString& localeName, const sal_Char* pFunction );
131 : sal_Unicode ** SAL_CALL getIndexArray(const com::sun::star::lang::Locale& rLocale, sal_Int16& indexCount);
132 : sal_Unicode ** SAL_CALL getIndexArrayForAlgorithm(const com::sun::star::lang::Locale& rLocale, const OUString& rAlgorithm);
133 : com::sun::star::i18n::Calendar2 ref_cal;
134 : OUString ref_name;
135 : com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > &
136 : getCalendarItemByName(const OUString& name,
137 : const com::sun::star::lang::Locale& rLocale,
138 : const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar2 >& calendarsSeq,
139 : sal_Int16 item) throw( com::sun::star::uno::RuntimeException );
140 :
141 : /// Helper to obtain a sequence of days, months, gmonths or eras.
142 : com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > getCalendarItems(
143 : sal_Unicode const * const * const allCalendars,
144 : sal_Int16 & rnOffset,
145 : const sal_Int16 nWhichItem,
146 : const sal_Int16 nCalendar,
147 : const com::sun::star::lang::Locale & rLocale,
148 : const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar2 > & calendarsSeq )
149 : throw( com::sun::star::uno::RuntimeException );
150 :
151 : };
152 :
153 : } } } }
154 :
155 : #endif // INCLUDED_I18NPOOL_INC_LOCALEDATA_HXX
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|