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