LibreOffice Module i18npool (master) 1
registerservices.cxx
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
20#include <config_locales.h>
21
22#include <com/sun/star/lang/XSingleServiceFactory.hpp>
23
26#include <cppuhelper/weak.hxx>
27
28#include <servicename.hxx>
29
33#include <numtotext_cjk.hxx>
34#include <numtochar.hxx>
35#include <texttonum.hxx>
36#include <chartonum.hxx>
37
38#include <calendarImpl.hxx>
40#include <calendar_hijri.hxx>
41#include <calendar_jewish.hxx>
42
43#include <breakiterator_cjk.hxx>
44#include <breakiterator_th.hxx>
45
50
51#include <chaptercollator.hxx>
52#include <collator_unicode.hxx>
53
56
57#include <textconversion.hxx>
58
59using namespace ::com::sun::star;
60using namespace ::com::sun::star::i18n;
61using namespace i18npool;
62
63#define IMPL_CREATEINSTANCE( ImplName ) \
64 static uno::Reference< uno::XInterface > \
65 ImplName##_CreateInstance( \
66 SAL_UNUSED_PARAMETER const uno::Reference< \
67 lang::XMultiServiceFactory >& ) \
68{ \
69 return uno::Reference < \
70 uno::XInterface >( static_cast<cppu::OWeakObject*>( \
71 new ImplName) ); \
72}
73
74#define IMPL_TRANSLITERATION_ITEM( implName ) \
75 { TRLT_SERVICELNAME_L10N, \
76 TRLT_IMPLNAME_PREFIX #implName, \
77 &implName##_CreateInstance }
78
79#define IMPL_UNO_CONSTRUCTOR( ImplName ) \
80extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * \
81i18npool_##ImplName##_get_implementation( \
82 css::uno::XComponentContext *, \
83 css::uno::Sequence<css::uno::Any> const &) \
84{ \
85 return cppu::acquire(new ImplName()); \
86}
87
88#define IMPL_UNO_CONSTRUCTOR_CTX( ImplName ) \
89extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * \
90i18npool_##ImplName##_get_implementation( \
91 css::uno::XComponentContext * context, \
92 css::uno::Sequence<css::uno::Any> const &) \
93{ \
94 return cppu::acquire(new ImplName(context)); \
95}
96
97
98// At least for iOS it doesn't hurt if we have lots of functions here
99// generated by these lovely macros that get compiled, but then no
100// references to them thanks to the WITH_LOCALE ifdefs for the
101// aInstances table below. The -dead_strip linker option will take
102// care of not linking these functions in. Presumably the same holds
103// for Android, too, as we use -ffunction-sections and
104// -Wl,--gc_sections. It's mainly for iOS and Android that the
105// --with-locales option is intended anyway.
106
108IMPL_CREATEINSTANCE( ignoreKashida_CTL )
109IMPL_CREATEINSTANCE( NumToCharIndic_ar )
110IMPL_CREATEINSTANCE( NumToTextCircledNumber )
125IMPL_UNO_CONSTRUCTOR( CharToNumEastIndic_ar )
126IMPL_UNO_CONSTRUCTOR( CharToNumIndic_ar )
133IMPL_UNO_CONSTRUCTOR( NumToCharEastIndic_ar )
134
135#if WITH_LOCALE_ALL || WITH_LOCALE_hi
136IMPL_CREATEINSTANCE( NumToCharIndic_hi )
137IMPL_UNO_CONSTRUCTOR( CharToNumIndic_hi )
139#endif
140
141#if WITH_LOCALE_ALL || WITH_LOCALE_ja
142IMPL_CREATEINSTANCE( fullwidthToHalfwidth )
144IMPL_CREATEINSTANCE( hiraganaToKatakana )
145IMPL_CREATEINSTANCE( ignoreBaFa_ja_JP )
146IMPL_CREATEINSTANCE( ignoreHyuByu_ja_JP )
147IMPL_CREATEINSTANCE( ignoreIandEfollowedByYa_ja_JP )
148IMPL_CREATEINSTANCE( ignoreIterationMark_ja_JP )
149IMPL_CREATEINSTANCE( ignoreKiKuFollowedBySa_ja_JP )
150IMPL_CREATEINSTANCE( ignoreMiddleDot_ja_JP )
151IMPL_CREATEINSTANCE( ignoreMinusSign_ja_JP )
152IMPL_CREATEINSTANCE( ignoreProlongedSoundMark_ja_JP )
153IMPL_CREATEINSTANCE( ignoreSeparator_ja_JP )
154IMPL_CREATEINSTANCE( ignoreSeZe_ja_JP )
155IMPL_CREATEINSTANCE( ignoreSize_ja_JP )
156IMPL_CREATEINSTANCE( ignoreSpace_ja_JP )
157IMPL_CREATEINSTANCE( ignoreTiJi_ja_JP )
158IMPL_CREATEINSTANCE( ignoreTraditionalKana_ja_JP )
159IMPL_CREATEINSTANCE( ignoreTraditionalKanji_ja_JP )
160IMPL_CREATEINSTANCE( ignoreZiZu_ja_JP )
161IMPL_CREATEINSTANCE( katakanaToHiragana )
162IMPL_CREATEINSTANCE( largeToSmall_ja_JP )
163IMPL_CREATEINSTANCE( NumToCharFullwidth )
164IMPL_CREATEINSTANCE( NumToCharHalfwidth )
165IMPL_CREATEINSTANCE( NumToCharKanjiShort_ja_JP )
166IMPL_CREATEINSTANCE( NumToCharKanjiTraditional_ja_JP )
167IMPL_CREATEINSTANCE( NumToTextFullwidth_ja_JP )
168IMPL_CREATEINSTANCE( NumToTextKanjiLongModern_ja_JP )
169IMPL_CREATEINSTANCE( NumToTextKanjiLongTraditional_ja_JP )
170IMPL_CREATEINSTANCE( NumToTextKanjiShortModern_ja_JP )
171IMPL_CREATEINSTANCE( NumToTextKanjiShortTraditional_ja_JP )
172IMPL_CREATEINSTANCE( smallToLarge_ja_JP )
173IMPL_CREATEINSTANCE( TextToNumKanjiLongModern_ja_JP )
174IMPL_CREATEINSTANCE( TextToNumKanjiLongTraditional_ja_JP )
176IMPL_UNO_CONSTRUCTOR( CharToNumFullwidth )
177IMPL_UNO_CONSTRUCTOR( CharToNumKanjiShort_ja_JP )
178IMPL_UNO_CONSTRUCTOR( CharToNumKanjiTraditional_ja_JP )
179IMPL_UNO_CONSTRUCTOR_CTX( IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_consonant )
180IMPL_UNO_CONSTRUCTOR_CTX( IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_syllable )
181IMPL_UNO_CONSTRUCTOR_CTX( IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_consonant )
182IMPL_UNO_CONSTRUCTOR_CTX( IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_syllable )
183IMPL_UNO_CONSTRUCTOR( FULLWIDTH_HALFWIDTH_LIKE_ASC )
184IMPL_UNO_CONSTRUCTOR( FULLWIDTHKATAKANA_HALFWIDTHKATAKANA )
187IMPL_UNO_CONSTRUCTOR( NumToTextAIUFullWidth_ja_JP )
188IMPL_UNO_CONSTRUCTOR( NumToTextAIUHalfWidth_ja_JP )
189IMPL_UNO_CONSTRUCTOR( NumToTextIROHAFullWidth_ja_JP )
190IMPL_UNO_CONSTRUCTOR( NumToTextIROHAHalfWidth_ja_JP )
191#endif
192
193#if WITH_LOCALE_ALL || WITH_LOCALE_ko
194IMPL_CREATEINSTANCE( NumToCharHangul_ko )
195IMPL_CREATEINSTANCE( NumToCharLower_ko )
196IMPL_CREATEINSTANCE( NumToCharUpper_ko )
197IMPL_CREATEINSTANCE( NumToTextFullwidth_ko )
198IMPL_CREATEINSTANCE( TextToNumFormalHangul_ko )
199IMPL_CREATEINSTANCE( TextToNumFormalLower_ko )
200IMPL_CREATEINSTANCE( TextToNumFormalUpper_ko )
201IMPL_CREATEINSTANCE( TextToNumInformalHangul_ko )
202IMPL_CREATEINSTANCE( TextToNumInformalLower_ko )
203IMPL_CREATEINSTANCE( TextToNumInformalUpper_ko )
205IMPL_UNO_CONSTRUCTOR( CharToNumHangul_ko )
206IMPL_UNO_CONSTRUCTOR( CharToNumLower_ko )
207IMPL_UNO_CONSTRUCTOR( CharToNumUpper_ko )
209IMPL_UNO_CONSTRUCTOR( NumToTextFormalHangul_ko )
210IMPL_UNO_CONSTRUCTOR( NumToTextFormalLower_ko )
211IMPL_UNO_CONSTRUCTOR( NumToTextFormalUpper_ko )
212IMPL_UNO_CONSTRUCTOR( NumToTextHangulCircledJamo_ko )
213IMPL_UNO_CONSTRUCTOR( NumToTextHangulCircledSyllable_ko )
214IMPL_UNO_CONSTRUCTOR( NumToTextHangulJamo_ko )
215IMPL_UNO_CONSTRUCTOR( NumToTextHangulSyllable_ko )
216IMPL_UNO_CONSTRUCTOR( NumToTextInformalHangul_ko )
217IMPL_UNO_CONSTRUCTOR( NumToTextInformalLower_ko )
218IMPL_UNO_CONSTRUCTOR( NumToTextInformalUpper_ko )
219#endif
220
221#if WITH_LOCALE_ALL || WITH_LOCALE_th
222IMPL_CREATEINSTANCE( NumToChar_th )
224IMPL_UNO_CONSTRUCTOR( CharToNum_th )
226#endif
227
228#if WITH_LOCALE_ALL || WITH_LOCALE_zh
229IMPL_CREATEINSTANCE( NumToCharLower_zh_CN )
230IMPL_CREATEINSTANCE( NumToCharLower_zh_TW )
231IMPL_CREATEINSTANCE( NumToCharUpper_zh_CN )
232IMPL_CREATEINSTANCE( NumToCharUpper_zh_TW )
233IMPL_CREATEINSTANCE( NumToTextDate_zh )
234IMPL_CREATEINSTANCE( NumToTextDiZi_zh )
235IMPL_CREATEINSTANCE( NumToTextTianGan_zh )
236IMPL_CREATEINSTANCE( TextToChuyin_zh_TW )
237IMPL_CREATEINSTANCE( TextToNumLower_zh_CN )
238IMPL_CREATEINSTANCE( TextToNumLower_zh_TW )
239IMPL_CREATEINSTANCE( TextToNumUpper_zh_CN )
240IMPL_CREATEINSTANCE( TextToNumUpper_zh_TW )
241IMPL_CREATEINSTANCE( TextToPinyin_zh_CN )
244IMPL_UNO_CONSTRUCTOR( CharToNumLower_zh_CN )
245IMPL_UNO_CONSTRUCTOR( CharToNumLower_zh_TW )
246IMPL_UNO_CONSTRUCTOR( CharToNumUpper_zh_CN )
247IMPL_UNO_CONSTRUCTOR( CharToNumUpper_zh_TW )
249IMPL_UNO_CONSTRUCTOR( NumToTextFullwidth_zh_CN )
250IMPL_UNO_CONSTRUCTOR( NumToTextFullwidth_zh_TW )
251IMPL_UNO_CONSTRUCTOR( NumToTextLower_zh_CN )
252IMPL_UNO_CONSTRUCTOR( NumToTextLower_zh_TW )
253IMPL_UNO_CONSTRUCTOR( NumToTextUpper_zh_CN )
254IMPL_UNO_CONSTRUCTOR( NumToTextUpper_zh_TW )
255#endif
256
257namespace {
258
259typedef uno::Reference< uno::XInterface > (*FN_CreateInstance)(
260 const uno::Reference< lang::XMultiServiceFactory >& );
261
262struct InstancesArray {
263 const char* pServiceNm;
264 const char* pImplementationNm;
265 FN_CreateInstance pFn;
266};
267
268}
269
270const InstancesArray aInstances[] = {
272 TRLT_IMPLNAME_PREFIX "UPPERCASE_LOWERCASE",
273 &Transliteration_u2l_CreateInstance },
275 TRLT_IMPLNAME_PREFIX "LOWERCASE_UPPERCASE",
276 &Transliteration_l2u_CreateInstance },
278 TRLT_IMPLNAME_PREFIX "SENTENCE_CASE",
279 &Transliteration_sentencecase_CreateInstance },
281 TRLT_IMPLNAME_PREFIX "TITLE_CASE",
282 &Transliteration_titlecase_CreateInstance },
284 TRLT_IMPLNAME_PREFIX "TOGGLE_CASE",
285 &Transliteration_togglecase_CreateInstance },
286
287 IMPL_TRANSLITERATION_ITEM( NumToCharIndic_ar ),
289 IMPL_TRANSLITERATION_ITEM( ignoreKashida_CTL ),
290 IMPL_TRANSLITERATION_ITEM( NumToTextCircledNumber ),
291
292#if WITH_LOCALE_ALL || WITH_LOCALE_hi
293 IMPL_TRANSLITERATION_ITEM( NumToCharIndic_hi ),
294#endif
295
296#if WITH_LOCALE_ALL || WITH_LOCALE_ja
298 TRLT_IMPLNAME_PREFIX "HIRAGANA_KATAKANA",
299 &hiraganaToKatakana_CreateInstance },
301 TRLT_IMPLNAME_PREFIX "KATAKANA_HIRAGANA",
302 &katakanaToHiragana_CreateInstance },
304 TRLT_IMPLNAME_PREFIX "FULLWIDTH_HALFWIDTH",
305 &fullwidthToHalfwidth_CreateInstance },
307 TRLT_IMPLNAME_PREFIX "HALFWIDTH_FULLWIDTH",
308 &halfwidthToFullwidth_CreateInstance },
309
327 IMPL_TRANSLITERATION_ITEM( NumToCharFullwidth ),
328 IMPL_TRANSLITERATION_ITEM( NumToCharHalfwidth ),
329 IMPL_TRANSLITERATION_ITEM( NumToCharKanjiShort_ja_JP ),
330 IMPL_TRANSLITERATION_ITEM( NumToCharKanjiTraditional_ja_JP ),
331 IMPL_TRANSLITERATION_ITEM( NumToTextFullwidth_ja_JP ),
332 IMPL_TRANSLITERATION_ITEM( NumToTextKanjiLongModern_ja_JP ),
333 IMPL_TRANSLITERATION_ITEM( NumToTextKanjiLongTraditional_ja_JP ),
334 IMPL_TRANSLITERATION_ITEM( NumToTextKanjiShortModern_ja_JP ),
335 IMPL_TRANSLITERATION_ITEM( NumToTextKanjiShortTraditional_ja_JP ),
337 IMPL_TRANSLITERATION_ITEM( TextToNumKanjiLongModern_ja_JP ),
338 IMPL_TRANSLITERATION_ITEM( TextToNumKanjiLongTraditional_ja_JP ),
339#endif
340
341#if WITH_LOCALE_ALL || WITH_LOCALE_ko
342 IMPL_TRANSLITERATION_ITEM( NumToCharHangul_ko ),
343 IMPL_TRANSLITERATION_ITEM( NumToCharLower_ko ),
344 IMPL_TRANSLITERATION_ITEM( NumToCharUpper_ko ),
345 IMPL_TRANSLITERATION_ITEM( NumToTextFullwidth_ko ),
346 IMPL_TRANSLITERATION_ITEM( TextToNumFormalHangul_ko ),
347 IMPL_TRANSLITERATION_ITEM( TextToNumFormalLower_ko ),
348 IMPL_TRANSLITERATION_ITEM( TextToNumFormalUpper_ko ),
349 IMPL_TRANSLITERATION_ITEM( TextToNumInformalHangul_ko ),
350 IMPL_TRANSLITERATION_ITEM( TextToNumInformalLower_ko ),
351 IMPL_TRANSLITERATION_ITEM( TextToNumInformalUpper_ko ),
352#endif
353
354#if WITH_LOCALE_ALL || WITH_LOCALE_th
355 IMPL_TRANSLITERATION_ITEM( NumToChar_th ),
356#endif
357
358#if WITH_LOCALE_ALL || WITH_LOCALE_zh
359 IMPL_TRANSLITERATION_ITEM( NumToCharLower_zh_CN ),
360 IMPL_TRANSLITERATION_ITEM( NumToCharLower_zh_TW ),
361 IMPL_TRANSLITERATION_ITEM( NumToCharUpper_zh_CN ),
362 IMPL_TRANSLITERATION_ITEM( NumToCharUpper_zh_TW ),
363 IMPL_TRANSLITERATION_ITEM( NumToTextDate_zh ),
364 IMPL_TRANSLITERATION_ITEM( NumToTextDiZi_zh ),
365 IMPL_TRANSLITERATION_ITEM( NumToTextTianGan_zh ),
366 IMPL_TRANSLITERATION_ITEM( TextToChuyin_zh_TW ),
367 IMPL_TRANSLITERATION_ITEM( TextToNumLower_zh_CN ),
368 IMPL_TRANSLITERATION_ITEM( TextToNumLower_zh_TW ),
369 IMPL_TRANSLITERATION_ITEM( TextToNumUpper_zh_CN ),
370 IMPL_TRANSLITERATION_ITEM( TextToNumUpper_zh_TW ),
371 IMPL_TRANSLITERATION_ITEM( TextToPinyin_zh_CN ),
372#endif
373
374 { nullptr, nullptr, nullptr }
375};
376
377
378extern "C"
379{
380
381SAL_DLLPUBLIC_EXPORT void* i18npool_component_getFactory( const char* sImplementationName, void* _pServiceManager, SAL_UNUSED_PARAMETER void* /*_pRegistryKey*/ )
382{
383 void* pRet = nullptr;
384
385 lang::XMultiServiceFactory* pServiceManager =
386 static_cast< lang::XMultiServiceFactory* >( _pServiceManager );
387 uno::Reference< lang::XSingleServiceFactory > xFactory;
388
389 for( const InstancesArray* pArr = aInstances; pArr->pServiceNm; ++pArr )
390 {
391 if( 0 == rtl_str_compare( sImplementationName, pArr->pImplementationNm ) )
392 {
393 uno::Sequence< OUString > aServiceNames {
394 OUString::createFromAscii( pArr->pServiceNm ) };
395 xFactory = ::cppu::createSingleFactory(
396 pServiceManager,
397 OUString::createFromAscii( pArr->pImplementationNm ),
398 *pArr->pFn, aServiceNames );
399 break;
400 }
401 }
402
403 if ( xFactory.is() )
404 {
405 xFactory->acquire();
406 pRet = xFactory.get();
407 }
408
409 return pRet;
410}
411
412} // "C"
413
414/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sImplementationName
Reference< XSingleServiceFactory > xFactory
Sequence< OUString > aServiceNames
Constant values shared between i18npool and, for example, the number formatter.
const InstancesArray aInstances[]
#define IMPL_UNO_CONSTRUCTOR(ImplName)
SAL_DLLPUBLIC_EXPORT void * i18npool_component_getFactory(const char *sImplementationName, void *_pServiceManager, SAL_UNUSED_PARAMETER void *)
#define IMPL_UNO_CONSTRUCTOR_CTX(ImplName)
#define IMPL_CREATEINSTANCE(ImplName)
#define IMPL_TRANSLITERATION_ITEM(implName)
#define TRLT_SERVICELNAME_L10N
Definition: servicename.hxx:59
#define TRLT_IMPLNAME_PREFIX
Definition: servicename.hxx:61