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