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 :
20 : #include <cppuhelper/supportsservice.hxx>
21 : #include <localedata.hxx>
22 : #include <i18nlangtag/mslangid.hxx>
23 : #include <i18nlangtag/languagetag.hxx>
24 : #include <rtl/ustrbuf.hxx>
25 : #include <string.h>
26 : #include <stdio.h>
27 : #include "rtl/instance.hxx"
28 : #include <sal/macros.h>
29 :
30 : using namespace com::sun::star::i18n;
31 : using namespace com::sun::star::uno;
32 : using namespace com::sun::star::lang;
33 : using namespace com::sun::star;
34 :
35 : typedef sal_Unicode** (SAL_CALL * MyFunc_Type)( sal_Int16&);
36 : typedef sal_Unicode*** (SAL_CALL * MyFunc_Type2)( sal_Int16&, sal_Int16& );
37 : typedef sal_Unicode**** (SAL_CALL * MyFunc_Type3)( sal_Int16&, sal_Int16&, sal_Int16& );
38 : typedef sal_Unicode const * const * (SAL_CALL * MyFunc_FormatCode)( sal_Int16&, sal_Unicode const *&, sal_Unicode const *& );
39 :
40 : #ifndef DISABLE_DYNLOADING
41 :
42 : static const char *lcl_DATA_EN = "localedata_en";
43 : static const char *lcl_DATA_ES = "localedata_es";
44 : static const char *lcl_DATA_EURO = "localedata_euro";
45 : static const char *lcl_DATA_OTHERS = "localedata_others";
46 :
47 : #endif
48 :
49 : #ifndef DISABLE_DYNLOADING
50 :
51 : static const struct {
52 : const char* pLocale;
53 : const char* pLib;
54 : } aLibTable[] = {
55 : { "en_US", lcl_DATA_EN },
56 : { "en_AU", lcl_DATA_EN },
57 : { "en_BZ", lcl_DATA_EN },
58 : { "en_CA", lcl_DATA_EN },
59 : { "en_GB", lcl_DATA_EN },
60 : { "en_IE", lcl_DATA_EN },
61 : { "en_JM", lcl_DATA_EN },
62 : { "en_NZ", lcl_DATA_EN },
63 : { "en_PH", lcl_DATA_EN },
64 : { "en_TT", lcl_DATA_EN },
65 : { "en_ZA", lcl_DATA_EN },
66 : { "en_ZW", lcl_DATA_EN },
67 : { "en_NA", lcl_DATA_EN },
68 : { "en_GH", lcl_DATA_EN },
69 : { "en_MW", lcl_DATA_EN },
70 :
71 : { "es_ES", lcl_DATA_ES },
72 : { "es_AR", lcl_DATA_ES },
73 : { "es_BO", lcl_DATA_ES },
74 : { "es_CL", lcl_DATA_ES },
75 : { "es_CO", lcl_DATA_ES },
76 : { "es_CR", lcl_DATA_ES },
77 : { "es_DO", lcl_DATA_ES },
78 : { "es_EC", lcl_DATA_ES },
79 : { "es_GT", lcl_DATA_ES },
80 : { "es_HN", lcl_DATA_ES },
81 : { "es_MX", lcl_DATA_ES },
82 : { "es_NI", lcl_DATA_ES },
83 : { "es_PA", lcl_DATA_ES },
84 : { "es_PE", lcl_DATA_ES },
85 : { "es_PR", lcl_DATA_ES },
86 : { "es_PY", lcl_DATA_ES },
87 : { "es_SV", lcl_DATA_ES },
88 : { "es_UY", lcl_DATA_ES },
89 : { "es_VE", lcl_DATA_ES },
90 : { "gl_ES", lcl_DATA_ES },
91 :
92 : { "de_DE", lcl_DATA_EURO },
93 : { "de_AT", lcl_DATA_EURO },
94 : { "de_CH", lcl_DATA_EURO },
95 : { "de_LI", lcl_DATA_EURO },
96 : { "de_LU", lcl_DATA_EURO },
97 : { "fr_FR", lcl_DATA_EURO },
98 : { "fr_BE", lcl_DATA_EURO },
99 : { "fr_CA", lcl_DATA_EURO },
100 : { "fr_CH", lcl_DATA_EURO },
101 : { "fr_LU", lcl_DATA_EURO },
102 : { "fr_MC", lcl_DATA_EURO },
103 : { "fr_BF", lcl_DATA_EURO },
104 : { "it_IT", lcl_DATA_EURO },
105 : { "it_CH", lcl_DATA_EURO },
106 : { "sl_SI", lcl_DATA_EURO },
107 : { "sv_SE", lcl_DATA_EURO },
108 : { "sv_FI", lcl_DATA_EURO },
109 : { "ca_ES", lcl_DATA_EURO },
110 : { "cs_CZ", lcl_DATA_EURO },
111 : { "sk_SK", lcl_DATA_EURO },
112 : { "da_DK", lcl_DATA_EURO },
113 : { "el_GR", lcl_DATA_EURO },
114 : { "fi_FI", lcl_DATA_EURO },
115 : { "is_IS", lcl_DATA_EURO },
116 : { "nl_BE", lcl_DATA_EURO },
117 : { "nl_NL", lcl_DATA_EURO },
118 : { "no_NO", lcl_DATA_EURO },
119 : { "nn_NO", lcl_DATA_EURO },
120 : { "nb_NO", lcl_DATA_EURO },
121 : { "nds_DE", lcl_DATA_EURO },
122 : { "pl_PL", lcl_DATA_EURO },
123 : { "pt_BR", lcl_DATA_EURO },
124 : { "pt_PT", lcl_DATA_EURO },
125 : { "ru_RU", lcl_DATA_EURO },
126 : { "tr_TR", lcl_DATA_EURO },
127 : { "et_EE", lcl_DATA_EURO },
128 : { "lb_LU", lcl_DATA_EURO },
129 : { "lt_LT", lcl_DATA_EURO },
130 : { "lv_LV", lcl_DATA_EURO },
131 : { "uk_UA", lcl_DATA_EURO },
132 : { "ro_RO", lcl_DATA_EURO },
133 : { "cy_GB", lcl_DATA_EURO },
134 : { "bg_BG", lcl_DATA_EURO },
135 : { "sr_Latn_ME", lcl_DATA_EURO },
136 : { "sr_Latn_RS", lcl_DATA_EURO },
137 : { "sr_Latn_CS", lcl_DATA_EURO },
138 : { "sr_ME", lcl_DATA_EURO },
139 : { "sr_RS", lcl_DATA_EURO },
140 : { "sr_CS", lcl_DATA_EURO },
141 : { "hr_HR", lcl_DATA_EURO },
142 : { "bs_BA", lcl_DATA_EURO },
143 : { "eu", lcl_DATA_EURO },
144 : { "fo_FO", lcl_DATA_EURO },
145 : { "ga_IE", lcl_DATA_EURO },
146 : { "gd_GB", lcl_DATA_EURO },
147 : { "ka_GE", lcl_DATA_EURO },
148 : { "be_BY", lcl_DATA_EURO },
149 : { "kl_GL", lcl_DATA_EURO },
150 : { "mk_MK", lcl_DATA_EURO },
151 : { "br_FR", lcl_DATA_EURO },
152 : { "la_VA", lcl_DATA_EURO },
153 : { "cv_RU", lcl_DATA_EURO },
154 : { "wa_BE", lcl_DATA_EURO },
155 : { "fur_IT", lcl_DATA_EURO },
156 : { "gsc_FR", lcl_DATA_EURO },
157 : { "fy_NL", lcl_DATA_EURO },
158 : { "oc_FR", lcl_DATA_EURO },
159 : { "mt_MT", lcl_DATA_EURO },
160 : { "sc_IT", lcl_DATA_EURO },
161 : { "ast_ES", lcl_DATA_EURO },
162 : { "ltg_LV", lcl_DATA_EURO },
163 : { "hsb_DE", lcl_DATA_EURO },
164 : { "dsb_DE", lcl_DATA_EURO },
165 : { "rue_SK", lcl_DATA_EURO },
166 : { "an_ES", lcl_DATA_EURO },
167 : { "myv_RU", lcl_DATA_EURO },
168 : { "lld_IT", lcl_DATA_EURO },
169 :
170 : { "ja_JP", lcl_DATA_OTHERS },
171 : { "ko_KR", lcl_DATA_OTHERS },
172 : { "zh_CN", lcl_DATA_OTHERS },
173 : { "zh_HK", lcl_DATA_OTHERS },
174 : { "zh_SG", lcl_DATA_OTHERS },
175 : { "zh_TW", lcl_DATA_OTHERS },
176 : { "zh_MO", lcl_DATA_OTHERS },
177 :
178 : { "ar_EG", lcl_DATA_OTHERS },
179 : { "ar_DZ", lcl_DATA_OTHERS },
180 : { "ar_LB", lcl_DATA_OTHERS },
181 : { "ar_SA", lcl_DATA_OTHERS },
182 : { "ar_TN", lcl_DATA_OTHERS },
183 : { "he_IL", lcl_DATA_OTHERS },
184 : { "hi_IN", lcl_DATA_OTHERS },
185 : { "kn_IN", lcl_DATA_OTHERS },
186 : { "ta_IN", lcl_DATA_OTHERS },
187 : { "te_IN", lcl_DATA_OTHERS },
188 : { "gu_IN", lcl_DATA_OTHERS },
189 : { "mr_IN", lcl_DATA_OTHERS },
190 : { "pa_IN", lcl_DATA_OTHERS },
191 : { "bn_IN", lcl_DATA_OTHERS },
192 : { "or_IN", lcl_DATA_OTHERS },
193 : { "en_IN", lcl_DATA_OTHERS },
194 : { "ml_IN", lcl_DATA_OTHERS },
195 : { "bn_BD", lcl_DATA_OTHERS },
196 : { "th_TH", lcl_DATA_OTHERS },
197 :
198 : { "af_ZA", lcl_DATA_OTHERS },
199 : { "hu_HU", lcl_DATA_OTHERS },
200 : { "id_ID", lcl_DATA_OTHERS },
201 : { "ms_MY", lcl_DATA_OTHERS },
202 : { "ia", lcl_DATA_OTHERS },
203 : { "mn_Cyrl_MN", lcl_DATA_OTHERS },
204 : { "az_AZ", lcl_DATA_OTHERS },
205 : { "sw_TZ", lcl_DATA_OTHERS },
206 : { "km_KH", lcl_DATA_OTHERS },
207 : { "lo_LA", lcl_DATA_OTHERS },
208 : { "rw_RW", lcl_DATA_OTHERS },
209 : { "eo", lcl_DATA_OTHERS },
210 : { "dz_BT", lcl_DATA_OTHERS },
211 : { "ne_NP", lcl_DATA_OTHERS },
212 : { "zu_ZA", lcl_DATA_OTHERS },
213 : { "nso_ZA", lcl_DATA_OTHERS },
214 : { "vi_VN", lcl_DATA_OTHERS },
215 : { "tn_ZA", lcl_DATA_OTHERS },
216 : { "xh_ZA", lcl_DATA_OTHERS },
217 : { "st_ZA", lcl_DATA_OTHERS },
218 : { "ss_ZA", lcl_DATA_OTHERS },
219 : { "ve_ZA", lcl_DATA_OTHERS },
220 : { "nr_ZA", lcl_DATA_OTHERS },
221 : { "ts_ZA", lcl_DATA_OTHERS },
222 : { "kmr_Latn_TR", lcl_DATA_OTHERS },
223 : { "ak_GH", lcl_DATA_OTHERS },
224 : { "af_NA", lcl_DATA_OTHERS },
225 : { "am_ET", lcl_DATA_OTHERS },
226 : { "ti_ER", lcl_DATA_OTHERS },
227 : { "tg_TJ", lcl_DATA_OTHERS },
228 : { "ky_KG", lcl_DATA_OTHERS },
229 : { "kk_KZ", lcl_DATA_OTHERS },
230 : { "fa_IR", lcl_DATA_OTHERS },
231 : { "ha_Latn_GH", lcl_DATA_OTHERS },
232 : { "ee_GH", lcl_DATA_OTHERS },
233 : { "sg_CF", lcl_DATA_OTHERS },
234 : { "lg_UG", lcl_DATA_OTHERS },
235 : { "uz_UZ", lcl_DATA_OTHERS },
236 : { "ln_CD", lcl_DATA_OTHERS },
237 : { "hy_AM", lcl_DATA_OTHERS },
238 : { "hil_PH", lcl_DATA_OTHERS },
239 : { "so_SO", lcl_DATA_OTHERS },
240 : { "gug_PY", lcl_DATA_OTHERS },
241 : { "tk_TM", lcl_DATA_OTHERS },
242 : { "my_MM", lcl_DATA_OTHERS },
243 : { "shs_CA", lcl_DATA_OTHERS },
244 : { "tpi_PG", lcl_DATA_OTHERS },
245 : { "ar_OM", lcl_DATA_OTHERS },
246 : { "ug_CN", lcl_DATA_OTHERS },
247 : { "om_ET", lcl_DATA_OTHERS },
248 : { "plt_MG", lcl_DATA_OTHERS },
249 : { "mai_IN", lcl_DATA_OTHERS },
250 : { "yi_US", lcl_DATA_OTHERS },
251 : { "haw_US", lcl_DATA_OTHERS },
252 : { "lif_NP", lcl_DATA_OTHERS },
253 : { "ur_PK", lcl_DATA_OTHERS },
254 : { "ht_HT", lcl_DATA_OTHERS },
255 : { "jbo", lcl_DATA_OTHERS },
256 : { "kab_DZ", lcl_DATA_OTHERS },
257 : { "pt_AO", lcl_DATA_OTHERS },
258 : { "pjt_AU", lcl_DATA_OTHERS },
259 : { "pap_CW", lcl_DATA_OTHERS },
260 : { "ebo_CG", lcl_DATA_OTHERS },
261 : { "tyx_CG", lcl_DATA_OTHERS },
262 : { "axk_CG", lcl_DATA_OTHERS },
263 : { "beq_CG", lcl_DATA_OTHERS },
264 : { "bkw_CG", lcl_DATA_OTHERS },
265 : { "bvx_CG", lcl_DATA_OTHERS },
266 : { "dde_CG", lcl_DATA_OTHERS },
267 : { "iyx_CG", lcl_DATA_OTHERS },
268 : { "kkw_CG", lcl_DATA_OTHERS },
269 : { "kng_CG", lcl_DATA_OTHERS },
270 : { "ldi_CG", lcl_DATA_OTHERS },
271 : { "mdw_CG", lcl_DATA_OTHERS },
272 : { "mkw_CG", lcl_DATA_OTHERS },
273 : { "njx_CG", lcl_DATA_OTHERS },
274 : { "ngz_CG", lcl_DATA_OTHERS },
275 : { "njy_CG", lcl_DATA_OTHERS },
276 : { "puu_CG", lcl_DATA_OTHERS },
277 : { "sdj_CG", lcl_DATA_OTHERS },
278 : { "tek_CG", lcl_DATA_OTHERS },
279 : { "tsa_CG", lcl_DATA_OTHERS },
280 : { "vif_CG", lcl_DATA_OTHERS },
281 : { "xku_CG", lcl_DATA_OTHERS },
282 : { "yom_CG", lcl_DATA_OTHERS },
283 : { "sid_ET", lcl_DATA_OTHERS },
284 : { "bo_CN", lcl_DATA_OTHERS },
285 : { "bo_IN", lcl_DATA_OTHERS },
286 : { "ar_AE", lcl_DATA_OTHERS },
287 : { "ar_KW", lcl_DATA_OTHERS },
288 : { "bm_ML", lcl_DATA_OTHERS },
289 : { "pui_CO", lcl_DATA_OTHERS },
290 : { "lgr_SB", lcl_DATA_OTHERS }
291 165 : };
292 :
293 : #else
294 :
295 : #include "localedata_static.hxx"
296 :
297 : #endif
298 :
299 : static const sal_Unicode cUnder = '_';
300 : static const sal_Unicode cHyphen = '-';
301 :
302 : static const sal_Int16 nbOfLocales = SAL_N_ELEMENTS(aLibTable);
303 :
304 141659 : struct LocaleDataLookupTableItem
305 : {
306 262 : LocaleDataLookupTableItem(const sal_Char *name, osl::Module* m, const sal_Char* lname) : dllName(name), module(m), localeName(lname)
307 : {
308 262 : }
309 : const sal_Char* dllName;
310 : osl::Module *module;
311 : const sal_Char* localeName;
312 :
313 : com::sun::star::lang::Locale aLocale;
314 113177 : sal_Bool equals(const com::sun::star::lang::Locale& rLocale)
315 : {
316 113177 : return (rLocale == aLocale);
317 : }
318 : };
319 :
320 :
321 : // static
322 0 : Sequence< CalendarItem > LocaleDataImpl::downcastCalendarItems( const Sequence< CalendarItem2 > & rCi )
323 : {
324 0 : sal_Int32 nSize = rCi.getLength();
325 0 : Sequence< CalendarItem > aCi( nSize);
326 0 : CalendarItem* p1 = aCi.getArray();
327 0 : const CalendarItem2* p2 = rCi.getConstArray();
328 0 : for (sal_Int32 i=0; i < nSize; ++i, ++p1, ++p2)
329 0 : *p1 = *p2;
330 0 : return aCi;
331 : }
332 :
333 :
334 : // static
335 0 : Calendar LocaleDataImpl::downcastCalendar( const Calendar2 & rC )
336 : {
337 : Calendar aCal(
338 : downcastCalendarItems( rC.Days),
339 : downcastCalendarItems( rC.Months),
340 : downcastCalendarItems( rC.Eras),
341 : rC.StartOfWeek,
342 : rC.MinimumNumberOfDaysForFirstWeek,
343 : rC.Default,
344 : rC.Name
345 0 : );
346 0 : return aCal;
347 : }
348 :
349 :
350 60028 : LocaleDataImpl::LocaleDataImpl()
351 : {
352 60028 : }
353 113437 : LocaleDataImpl::~LocaleDataImpl()
354 : {
355 113437 : }
356 :
357 :
358 : LocaleDataItem SAL_CALL
359 36908 : LocaleDataImpl::getLocaleItem( const Locale& rLocale ) throw(RuntimeException, std::exception)
360 : {
361 36908 : sal_Unicode **dataItem = NULL;
362 :
363 36908 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getLocaleItem" );
364 :
365 36908 : if ( func ) {
366 36908 : sal_Int16 dataItemCount = 0;
367 36908 : dataItem = func(dataItemCount);
368 :
369 : LocaleDataItem item(
370 : dataItem[0],
371 36908 : dataItem[1],
372 36908 : dataItem[2],
373 36908 : dataItem[3],
374 36908 : dataItem[4],
375 36908 : dataItem[5],
376 36908 : dataItem[6],
377 36908 : dataItem[7],
378 36908 : dataItem[8],
379 36908 : dataItem[9],
380 36908 : dataItem[10],
381 36908 : dataItem[11],
382 36908 : dataItem[12],
383 36908 : dataItem[13],
384 36908 : dataItem[14],
385 36908 : dataItem[15],
386 36908 : dataItem[16],
387 36908 : dataItem[17]
388 627436 : );
389 36908 : return item;
390 : }
391 : else {
392 0 : LocaleDataItem item1;
393 0 : return item1;
394 : }
395 : }
396 :
397 : #ifndef DISABLE_DYNLOADING
398 :
399 0 : extern "C" { static void SAL_CALL thisModule() {} }
400 :
401 : #endif
402 :
403 : namespace
404 : {
405 :
406 : // implement the lookup table as a safe static object
407 : class lcl_LookupTableHelper
408 : {
409 : public:
410 : lcl_LookupTableHelper();
411 : ~lcl_LookupTableHelper();
412 :
413 : oslGenericFunction SAL_CALL getFunctionSymbolByName(
414 : const OUString& localeName, const sal_Char* pFunction,
415 : LocaleDataLookupTableItem** pOutCachedItem );
416 :
417 : private:
418 : ::osl::Mutex maMutex;
419 : ::std::vector< LocaleDataLookupTableItem* > maLookupTable;
420 : };
421 :
422 : // from instance.hxx: Helper base class for a late-initialized
423 : // (default-constructed) static variable, implementing the double-checked
424 : // locking pattern correctly.
425 : // usage: lcl_LookupTableHelper & rLookupTable = lcl_LookupTableStatic::get();
426 : // retrieves the singleton lookup table instance
427 : struct lcl_LookupTableStatic : public ::rtl::Static< lcl_LookupTableHelper, lcl_LookupTableStatic >
428 : {};
429 :
430 158 : lcl_LookupTableHelper::lcl_LookupTableHelper()
431 : {
432 158 : }
433 :
434 316 : lcl_LookupTableHelper::~lcl_LookupTableHelper()
435 : {
436 158 : LocaleDataLookupTableItem* pItem = 0;
437 :
438 158 : std::vector<LocaleDataLookupTableItem*>::const_iterator aEnd(maLookupTable.end());
439 158 : std::vector<LocaleDataLookupTableItem*>::iterator aIter(maLookupTable.begin());
440 :
441 420 : for ( ; aIter != aEnd; ++aIter ) {
442 262 : pItem = *aIter;
443 262 : delete pItem->module;
444 262 : delete pItem;
445 : }
446 158 : maLookupTable.clear();
447 158 : }
448 :
449 70812 : oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName(
450 : const OUString& localeName, const sal_Char* pFunction,
451 : LocaleDataLookupTableItem** pOutCachedItem )
452 : {
453 70812 : OUString aFallback;
454 70812 : bool bFallback = (localeName.indexOf( cUnder) < 0);
455 70812 : if (bFallback)
456 : {
457 1039 : Locale aLocale;
458 1039 : aLocale.Language = localeName;
459 2078 : Locale aFbLocale = MsLangId::getFallbackLocale( aLocale);
460 1039 : if (aFbLocale == aLocale)
461 312 : bFallback = false; // may be a "language-only-locale" like Interlingua (ia)
462 : else
463 1766 : aFallback = LocaleDataImpl::getFirstLocaleServiceName( aFbLocale);
464 : }
465 :
466 2169977 : for ( sal_Int16 i = 0; i < nbOfLocales; i++)
467 : {
468 2240787 : if (localeName.equalsAscii(aLibTable[i].pLocale) ||
469 957 : (bFallback && aFallback.equalsAscii(aLibTable[i].pLocale)))
470 : {
471 : #ifndef DISABLE_DYNLOADING
472 70811 : LocaleDataLookupTableItem* pCurrent = 0;
473 70811 : OUStringBuffer aBuf(strlen(aLibTable[i].pLocale) + 1 + strlen(pFunction));
474 : {
475 70811 : ::osl::MutexGuard aGuard( maMutex );
476 112763 : for (size_t l = 0; l < maLookupTable.size(); l++)
477 : {
478 112501 : pCurrent = maLookupTable[l];
479 112501 : if (pCurrent->dllName == aLibTable[i].pLib)
480 : {
481 : OSL_ASSERT( pOutCachedItem );
482 70549 : if( pOutCachedItem )
483 : {
484 70549 : (*pOutCachedItem) = new LocaleDataLookupTableItem( *pCurrent );
485 70549 : (*pOutCachedItem)->localeName = aLibTable[i].pLocale;
486 : return (*pOutCachedItem)->module->getFunctionSymbol(
487 70549 : aBuf.appendAscii( pFunction).append( cUnder).
488 141098 : appendAscii( (*pOutCachedItem)->localeName).makeStringAndClear());
489 : }
490 : else
491 0 : return NULL;
492 : }
493 262 : }
494 : }
495 : // Library not loaded, load it and add it to the list.
496 : #ifdef SAL_DLLPREFIX
497 262 : aBuf.ensureCapacity(strlen(aLibTable[i].pLib) + 6); // mostly "lib*.so"
498 262 : aBuf.appendAscii( SAL_DLLPREFIX ).appendAscii(aLibTable[i].pLib).appendAscii( SAL_DLLEXTENSION );
499 : #else
500 : aBuf.ensureCapacity(strlen(aLibTable[i].pLib) + 4); // mostly "*.dll"
501 : aBuf.appendAscii(aLibTable[i].pLib).appendAscii( SAL_DLLEXTENSION );
502 : #endif
503 262 : osl::Module *module = new osl::Module();
504 262 : if ( module->loadRelative(&thisModule, aBuf.makeStringAndClear()) )
505 : {
506 262 : ::osl::MutexGuard aGuard( maMutex );
507 262 : LocaleDataLookupTableItem* pNewItem = new LocaleDataLookupTableItem(aLibTable[i].pLib, module, aLibTable[i].pLocale);
508 262 : maLookupTable.push_back(pNewItem);
509 : OSL_ASSERT( pOutCachedItem );
510 262 : if( pOutCachedItem )
511 : {
512 262 : (*pOutCachedItem) = new LocaleDataLookupTableItem( *pNewItem );
513 : return module->getFunctionSymbol(
514 262 : aBuf.appendAscii(pFunction).append(cUnder).
515 524 : appendAscii((*pOutCachedItem)->localeName).makeStringAndClear());
516 : }
517 : else
518 0 : return NULL;
519 : }
520 : else
521 0 : delete module;
522 : #else
523 : (void) pOutCachedItem;
524 :
525 : if( strcmp(pFunction, "getAllCalendars") == 0 )
526 : return aLibTable[i].getAllCalendars;
527 : else if( strcmp(pFunction, "getAllCurrencies") == 0 )
528 : return aLibTable[i].getAllCurrencies;
529 : else if( strcmp(pFunction, "getAllFormats0") == 0 )
530 : return aLibTable[i].getAllFormats0;
531 : else if( strcmp(pFunction, "getBreakIteratorRules") == 0 )
532 : return aLibTable[i].getBreakIteratorRules;
533 : else if( strcmp(pFunction, "getCollationOptions") == 0 )
534 : return aLibTable[i].getCollationOptions;
535 : else if( strcmp(pFunction, "getCollatorImplementation") == 0 )
536 : return aLibTable[i].getCollatorImplementation;
537 : else if( strcmp(pFunction, "getContinuousNumberingLevels") == 0 )
538 : return aLibTable[i].getContinuousNumberingLevels;
539 : else if( strcmp(pFunction, "getDateAcceptancePatterns") == 0 )
540 : return aLibTable[i].getDateAcceptancePatterns;
541 : else if( strcmp(pFunction, "getFollowPageWords") == 0 )
542 : return aLibTable[i].getFollowPageWords;
543 : else if( strcmp(pFunction, "getForbiddenCharacters") == 0 )
544 : return aLibTable[i].getForbiddenCharacters;
545 : else if( strcmp(pFunction, "getIndexAlgorithm") == 0 )
546 : return aLibTable[i].getIndexAlgorithm;
547 : else if( strcmp(pFunction, "getLCInfo") == 0 )
548 : return aLibTable[i].getLCInfo;
549 : else if( strcmp(pFunction, "getLocaleItem") == 0 )
550 : return aLibTable[i].getLocaleItem;
551 : else if( strcmp(pFunction, "getOutlineNumberingLevels") == 0 )
552 : return aLibTable[i].getOutlineNumberingLevels;
553 : else if( strcmp(pFunction, "getReservedWords") == 0 )
554 : return aLibTable[i].getReservedWords;
555 : else if( strcmp(pFunction, "getSearchOptions") == 0 )
556 : return aLibTable[i].getSearchOptions;
557 : else if( strcmp(pFunction, "getTransliterations") == 0 )
558 : return aLibTable[i].getTransliterations;
559 : else if( strcmp(pFunction, "getUnicodeScripts") == 0 )
560 : return aLibTable[i].getUnicodeScripts;
561 : else if( strcmp(pFunction, "getAllFormats1") == 0 )
562 : return aLibTable[i].getAllFormats1;
563 : #endif
564 : }
565 : }
566 1 : return NULL;
567 : }
568 :
569 : } // anonymous namespace
570 :
571 :
572 : // REF values equal offsets of counts within getAllCalendars() data structure!
573 : #define REF_DAYS 0
574 : #define REF_MONTHS 1
575 : #define REF_GMONTHS 2
576 : #define REF_PMONTHS 3
577 : #define REF_ERAS 4
578 : #define REF_OFFSET_COUNT 5
579 :
580 16 : Sequence< CalendarItem2 > &LocaleDataImpl::getCalendarItemByName(const OUString& name,
581 : const Locale& rLocale, const Sequence< Calendar2 >& calendarsSeq, sal_Int16 item)
582 : throw(RuntimeException)
583 : {
584 16 : if (!ref_name.equals(name)) {
585 16 : OUString aLocStr, id;
586 8 : sal_Int32 nLastUnder = name.lastIndexOf( cUnder);
587 : SAL_WARN_IF( nLastUnder < 1, "i18npool",
588 : "LocaleDataImpl::getCalendarItemByName - no '_' or first in name can't be right: " << name);
589 8 : if (nLastUnder >= 0)
590 : {
591 8 : aLocStr = name.copy( 0, nLastUnder);
592 8 : if (nLastUnder + 1 < name.getLength())
593 8 : id = name.copy( nLastUnder + 1);
594 : }
595 16 : Locale loc( LanguageTag::convertToLocale( aLocStr.replace( cUnder, cHyphen)));
596 16 : Sequence < Calendar2 > cals;
597 8 : if (loc == rLocale) {
598 0 : cals = calendarsSeq;
599 : } else {
600 8 : cals = getAllCalendars2(loc);
601 : }
602 : sal_Int32 index;
603 8 : for (index = 0; index < cals.getLength(); index++) {
604 8 : if (id.equals(cals[index].Name)) {
605 8 : ref_cal = cals[index];
606 8 : break;
607 : }
608 : }
609 : // Referred locale not found, return name for en_US locale.
610 8 : if (index == cals.getLength()) {
611 0 : cals = getAllCalendars2(
612 0 : Locale(OUString("en"), OUString("US"), OUString()));
613 0 : if (cals.getLength() > 0)
614 0 : ref_cal = cals[0];
615 : else
616 0 : throw RuntimeException();
617 : }
618 16 : ref_name = name;
619 : }
620 16 : switch (item)
621 : {
622 : case REF_DAYS:
623 16 : return ref_cal.Days;
624 : case REF_MONTHS:
625 0 : return ref_cal.Months;
626 : case REF_GMONTHS:
627 0 : return ref_cal.GenitiveMonths;
628 : case REF_PMONTHS:
629 0 : return ref_cal.PartitiveMonths;
630 : default:
631 : OSL_FAIL( "LocaleDataImpl::getCalendarItemByName: unhandled REF_* case");
632 : // fallthru
633 : case REF_ERAS:
634 0 : return ref_cal.Eras;
635 : }
636 : }
637 :
638 :
639 13060 : Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems(
640 : sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset,
641 : const sal_Int16 nWhichItem, const sal_Int16 nCalendar,
642 : const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq )
643 : throw(RuntimeException)
644 : {
645 13060 : Sequence< CalendarItem2 > aItems;
646 13060 : if ( OUString( allCalendars[rnOffset] ) == "ref" )
647 : {
648 16 : aItems = getCalendarItemByName( OUString( allCalendars[rnOffset+1]), rLocale, calendarsSeq, nWhichItem);
649 16 : rnOffset += 2;
650 : }
651 : else
652 : {
653 13044 : sal_Int32 nSize = allCalendars[nWhichItem][nCalendar];
654 13044 : aItems.realloc( nSize);
655 13044 : CalendarItem2* pItem = aItems.getArray();
656 13044 : switch (nWhichItem)
657 : {
658 : case REF_DAYS:
659 : case REF_MONTHS:
660 : case REF_GMONTHS:
661 : case REF_PMONTHS:
662 126482 : for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
663 : {
664 232100 : CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
665 348150 : allCalendars[rnOffset+2], allCalendars[rnOffset+3]);
666 116050 : *pItem = item;
667 116050 : rnOffset += 4;
668 116050 : }
669 10432 : break;
670 : case REF_ERAS:
671 : // Absent narrow name.
672 7836 : for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
673 : {
674 10448 : CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
675 15672 : allCalendars[rnOffset+2], OUString());
676 5224 : *pItem = item;
677 5224 : rnOffset += 3;
678 5224 : }
679 2612 : break;
680 : default:
681 : OSL_FAIL( "LocaleDataImpl::getCalendarItems: unhandled REF_* case");
682 : }
683 : }
684 13060 : return aItems;
685 : }
686 :
687 :
688 : Sequence< Calendar2 > SAL_CALL
689 1312 : LocaleDataImpl::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException, std::exception)
690 : {
691 :
692 1312 : sal_Unicode const * const * allCalendars = NULL;
693 :
694 1312 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getAllCalendars" );
695 :
696 1312 : if ( func ) {
697 1312 : sal_Int16 calendarsCount = 0;
698 1312 : allCalendars = func(calendarsCount);
699 :
700 1312 : Sequence< Calendar2 > calendarsSeq(calendarsCount);
701 1312 : sal_Int16 offset = REF_OFFSET_COUNT;
702 3924 : for(sal_Int16 i = 0; i < calendarsCount; i++) {
703 2612 : OUString calendarID(allCalendars[offset]);
704 2612 : offset++;
705 2612 : sal_Bool defaultCalendar = sal::static_int_cast<sal_Bool>( allCalendars[offset][0] );
706 2612 : offset++;
707 : Sequence< CalendarItem2 > days = getCalendarItems( allCalendars, offset, REF_DAYS, i,
708 5224 : rLocale, calendarsSeq);
709 : Sequence< CalendarItem2 > months = getCalendarItems( allCalendars, offset, REF_MONTHS, i,
710 5224 : rLocale, calendarsSeq);
711 : Sequence< CalendarItem2 > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
712 5224 : rLocale, calendarsSeq);
713 : Sequence< CalendarItem2 > pmonths = getCalendarItems( allCalendars, offset, REF_PMONTHS, i,
714 5224 : rLocale, calendarsSeq);
715 : Sequence< CalendarItem2 > eras = getCalendarItems( allCalendars, offset, REF_ERAS, i,
716 5224 : rLocale, calendarsSeq);
717 5224 : OUString startOfWeekDay(allCalendars[offset]);
718 2612 : offset++;
719 2612 : sal_Int16 minimalDaysInFirstWeek = allCalendars[offset][0];
720 2612 : offset++;
721 : Calendar2 aCalendar(days, months, gmonths, pmonths, eras, startOfWeekDay,
722 5224 : minimalDaysInFirstWeek, defaultCalendar, calendarID);
723 2612 : calendarsSeq[i] = aCalendar;
724 2612 : }
725 1312 : return calendarsSeq;
726 : }
727 : else {
728 0 : Sequence< Calendar2 > seq1(0);
729 0 : return seq1;
730 : }
731 : }
732 :
733 :
734 : Sequence< Calendar > SAL_CALL
735 0 : LocaleDataImpl::getAllCalendars( const Locale& rLocale ) throw(RuntimeException, std::exception)
736 : {
737 0 : const Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
738 0 : sal_Int32 nLen = aCal2.getLength();
739 0 : Sequence< Calendar > aCal1( nLen);
740 0 : const Calendar2* p2 = aCal2.getConstArray();
741 0 : Calendar* p1 = aCal1.getArray();
742 0 : for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
743 : {
744 0 : *p1 = downcastCalendar( *p2);
745 : }
746 0 : return aCal1;
747 : }
748 :
749 :
750 : Sequence< Currency2 > SAL_CALL
751 25130 : LocaleDataImpl::getAllCurrencies2( const Locale& rLocale ) throw(RuntimeException, std::exception)
752 : {
753 25130 : sal_Unicode **allCurrencies = NULL;
754 :
755 25130 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getAllCurrencies" );
756 :
757 25130 : if ( func ) {
758 25130 : sal_Int16 currencyCount = 0;
759 25130 : allCurrencies = func(currencyCount);
760 :
761 25130 : Sequence< Currency2 > seq(currencyCount);
762 55284 : for(int i = 0, nOff = 0; i < currencyCount; i++, nOff += 8 ) {
763 : Currency2 cur(
764 30154 : allCurrencies[nOff], // string ID
765 30154 : allCurrencies[nOff+1], // string Symbol
766 30154 : allCurrencies[nOff+2], // string BankSymbol
767 30154 : allCurrencies[nOff+3], // string Name
768 30154 : allCurrencies[nOff+4][0] != 0, // boolean Default
769 30154 : allCurrencies[nOff+5][0] != 0, // boolean UsedInCompatibleFormatCodes
770 30154 : allCurrencies[nOff+6][0], // short DecimalPlaces
771 30154 : allCurrencies[nOff+7][0] != 0 // boolean LegacyOnly
772 241232 : );
773 30154 : seq[i] = cur;
774 30154 : }
775 25130 : return seq;
776 : }
777 : else {
778 0 : Sequence< Currency2 > seq1(0);
779 0 : return seq1;
780 : }
781 : }
782 :
783 :
784 : Sequence< Currency > SAL_CALL
785 0 : LocaleDataImpl::getAllCurrencies( const Locale& rLocale ) throw(RuntimeException, std::exception)
786 : {
787 0 : Sequence< Currency2 > aCur2( getAllCurrencies2( rLocale));
788 0 : sal_Int32 nLen = aCur2.getLength();
789 0 : Sequence< Currency > aCur1( nLen);
790 0 : const Currency2* p2 = aCur2.getArray();
791 0 : Currency* p1 = aCur1.getArray();
792 0 : for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
793 : {
794 0 : *p1 = *p2;
795 : }
796 0 : return aCur1;
797 : }
798 :
799 :
800 : // return a static (!) string resulting from replacing all occurrences of
801 : // 'oldStr' string in 'formatCode' string with 'newStr' string
802 1253242 : static const sal_Unicode * replace( sal_Unicode const * const formatCode, sal_Unicode const * const oldStr, sal_Unicode const * const newStr)
803 : {
804 : // make reasonable assumption of maximum length of formatCode.
805 : #define MAX_FORMATCODE_LENTH 512
806 : static sal_Unicode str[MAX_FORMATCODE_LENTH];
807 :
808 1253242 : if (oldStr[0] == 0) // no replacement requires
809 235350 : return formatCode;
810 :
811 1017892 : sal_Int32 i = 0, k = 0;
812 13280614 : while (formatCode[i] > 0 && k < MAX_FORMATCODE_LENTH) {
813 11244830 : sal_Int32 j = 0, last = k;
814 : // search oldStr in formatCode
815 25329179 : while (formatCode[i] > 0 && oldStr[j] > 0 && k < MAX_FORMATCODE_LENTH) {
816 13811783 : str[k++] = formatCode[i];
817 13811783 : if (formatCode[i++] != oldStr[j++])
818 10972264 : break;
819 : }
820 11244830 : if (oldStr[j] == 0) {
821 : // matched string found, do replacement
822 272566 : k = last; j = 0;
823 2782940 : while (newStr[j] > 0 && k < MAX_FORMATCODE_LENTH)
824 2237808 : str[k++] = newStr[j++];
825 : }
826 : }
827 1017892 : if (k >= MAX_FORMATCODE_LENTH) // could not complete replacement, return original formatCode
828 0 : return formatCode;
829 :
830 1017892 : str[k] = 0;
831 1017892 : return str;
832 : }
833 :
834 : Sequence< FormatElement > SAL_CALL
835 22150 : LocaleDataImpl::getAllFormats( const Locale& rLocale ) throw(RuntimeException, std::exception)
836 : {
837 22150 : const int SECTIONS = 2;
838 : struct FormatSection
839 : {
840 : MyFunc_FormatCode func;
841 : sal_Unicode const *from;
842 : sal_Unicode const *to;
843 : sal_Unicode const *const *formatArray;
844 : sal_Int16 formatCount;
845 :
846 44300 : FormatSection() : func(0), from(0), to(0), formatArray(0), formatCount(0) {}
847 44300 : sal_Int16 getFunc( LocaleDataImpl& rLocaleData, const Locale& rL, const char* pName )
848 : {
849 44300 : func = reinterpret_cast<MyFunc_FormatCode>( rLocaleData.getFunctionSymbol( rL, pName));
850 44300 : if (func)
851 38197 : formatArray = func( formatCount, from, to);
852 44300 : return formatCount;
853 : }
854 22150 : } section[SECTIONS];
855 :
856 : sal_Int32 formatCount;
857 22150 : formatCount = section[0].getFunc( *this, rLocale, "getAllFormats0");
858 22150 : formatCount += section[1].getFunc( *this, rLocale, "getAllFormats1");
859 :
860 22150 : Sequence< FormatElement > seq(formatCount);
861 22150 : sal_Int32 f = 0;
862 66450 : for (int s = 0; s < SECTIONS; ++s)
863 : {
864 44300 : sal_Unicode const * const * const formatArray = section[s].formatArray;
865 44300 : if ( formatArray )
866 : {
867 1291439 : for (int i = 0, nOff = 0; i < section[s].formatCount; ++i, nOff += 7, ++f)
868 : {
869 : FormatElement elem(
870 1253242 : replace( formatArray[nOff], section[s].from, section[s].to),
871 1253242 : formatArray[nOff + 1],
872 1253242 : formatArray[nOff + 2],
873 1253242 : formatArray[nOff + 3],
874 1253242 : formatArray[nOff + 4],
875 1253242 : formatArray[nOff + 5][0],
876 8772694 : sal::static_int_cast<sal_Bool>(formatArray[nOff + 6][0]));
877 1253242 : seq[f] = elem;
878 1253242 : }
879 : }
880 : }
881 22150 : return seq;
882 : }
883 :
884 :
885 : Sequence< OUString > SAL_CALL
886 181 : LocaleDataImpl::getDateAcceptancePatterns( const Locale& rLocale ) throw(RuntimeException, std::exception)
887 : {
888 181 : sal_Unicode **patternsArray = NULL;
889 :
890 181 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getDateAcceptancePatterns" );
891 :
892 181 : if (func)
893 : {
894 181 : sal_Int16 patternsCount = 0;
895 181 : patternsArray = func( patternsCount );
896 181 : Sequence< OUString > seq( patternsCount );
897 553 : for (sal_Int16 i = 0; i < patternsCount; ++i)
898 : {
899 372 : seq[i] = OUString( patternsArray[i] );
900 : }
901 181 : return seq;
902 : }
903 : else
904 : {
905 0 : Sequence< OUString > seq(0);
906 0 : return seq;
907 : }
908 : }
909 :
910 :
911 : #define COLLATOR_OFFSET_ALGO 0
912 : #define COLLATOR_OFFSET_DEFAULT 1
913 : #define COLLATOR_OFFSET_RULE 2
914 : #define COLLATOR_ELEMENTS 3
915 :
916 : OUString SAL_CALL
917 374 : LocaleDataImpl::getCollatorRuleByAlgorithm( const Locale& rLocale, const OUString& algorithm ) throw(RuntimeException)
918 : {
919 374 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getCollatorImplementation" );
920 374 : if ( func ) {
921 374 : sal_Int16 collatorCount = 0;
922 374 : sal_Unicode **collatorArray = func(collatorCount);
923 374 : for(sal_Int16 i = 0; i < collatorCount; i++)
924 374 : if (algorithm.equals(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO]))
925 374 : return OUString(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_RULE]);
926 : }
927 0 : return OUString();
928 : }
929 :
930 :
931 : Sequence< Implementation > SAL_CALL
932 362 : LocaleDataImpl::getCollatorImplementations( const Locale& rLocale ) throw(RuntimeException, std::exception)
933 : {
934 362 : sal_Unicode **collatorArray = NULL;
935 :
936 362 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getCollatorImplementation" );
937 :
938 362 : if ( func ) {
939 362 : sal_Int16 collatorCount = 0;
940 362 : collatorArray = func(collatorCount);
941 362 : Sequence< Implementation > seq(collatorCount);
942 724 : for(sal_Int16 i = 0; i < collatorCount; i++) {
943 362 : Implementation impl(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO],
944 : sal::static_int_cast<sal_Bool>(
945 724 : collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_DEFAULT][0]));
946 362 : seq[i] = impl;
947 362 : }
948 362 : return seq;
949 : }
950 : else {
951 0 : Sequence< Implementation > seq1(0);
952 0 : return seq1;
953 : }
954 : }
955 :
956 : Sequence< OUString > SAL_CALL
957 0 : LocaleDataImpl::getCollationOptions( const Locale& rLocale ) throw(RuntimeException, std::exception)
958 : {
959 0 : sal_Unicode **optionsArray = NULL;
960 :
961 0 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getCollationOptions" );
962 :
963 0 : if ( func ) {
964 0 : sal_Int16 optionsCount = 0;
965 0 : optionsArray = func(optionsCount);
966 0 : Sequence< OUString > seq(optionsCount);
967 0 : for(sal_Int16 i = 0; i < optionsCount; i++) {
968 0 : seq[i] = OUString( optionsArray[i] );
969 : }
970 0 : return seq;
971 : }
972 : else {
973 0 : Sequence< OUString > seq1(0);
974 0 : return seq1;
975 : }
976 : }
977 :
978 : Sequence< OUString > SAL_CALL
979 0 : LocaleDataImpl::getSearchOptions( const Locale& rLocale ) throw(RuntimeException, std::exception)
980 : {
981 0 : sal_Unicode **optionsArray = NULL;
982 :
983 0 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getSearchOptions" );
984 :
985 0 : if ( func ) {
986 0 : sal_Int16 optionsCount = 0;
987 0 : optionsArray = func(optionsCount);
988 0 : Sequence< OUString > seq(optionsCount);
989 0 : for(sal_Int16 i = 0; i < optionsCount; i++) {
990 0 : seq[i] = OUString( optionsArray[i] );
991 : }
992 0 : return seq;
993 : }
994 : else {
995 0 : Sequence< OUString > seq1(0);
996 0 : return seq1;
997 : }
998 : }
999 :
1000 : sal_Unicode ** SAL_CALL
1001 27 : LocaleDataImpl::getIndexArray(const Locale& rLocale, sal_Int16& indexCount)
1002 : {
1003 27 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getIndexAlgorithm" );
1004 :
1005 27 : if (func)
1006 27 : return func(indexCount);
1007 0 : return NULL;
1008 : }
1009 :
1010 : Sequence< OUString > SAL_CALL
1011 12 : LocaleDataImpl::getIndexAlgorithm( const Locale& rLocale ) throw(RuntimeException)
1012 : {
1013 12 : sal_Int16 indexCount = 0;
1014 12 : sal_Unicode **indexArray = getIndexArray(rLocale, indexCount);
1015 :
1016 12 : if ( indexArray ) {
1017 12 : Sequence< OUString > seq(indexCount);
1018 24 : for(sal_Int16 i = 0; i < indexCount; i++) {
1019 12 : seq[i] = indexArray[i*5];
1020 : }
1021 12 : return seq;
1022 : }
1023 : else {
1024 0 : Sequence< OUString > seq1(0);
1025 0 : return seq1;
1026 : }
1027 : }
1028 :
1029 : OUString SAL_CALL
1030 0 : LocaleDataImpl::getDefaultIndexAlgorithm( const Locale& rLocale ) throw(RuntimeException)
1031 : {
1032 0 : sal_Int16 indexCount = 0;
1033 0 : sal_Unicode **indexArray = getIndexArray(rLocale, indexCount);
1034 :
1035 0 : if ( indexArray ) {
1036 0 : for(sal_Int16 i = 0; i < indexCount; i++) {
1037 0 : if (indexArray[i*5 + 3][0])
1038 0 : return OUString(indexArray[i*5]);
1039 : }
1040 : }
1041 0 : return OUString();
1042 : }
1043 :
1044 : sal_Bool SAL_CALL
1045 0 : LocaleDataImpl::hasPhonetic( const Locale& rLocale ) throw(RuntimeException)
1046 : {
1047 0 : sal_Int16 indexCount = 0;
1048 0 : sal_Unicode **indexArray = getIndexArray(rLocale, indexCount);
1049 :
1050 0 : if ( indexArray ) {
1051 0 : for(sal_Int16 i = 0; i < indexCount; i++) {
1052 0 : if (indexArray[i*5 + 4][0])
1053 0 : return sal_True;
1054 : }
1055 : }
1056 0 : return sal_False;
1057 : }
1058 :
1059 : sal_Unicode ** SAL_CALL
1060 15 : LocaleDataImpl::getIndexArrayForAlgorithm(const Locale& rLocale, const OUString& algorithm)
1061 : {
1062 15 : sal_Int16 indexCount = 0;
1063 15 : sal_Unicode **indexArray = getIndexArray(rLocale, indexCount);
1064 15 : if ( indexArray ) {
1065 15 : for(sal_Int16 i = 0; i < indexCount; i++) {
1066 15 : if (algorithm.equals(indexArray[i*5]))
1067 15 : return indexArray+i*5;
1068 : }
1069 : }
1070 0 : return NULL;
1071 : }
1072 :
1073 : sal_Bool SAL_CALL
1074 5 : LocaleDataImpl::isPhonetic( const Locale& rLocale, const OUString& algorithm ) throw(RuntimeException)
1075 : {
1076 5 : sal_Unicode **indexArray = getIndexArrayForAlgorithm(rLocale, algorithm);
1077 5 : return (indexArray && indexArray[4][0]) ? sal_True : sal_False;
1078 : }
1079 :
1080 : OUString SAL_CALL
1081 5 : LocaleDataImpl::getIndexKeysByAlgorithm( const Locale& rLocale, const OUString& algorithm ) throw(RuntimeException)
1082 : {
1083 5 : sal_Unicode **indexArray = getIndexArrayForAlgorithm(rLocale, algorithm);
1084 5 : return indexArray ? OUString("0-9")+OUString(indexArray[2]) : OUString();
1085 : }
1086 :
1087 : OUString SAL_CALL
1088 5 : LocaleDataImpl::getIndexModuleByAlgorithm( const Locale& rLocale, const OUString& algorithm ) throw(RuntimeException)
1089 : {
1090 5 : sal_Unicode **indexArray = getIndexArrayForAlgorithm(rLocale, algorithm);
1091 5 : return indexArray ? OUString(indexArray[1]) : OUString();
1092 : }
1093 :
1094 : Sequence< UnicodeScript > SAL_CALL
1095 5 : LocaleDataImpl::getUnicodeScripts( const Locale& rLocale ) throw(RuntimeException)
1096 : {
1097 5 : sal_Unicode **scriptArray = NULL;
1098 :
1099 5 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getUnicodeScripts" );
1100 :
1101 5 : if ( func ) {
1102 5 : sal_Int16 scriptCount = 0;
1103 5 : scriptArray = func(scriptCount);
1104 5 : Sequence< UnicodeScript > seq(scriptCount);
1105 15 : for(sal_Int16 i = 0; i < scriptCount; i++) {
1106 10 : seq[i] = UnicodeScript( OUString(scriptArray[i]).toInt32() );
1107 : }
1108 5 : return seq;
1109 : }
1110 : else {
1111 0 : Sequence< UnicodeScript > seq1(0);
1112 0 : return seq1;
1113 : }
1114 : }
1115 :
1116 : Sequence< OUString > SAL_CALL
1117 0 : LocaleDataImpl::getFollowPageWords( const Locale& rLocale ) throw(RuntimeException)
1118 : {
1119 0 : sal_Unicode **wordArray = NULL;
1120 :
1121 0 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getFollowPageWords" );
1122 :
1123 0 : if ( func ) {
1124 0 : sal_Int16 wordCount = 0;
1125 0 : wordArray = func(wordCount);
1126 0 : Sequence< OUString > seq(wordCount);
1127 0 : for(sal_Int16 i = 0; i < wordCount; i++) {
1128 0 : seq[i] = OUString(wordArray[i]);
1129 : }
1130 0 : return seq;
1131 : }
1132 : else {
1133 0 : Sequence< OUString > seq1(0);
1134 0 : return seq1;
1135 : }
1136 : }
1137 :
1138 : Sequence< OUString > SAL_CALL
1139 0 : LocaleDataImpl::getTransliterations( const Locale& rLocale ) throw(RuntimeException, std::exception)
1140 : {
1141 :
1142 0 : sal_Unicode **transliterationsArray = NULL;
1143 :
1144 0 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getTransliterations" );
1145 :
1146 0 : if ( func ) {
1147 0 : sal_Int16 transliterationsCount = 0;
1148 0 : transliterationsArray = func(transliterationsCount);
1149 :
1150 0 : Sequence< OUString > seq(transliterationsCount);
1151 0 : for(int i = 0; i < transliterationsCount; i++) {
1152 0 : OUString elem(transliterationsArray[i]);
1153 0 : seq[i] = elem;
1154 0 : }
1155 0 : return seq;
1156 : }
1157 : else {
1158 0 : Sequence< OUString > seq1(0);
1159 0 : return seq1;
1160 : }
1161 :
1162 :
1163 : }
1164 :
1165 :
1166 : LanguageCountryInfo SAL_CALL
1167 47372 : LocaleDataImpl::getLanguageCountryInfo( const Locale& rLocale ) throw(RuntimeException, std::exception)
1168 : {
1169 :
1170 47372 : sal_Unicode **LCInfoArray = NULL;
1171 :
1172 47372 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getLCInfo" );
1173 :
1174 47372 : if ( func ) {
1175 47372 : sal_Int16 LCInfoCount = 0;
1176 47372 : LCInfoArray = func(LCInfoCount);
1177 : LanguageCountryInfo info(LCInfoArray[0],
1178 47372 : LCInfoArray[1],
1179 47372 : LCInfoArray[2],
1180 47372 : LCInfoArray[3],
1181 189488 : LCInfoArray[4]);
1182 47372 : return info;
1183 : }
1184 : else {
1185 0 : LanguageCountryInfo info1;
1186 0 : return info1;
1187 : }
1188 :
1189 : }
1190 :
1191 :
1192 : ForbiddenCharacters SAL_CALL
1193 11078 : LocaleDataImpl::getForbiddenCharacters( const Locale& rLocale ) throw(RuntimeException, std::exception)
1194 : {
1195 11078 : sal_Unicode **LCForbiddenCharactersArray = NULL;
1196 :
1197 11078 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getForbiddenCharacters" );
1198 :
1199 11078 : if ( func ) {
1200 11078 : sal_Int16 LCForbiddenCharactersCount = 0;
1201 11078 : LCForbiddenCharactersArray = func(LCForbiddenCharactersCount);
1202 11078 : ForbiddenCharacters chars(LCForbiddenCharactersArray[0], LCForbiddenCharactersArray[1]);
1203 11078 : return chars;
1204 : }
1205 : else {
1206 0 : ForbiddenCharacters chars1;
1207 0 : return chars1;
1208 : }
1209 : }
1210 :
1211 : OUString SAL_CALL
1212 3 : LocaleDataImpl::getHangingCharacters( const Locale& rLocale ) throw(RuntimeException)
1213 : {
1214 3 : sal_Unicode **LCForbiddenCharactersArray = NULL;
1215 :
1216 3 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getForbiddenCharacters" );
1217 :
1218 3 : if ( func ) {
1219 3 : sal_Int16 LCForbiddenCharactersCount = 0;
1220 3 : LCForbiddenCharactersArray = func(LCForbiddenCharactersCount);
1221 3 : return OUString(LCForbiddenCharactersArray[2]);
1222 : }
1223 :
1224 0 : return OUString();
1225 : }
1226 :
1227 : Sequence< OUString > SAL_CALL
1228 4177 : LocaleDataImpl::getBreakIteratorRules( const Locale& rLocale ) throw(RuntimeException)
1229 : {
1230 4177 : sal_Unicode **LCBreakIteratorRulesArray = NULL;
1231 :
1232 4177 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getBreakIteratorRules" );
1233 :
1234 4177 : if ( func ) {
1235 4177 : sal_Int16 LCBreakIteratorRuleCount = 0;
1236 4177 : LCBreakIteratorRulesArray = func(LCBreakIteratorRuleCount);
1237 4177 : Sequence< OUString > seq(LCBreakIteratorRuleCount);
1238 25062 : for(int i = 0; i < (LCBreakIteratorRuleCount); i++) {
1239 20885 : OUString elem(LCBreakIteratorRulesArray[i]);
1240 20885 : seq[i] = elem;
1241 20885 : }
1242 4177 : return seq;
1243 : }
1244 : else {
1245 0 : Sequence< OUString > seq1(0);
1246 0 : return seq1;
1247 : }
1248 : }
1249 :
1250 :
1251 : Sequence< OUString > SAL_CALL
1252 727 : LocaleDataImpl::getReservedWord( const Locale& rLocale ) throw(RuntimeException, std::exception)
1253 : {
1254 727 : sal_Unicode **LCReservedWordsArray = NULL;
1255 :
1256 727 : MyFunc_Type func = (MyFunc_Type) getFunctionSymbol( rLocale, "getReservedWords" );
1257 :
1258 727 : if ( func ) {
1259 727 : sal_Int16 LCReservedWordsCount = 0;
1260 727 : LCReservedWordsArray = func(LCReservedWordsCount);
1261 727 : Sequence< OUString > seq(LCReservedWordsCount);
1262 9451 : for(int i = 0; i < (LCReservedWordsCount); i++) {
1263 8724 : OUString elem(LCReservedWordsArray[i]);
1264 8724 : seq[i] = elem;
1265 8724 : }
1266 727 : return seq;
1267 : }
1268 : else {
1269 0 : Sequence< OUString > seq1(0);
1270 0 : return seq1;
1271 : }
1272 : }
1273 :
1274 :
1275 : Sequence< Sequence<beans::PropertyValue> > SAL_CALL
1276 0 : LocaleDataImpl::getContinuousNumberingLevels( const lang::Locale& rLocale ) throw(RuntimeException)
1277 : {
1278 : // load symbol
1279 0 : MyFunc_Type2 func = (MyFunc_Type2) getFunctionSymbol( rLocale, "getContinuousNumberingLevels" );
1280 :
1281 0 : if ( func )
1282 : {
1283 : int i;
1284 : // invoke function
1285 : sal_Int16 nStyles;
1286 : sal_Int16 nAttributes;
1287 0 : sal_Unicode*** p0 = func( nStyles, nAttributes );
1288 :
1289 : // allocate memory for nAttributes attributes for each of the nStyles styles.
1290 0 : Sequence< Sequence<beans::PropertyValue> > pv( nStyles );
1291 0 : for( i=0; i<pv.getLength(); i++ ) {
1292 0 : pv[i] = Sequence<beans::PropertyValue>( nAttributes );
1293 : }
1294 :
1295 0 : sal_Unicode*** pStyle = p0;
1296 0 : for( i=0; i<nStyles; i++ ) {
1297 0 : sal_Unicode** pAttribute = pStyle[i];
1298 0 : for( int j=0; j<nAttributes; j++ ) { // prefix, numberingtype, ...
1299 0 : sal_Unicode* pString = pAttribute[j];
1300 0 : beans::PropertyValue& rVal = pv[i][j];
1301 0 : OUString sVal;
1302 0 : if( pString ) {
1303 0 : if( 0 != j && 2 != j )
1304 0 : sVal = pString;
1305 0 : else if( *pString )
1306 0 : sVal = OUString( pString, 1 );
1307 : }
1308 :
1309 0 : switch( j )
1310 : {
1311 : case 0:
1312 0 : rVal.Name = "Prefix";
1313 0 : rVal.Value <<= sVal;
1314 0 : break;
1315 : case 1:
1316 0 : rVal.Name = "NumberingType";
1317 0 : rVal.Value <<= (sal_Int16) sVal.toInt32();
1318 0 : break;
1319 : case 2:
1320 0 : rVal.Name = "Suffix";
1321 0 : rVal.Value <<= sVal;
1322 0 : break;
1323 : case 3:
1324 0 : rVal.Name = "Transliteration";
1325 0 : rVal.Value <<= sVal;
1326 0 : break;
1327 : case 4:
1328 0 : rVal.Name = "NatNum";
1329 0 : rVal.Value <<= (sal_Int16) sVal.toInt32();
1330 0 : break;
1331 : default:
1332 : OSL_ASSERT(false);
1333 : }
1334 0 : }
1335 : }
1336 0 : return pv;
1337 : }
1338 :
1339 0 : Sequence< Sequence<beans::PropertyValue> > seq1(0);
1340 0 : return seq1;
1341 : }
1342 :
1343 : // OutlineNumbering helper class
1344 :
1345 : #include <com/sun/star/container/XIndexAccess.hpp>
1346 : #include <cppuhelper/implbase1.hxx>
1347 :
1348 : namespace com{ namespace sun{ namespace star{ namespace lang {
1349 : struct Locale;
1350 : }}}}
1351 :
1352 0 : struct OutlineNumberingLevel_Impl
1353 : {
1354 : OUString sPrefix;
1355 : sal_Int16 nNumType; //com::sun::star::style::NumberingType
1356 : OUString sSuffix;
1357 : sal_Unicode cBulletChar;
1358 : OUString sBulletFontName;
1359 : sal_Int16 nParentNumbering;
1360 : sal_Int32 nLeftMargin;
1361 : sal_Int32 nSymbolTextDistance;
1362 : sal_Int32 nFirstLineOffset;
1363 : OUString sTransliteration;
1364 : sal_Int32 nNatNum;
1365 : };
1366 :
1367 : class OutlineNumbering : public cppu::WeakImplHelper1 < container::XIndexAccess >
1368 : {
1369 : // OutlineNumbering helper class
1370 :
1371 : const OutlineNumberingLevel_Impl* m_pOutlineLevels;
1372 : sal_Int16 m_nCount;
1373 : public:
1374 : OutlineNumbering(const OutlineNumberingLevel_Impl* pOutlineLevels, int nLevels);
1375 : virtual ~OutlineNumbering();
1376 :
1377 : //XIndexAccess
1378 : virtual sal_Int32 SAL_CALL getCount( ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
1379 : virtual Any SAL_CALL getByIndex( sal_Int32 Index )
1380 : throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
1381 :
1382 : //XElementAccess
1383 : virtual Type SAL_CALL getElementType( ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
1384 : virtual sal_Bool SAL_CALL hasElements( ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
1385 : };
1386 :
1387 : Sequence< Reference<container::XIndexAccess> > SAL_CALL
1388 0 : LocaleDataImpl::getOutlineNumberingLevels( const lang::Locale& rLocale ) throw(RuntimeException)
1389 : {
1390 : // load symbol
1391 0 : MyFunc_Type3 func = (MyFunc_Type3) getFunctionSymbol( rLocale, "getOutlineNumberingLevels" );
1392 :
1393 0 : if ( func )
1394 : {
1395 : int i;
1396 : // invoke function
1397 : sal_Int16 nStyles;
1398 : sal_Int16 nLevels;
1399 : sal_Int16 nAttributes;
1400 0 : sal_Unicode**** p0 = func( nStyles, nLevels, nAttributes );
1401 :
1402 0 : Sequence< Reference<container::XIndexAccess> > aRet( nStyles );
1403 :
1404 0 : OUString aEmptyStr;
1405 :
1406 0 : sal_Unicode**** pStyle = p0;
1407 0 : for( i=0; i<nStyles; i++ )
1408 : {
1409 : int j;
1410 :
1411 0 : OutlineNumberingLevel_Impl* level = new OutlineNumberingLevel_Impl[ nLevels+1 ];
1412 0 : sal_Unicode*** pLevel = pStyle[i];
1413 0 : for( j = 0; j < nLevels; j++ )
1414 : {
1415 0 : sal_Unicode** pAttribute = pLevel[j];
1416 0 : for( int k=0; k<nAttributes; k++ )
1417 : {
1418 0 : OUString tmp( pAttribute[k] );
1419 0 : switch( k )
1420 : {
1421 0 : case 0: level[j].sPrefix = tmp; break;
1422 0 : case 1: level[j].nNumType = sal::static_int_cast<sal_Int16>(tmp.toInt32()); break;
1423 0 : case 2: level[j].sSuffix = tmp; break;
1424 0 : case 3: level[j].cBulletChar = sal::static_int_cast<sal_Unicode>(tmp.toUInt32(16)); break; // base 16
1425 0 : case 4: level[j].sBulletFontName = tmp; break;
1426 0 : case 5: level[j].nParentNumbering = sal::static_int_cast<sal_Int16>(tmp.toInt32()); break;
1427 0 : case 6: level[j].nLeftMargin = tmp.toInt32(); break;
1428 0 : case 7: level[j].nSymbolTextDistance = tmp.toInt32(); break;
1429 0 : case 8: level[j].nFirstLineOffset = tmp.toInt32(); break;
1430 0 : case 9: break;
1431 0 : case 10: level[j].sTransliteration = tmp; break;
1432 0 : case 11: level[j].nNatNum = tmp.toInt32(); break;
1433 : default:
1434 : OSL_ASSERT(false);
1435 : }
1436 0 : }
1437 : }
1438 0 : level[j].sPrefix = aEmptyStr;
1439 0 : level[j].nNumType = 0;
1440 0 : level[j].sSuffix = aEmptyStr;
1441 0 : level[j].cBulletChar = 0;
1442 0 : level[j].sBulletFontName = aEmptyStr;
1443 0 : level[j].nParentNumbering = 0;
1444 0 : level[j].nLeftMargin = 0;
1445 0 : level[j].nSymbolTextDistance = 0;
1446 0 : level[j].nFirstLineOffset = 0;
1447 0 : level[j].sTransliteration = aEmptyStr;
1448 0 : level[j].nNatNum = 0;
1449 0 : aRet[i] = new OutlineNumbering( level, nLevels );
1450 : }
1451 0 : return aRet;
1452 : }
1453 : else {
1454 0 : Sequence< Reference<container::XIndexAccess> > seq1(0);
1455 0 : return seq1;
1456 : }
1457 : }
1458 :
1459 : // helper functions
1460 :
1461 171956 : oslGenericFunction SAL_CALL LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, const sal_Char* pFunction )
1462 : throw(RuntimeException)
1463 : {
1464 171956 : lcl_LookupTableHelper & rLookupTable = lcl_LookupTableStatic::get();
1465 :
1466 171956 : OUStringBuffer aBuf(1);
1467 171956 : if (cachedItem.get() && cachedItem->equals(rLocale))
1468 : {
1469 107151 : aBuf.ensureCapacity(strlen(pFunction) + 1 + strlen(cachedItem->localeName));
1470 214302 : return cachedItem->module->getFunctionSymbol(aBuf.appendAscii(pFunction).append(cUnder).
1471 321453 : appendAscii(cachedItem->localeName).makeStringAndClear());
1472 : }
1473 :
1474 64805 : oslGenericFunction pSymbol = 0;
1475 64805 : LocaleDataLookupTableItem *pCachedItem = 0;
1476 :
1477 : // Load function with name <func>_<lang>_<country> or <func>_<bcp47> and
1478 : // fallbacks.
1479 : pSymbol = rLookupTable.getFunctionSymbolByName( LocaleDataImpl::getFirstLocaleServiceName( rLocale),
1480 64805 : pFunction, &pCachedItem);
1481 64805 : if (!pSymbol)
1482 : {
1483 1 : ::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
1484 1 : for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
1485 : {
1486 0 : pSymbol = rLookupTable.getFunctionSymbolByName( *it, pFunction, &pCachedItem);
1487 0 : if (pSymbol)
1488 0 : break;
1489 1 : }
1490 : }
1491 64805 : if (!pSymbol)
1492 : {
1493 : // load default function with name <func>_en_US
1494 1 : pSymbol = rLookupTable.getFunctionSymbolByName(OUString("en_US"), pFunction, &pCachedItem);
1495 : }
1496 :
1497 64805 : if (!pSymbol)
1498 : // Appropriate symbol could not be found. Give up.
1499 0 : throw RuntimeException();
1500 :
1501 64805 : if (pCachedItem)
1502 64805 : cachedItem.reset(pCachedItem);
1503 64805 : if (cachedItem.get())
1504 64805 : cachedItem->aLocale = rLocale;
1505 :
1506 64805 : return pSymbol;
1507 : }
1508 :
1509 : Sequence< Locale > SAL_CALL
1510 26 : LocaleDataImpl::getAllInstalledLocaleNames() throw(RuntimeException, std::exception)
1511 : {
1512 26 : Sequence< lang::Locale > seq( nbOfLocales );
1513 26 : sal_Int16 nInstalled = 0;
1514 :
1515 6032 : for( sal_Int16 i=0; i<nbOfLocales; i++ ) {
1516 6006 : OUString name = OUString::createFromAscii( aLibTable[i].pLocale );
1517 :
1518 : // Check if the locale is really available and not just in the table,
1519 : // don't allow fall backs.
1520 6006 : LocaleDataLookupTableItem *pCachedItem = 0;
1521 6006 : if (lcl_LookupTableStatic::get().getFunctionSymbolByName( name, "getLocaleItem", &pCachedItem )) {
1522 6006 : if( pCachedItem )
1523 6006 : cachedItem.reset( pCachedItem );
1524 6006 : seq[nInstalled++] = LanguageTag::convertToLocale( name.replace( cUnder, cHyphen), false);
1525 : }
1526 : else
1527 : {
1528 0 : delete pCachedItem;
1529 : }
1530 6006 : }
1531 26 : if ( nInstalled < nbOfLocales )
1532 0 : seq.realloc( nInstalled ); // reflect reality
1533 :
1534 26 : return seq;
1535 : }
1536 :
1537 : using namespace ::com::sun::star::container;
1538 : using namespace ::com::sun::star::beans;
1539 : using namespace ::com::sun::star::style;
1540 : using namespace ::com::sun::star::text;
1541 :
1542 0 : OutlineNumbering::OutlineNumbering(const OutlineNumberingLevel_Impl* pOutlnLevels, int nLevels) :
1543 : m_pOutlineLevels(pOutlnLevels),
1544 0 : m_nCount(sal::static_int_cast<sal_Int16>(nLevels))
1545 : {
1546 0 : }
1547 :
1548 0 : OutlineNumbering::~OutlineNumbering()
1549 : {
1550 0 : delete [] m_pOutlineLevels;
1551 0 : }
1552 :
1553 0 : sal_Int32 OutlineNumbering::getCount( ) throw(RuntimeException, std::exception)
1554 : {
1555 0 : return m_nCount;
1556 : }
1557 :
1558 0 : Any OutlineNumbering::getByIndex( sal_Int32 nIndex )
1559 : throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
1560 : {
1561 0 : if(nIndex < 0 || nIndex >= m_nCount)
1562 0 : throw IndexOutOfBoundsException();
1563 0 : const OutlineNumberingLevel_Impl* pTemp = m_pOutlineLevels;
1564 0 : pTemp += nIndex;
1565 0 : Any aRet;
1566 :
1567 0 : Sequence<PropertyValue> aOutlineNumbering(12);
1568 0 : PropertyValue* pValues = aOutlineNumbering.getArray();
1569 0 : pValues[0].Name = "Prefix";
1570 0 : pValues[0].Value <<= pTemp->sPrefix;
1571 0 : pValues[1].Name = "NumberingType";
1572 0 : pValues[1].Value <<= pTemp->nNumType;
1573 0 : pValues[2].Name = "Suffix";
1574 0 : pValues[2].Value <<= pTemp->sSuffix;
1575 0 : pValues[3].Name = "BulletChar";
1576 0 : pValues[3].Value <<= OUString(&pTemp->cBulletChar, 1);
1577 0 : pValues[4].Name = "BulletFontName";
1578 0 : pValues[4].Value <<= pTemp->sBulletFontName;
1579 0 : pValues[5].Name = "ParentNumbering";
1580 0 : pValues[5].Value <<= OUString::number(pTemp->nParentNumbering);
1581 0 : pValues[6].Name = "LeftMargin";
1582 0 : pValues[6].Value <<= pTemp->nLeftMargin;
1583 0 : pValues[7].Name = "SymbolTextDistance";
1584 0 : pValues[7].Value <<= pTemp->nSymbolTextDistance;
1585 0 : pValues[8].Name = "FirstLineOffset";
1586 0 : pValues[8].Value <<= pTemp->nFirstLineOffset;
1587 0 : pValues[9].Name = "Adjust";
1588 0 : pValues[9].Value <<= (sal_Int16)HoriOrientation::LEFT;
1589 0 : pValues[10].Name = "Transliteration";
1590 0 : pValues[10].Value <<= pTemp->sTransliteration;
1591 0 : pValues[11].Name = "NatNum";
1592 0 : pValues[11].Value <<= pTemp->nNatNum;
1593 0 : aRet <<= aOutlineNumbering;
1594 0 : return aRet;
1595 : }
1596 :
1597 0 : Type OutlineNumbering::getElementType( ) throw(RuntimeException, std::exception)
1598 : {
1599 0 : return ::getCppuType((Sequence<PropertyValue>*)0);
1600 : }
1601 :
1602 0 : sal_Bool OutlineNumbering::hasElements( ) throw(RuntimeException, std::exception)
1603 : {
1604 0 : return m_nCount > 0;
1605 : }
1606 :
1607 : OUString SAL_CALL
1608 0 : LocaleDataImpl::getImplementationName() throw( RuntimeException, std::exception )
1609 : {
1610 0 : return OUString("com.sun.star.i18n.LocaleDataImpl");
1611 : }
1612 :
1613 0 : sal_Bool SAL_CALL LocaleDataImpl::supportsService(const OUString& rServiceName)
1614 : throw( RuntimeException, std::exception )
1615 : {
1616 0 : return cppu::supportsService(this, rServiceName);
1617 : }
1618 :
1619 : Sequence< OUString > SAL_CALL
1620 0 : LocaleDataImpl::getSupportedServiceNames() throw( RuntimeException, std::exception )
1621 : {
1622 0 : Sequence< OUString > aRet(1);
1623 0 : aRet[0] = "com.sun.star.i18n.LocaleData";
1624 0 : return aRet;
1625 : }
1626 :
1627 : // static
1628 94587 : OUString LocaleDataImpl::getFirstLocaleServiceName( const com::sun::star::lang::Locale & rLocale )
1629 : {
1630 94587 : if (rLocale.Language == I18NLANGTAG_QLT)
1631 312 : return rLocale.Variant.replace( cHyphen, cUnder);
1632 94275 : else if (!rLocale.Country.isEmpty())
1633 93293 : return rLocale.Language + "_" + rLocale.Country;
1634 : else
1635 982 : return rLocale.Language;
1636 : }
1637 :
1638 : // static
1639 29056 : ::std::vector< OUString > LocaleDataImpl::getFallbackLocaleServiceNames( const com::sun::star::lang::Locale & rLocale )
1640 : {
1641 29056 : ::std::vector< OUString > aVec;
1642 29056 : if (rLocale.Language == I18NLANGTAG_QLT)
1643 : {
1644 0 : aVec = LanguageTag( rLocale).getFallbackStrings( false);
1645 0 : for (::std::vector< OUString >::iterator it(aVec.begin()); it != aVec.end(); ++it)
1646 : {
1647 0 : *it = (*it).replace( cHyphen, cUnder);
1648 : }
1649 : }
1650 29056 : else if (!rLocale.Country.isEmpty())
1651 : {
1652 29008 : aVec.push_back( rLocale.Language);
1653 : }
1654 : // else nothing, language-only was the first
1655 29056 : return aVec;
1656 : }
1657 :
1658 : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1659 54019 : com_sun_star_i18n_LocaleDataImpl_get_implementation(
1660 : css::uno::XComponentContext *,
1661 : css::uno::Sequence<css::uno::Any> const &)
1662 : {
1663 54019 : return cppu::acquire(new LocaleDataImpl());
1664 495 : }
1665 :
1666 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|