Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <defaultnumberingprovider.hxx>
21 : #include <com/sun/star/style/NumberingType.hpp>
22 : #include <com/sun/star/beans/PropertyValue.hpp>
23 : #include <com/sun/star/configuration/theDefaultProvider.hpp>
24 : #include <com/sun/star/text/HoriOrientation.hpp>
25 : #include <localedata.hxx>
26 : #include <nativenumbersupplier.hxx>
27 : #include <stdio.h>
28 : #include <string.h>
29 : #include <comphelper/processfactory.hxx>
30 :
31 : // Cyrillic upper case
32 : #define C_CYR_A "\xD0\x90"
33 : #define C_CYR_B "\xD0\x91"
34 : // Cyrillic lower case
35 : #define S_CYR_A "\xD0\xB0"
36 : #define S_CYR_B "\xD0\xB1"
37 :
38 : //Greek upper case
39 : #define C_GR_A "\xCE\x91"
40 : #define C_GR_B "\xCE\x92"
41 : //Greek lower case
42 : #define S_GR_A "\xCE\xB1"
43 : #define S_GR_B "\xCE\xB2"
44 :
45 : #include <math.h>
46 : #include <sal/macros.h>
47 : #include <rtl/ustring.hxx>
48 : #include <rtl/ustrbuf.hxx>
49 : #include <com/sun/star/i18n/XTransliteration.hpp>
50 : #include <com/sun/star/i18n/TransliterationType.hpp>
51 : #include <com/sun/star/i18n/TransliterationModulesNew.hpp>
52 : #include <com/sun/star/i18n/XLocaleData.hpp>
53 :
54 : #include <bullet.h>
55 :
56 : using namespace com::sun::star;
57 : using namespace com::sun::star::uno;
58 : using namespace com::sun::star::lang;
59 : using namespace ::rtl;
60 :
61 : namespace com { namespace sun { namespace star { namespace i18n {
62 :
63 : static sal_Unicode table_Alphabet_ar[] = {
64 : 0x0623, 0x0628, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E,
65 : 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635,
66 : 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x0642,
67 : 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649
68 : };
69 :
70 : static sal_Unicode table_Alphabet_ar_abjad[] = {
71 : 0x0627, 0x0628, 0x062c, 0x062f, 0x0647, 0x0648, 0x0632, 0x062d,
72 : 0x0637, 0x064a, 0x0643, 0x0644, 0x0645, 0x0646, 0x0633, 0x0639,
73 : 0x0641, 0x0635, 0x0642, 0x0631, 0x0634, 0x062a, 0x062b, 0x062e,
74 : 0x0630, 0x0636, 0x0638, 0x063a
75 : };
76 :
77 : static sal_Unicode table_Alphabet_th[] = {
78 : 0x0E01, 0x0E02, 0x0E04, 0x0E07,
79 : 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
80 : 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
81 : 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
82 : 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
83 : 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E
84 : };
85 :
86 : static sal_Unicode table_Alphabet_he[] = {
87 : 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
88 : 0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0, 0x05E1, 0x05E2,
89 : 0x05E4, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA
90 : };
91 :
92 : static sal_Unicode table_Alphabet_ne[] = {
93 : 0x0915, 0x0916, 0x0917, 0x0918, 0x0919, 0x091A, 0x091B, 0x091C,
94 : 0x091D, 0x091E, 0x091F, 0x0920, 0x0921, 0x0922, 0x0923, 0x0924,
95 : 0x0925, 0x0926, 0x0927, 0x0928, 0x092A, 0x092B, 0x092C, 0x092D,
96 : 0x092E, 0x092F, 0x0930, 0x0932, 0x0935, 0x0936, 0x0937, 0x0938,
97 : 0x0939
98 : };
99 :
100 : static sal_Unicode table_Alphabet_km[] = {
101 : 0x1780, 0x1781, 0x1782, 0x1783, 0x1784, 0x1785, 0x1786, 0x1787,
102 : 0x1788, 0x1789, 0x178A, 0x178B, 0x178C, 0x178D, 0x178E, 0x178F,
103 : 0x1790, 0x1791, 0x1792, 0x1793, 0x1794, 0x1795, 0x1796, 0x1797,
104 : 0x1798, 0x1799, 0x179A, 0x179B, 0x179C, 0x179F,
105 : 0x17A0, 0x17A1, 0x17A2
106 : };
107 :
108 : static sal_Unicode table_Alphabet_lo[] = {
109 : 0x0E81, 0x0E82, 0x0E84, 0x0E87, 0x0E88, 0x0E8A, 0x0E8D, 0x0E94,
110 : 0x0E95, 0x0E96, 0x0E97, 0x0E99, 0x0E9A, 0x0E9B, 0x0E9C,
111 : 0x0E9D, 0x0E9E, 0x0E9F, 0x0EA1, 0x0EA2, 0x0EA3, 0x0EA5, 0x0EA7,
112 : 0x0EAA, 0x0EAB, 0x0EAD, 0x0EAE, 0x0EAF, 0x0EAE, 0x0EDC, 0x0EDD
113 : };
114 :
115 : static sal_Unicode table_Alphabet_dz[] = {
116 : 0x0F40, 0x0F41, 0x0F42, 0x0F44, 0x0F45, 0x0F46, 0x0F47, 0x0F49,
117 : 0x0F4F, 0x0F50, 0x0F51, 0x0F53, 0x0F54, 0x0F55, 0x0F56, 0x0F58,
118 : 0x0F59, 0x0F5A, 0x0F5B, 0x0F5D, 0x0F5E, 0x0F5F, 0x0F60, 0x0F61,
119 : 0x0F62, 0x0F63, 0x0F64, 0x0F66, 0x0F67, 0x0F68
120 : };
121 :
122 : static sal_Unicode table_Alphabet_my[] = {
123 : 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007,
124 : 0x1008,/*0x1009,*/0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F,
125 : 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017,
126 : 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F,
127 : 0x1020, 0x1021
128 : };
129 :
130 : // Bulgarian Cyrillic upper case letters
131 : static sal_Unicode table_CyrillicUpperLetter_bg[] = {
132 : 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418,
133 : 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422,
134 : 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042E,
135 : 0x042F
136 : };
137 :
138 : // Bulgarian cyrillic lower case letters
139 : static sal_Unicode table_CyrillicLowerLetter_bg[] = {
140 : 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438,
141 : 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442,
142 : 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044E,
143 : 0x044F
144 : };
145 :
146 : // Russian Cyrillic upper letters
147 : static sal_Unicode table_CyrillicUpperLetter_ru[] = {
148 : 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
149 : 0x0418, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420,
150 : 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
151 : 0x0429, 0x042B, 0x042D, 0x042E, 0x042F
152 : };
153 :
154 : // Russian cyrillic lower letters
155 : static sal_Unicode table_CyrillicLowerLetter_ru[] = {
156 : 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
157 : 0x0438, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440,
158 : 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448,
159 : 0x0449, 0x044B, 0x044D, 0x044E, 0x044F
160 : };
161 :
162 : // Serbian Cyrillic upper letters
163 : static sal_Unicode table_CyrillicUpperLetter_sr[] = {
164 : 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0402, 0x0415, 0x0416,
165 : 0x0417, 0x0418, 0x0408, 0x041A, 0x041B, 0x0409, 0x041C, 0x041D,
166 : 0x040A, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x040B, 0x0423,
167 : 0x0424, 0x0425, 0x0426, 0x0427, 0x040F, 0x0428
168 : };
169 :
170 : // Serbian cyrillic lower letters
171 : static sal_Unicode table_CyrillicLowerLetter_sr[] = {
172 : 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0452, 0x0435, 0x0436,
173 : 0x0437, 0x0438, 0x0458, 0x043A, 0x043B, 0x0459, 0x043C, 0x043D,
174 : 0x045A, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x045B, 0x0443,
175 : 0x0444, 0x0445, 0x0446, 0x0447, 0x045F, 0x0448
176 : };
177 :
178 : static sal_Unicode table_GreekUpperLetter[] = {
179 : 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x03DB, 0x0396, 0x0397, 0x0398,
180 : 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03DF,
181 : 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03E0
182 : };
183 :
184 : static sal_Unicode table_GreekLowerLetter[] = {
185 : 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03DB, 0x03B6, 0x03B7, 0x03B8,
186 : 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03DF,
187 : 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03E1
188 : };
189 :
190 : static sal_Unicode table_Alphabet_fa[] = {
191 : 0x0622, 0x0628, 0x067E, 0x062A, 0x062B, 0x062C, 0x0686, 0x062D,
192 : 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0698, 0x0633, 0x0634,
193 : 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x0640, 0x0641, 0x0642,
194 : 0x06A9, 0x06AF, 0x0644, 0x0645, 0x0646, 0x0648, 0x0647, 0x06CC
195 : };
196 :
197 : static sal_Unicode upperLetter[] = {
198 : 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
199 : 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
200 : 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
201 : };
202 :
203 : static sal_Unicode lowerLetter[] = {
204 : 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
205 : 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
206 : 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
207 : };
208 :
209 : // Tables used for numbering in persian words
210 : static sal_Unicode table_PersianWord_decade1[][7]={
211 : {0}, // 0
212 : {0x06cc, 0x06a9, 0}, // 1
213 : {0x062f, 0x0648, 0}, // 2
214 : {0x0633, 0x0647, 0}, // 3
215 : {0x0686, 0x0647, 0x0627, 0x0631, 0}, // 4
216 : {0x067e, 0x0646, 0x062c, 0}, // 5
217 : {0x0634, 0x0634, 0}, // 6
218 : {0x0647, 0x0641, 0x062a, 0}, // 7
219 : {0x0647, 0x0634, 0x062a, 0}, // 8
220 : {0x0646, 0x0647, 0}, // 9
221 : {0x062f, 0x0647, 0}, // 10
222 : {0x06cc, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 11
223 : {0x062f, 0x0648, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 12
224 : {0x0633, 0x06cc, 0x0632, 0x062f, 0x0647, 0}, // 13
225 : {0x0686, 0x0647, 0x0627, 0x0631, 0x062f, 0x0647, 0}, // 14
226 : {0x067e, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 15
227 : {0x0634, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 16
228 : {0x0647, 0x0641, 0x062f, 0x0647, 0}, // 17
229 : {0x0647, 0x062c, 0x062f, 0x0647, 0}, // 18
230 : {0x0646, 0x0648, 0x0632, 0x062f, 0x0647, 0} // 19
231 : };
232 :
233 : static sal_Unicode table_PersianWord_decade2[][6]={
234 : {0x0628, 0x06cc, 0x0633, 0x062a, 0}, // 20
235 : {0x0633, 0x06cc, 0}, // 30
236 : {0x0686, 0x0647, 0x0644, 0}, // 40
237 : {0x067e, 0x0646, 0x062c, 0x0627, 0x0647, 0}, // 50
238 : {0x0634, 0x0635, 0x062a, 0}, // 60
239 : {0x0647, 0x0641, 0x062a, 0x0627, 0x062f, 0}, // 70
240 : {0x0647, 0x0634, 0x062a, 0x0627, 0x062f, 0}, // 80
241 : {0x0646, 0x0648, 0x062f, 0} // 90
242 : };
243 :
244 : static sal_Unicode table_PersianWord_decade3[][7]={
245 : {0x0635, 0x062f, 0}, // 100
246 : {0x062f, 0x0648, 0x06cc, 0x0633, 0x062a, 0}, // 200
247 : {0x0633, 0x06cc, 0x0635, 0x062f, 0}, // 300
248 : {0x0686, 0x0647, 0x0627, 0x0631, 0x0635, 0x062f, 0}, // 400
249 : {0x067e, 0x0627, 0x0646, 0x0635, 0x062f, 0}, // 500
250 : {0x0634, 0x0635, 0x062f, 0}, // 600
251 : {0x0647, 0x0641, 0x062a, 0x0635, 0x062f, 0}, // 700
252 : {0x0647, 0x0634, 0x062a, 0x0635, 0x062f, 0}, // 800
253 : {0x0646, 0x0647, 0x0635, 0x062f, 0} // 900
254 : };
255 :
256 : static sal_Unicode table_PersianWord_decadeX[][8]={
257 : {0x0647, 0x0632, 0x0627, 0x0631, 0}, // 1000
258 : {0x0645, 0x06cc, 0x0644, 0x06cc, 0x0648, 0x0646, 0}, // 1000000
259 : {0x0645, 0x06cc, 0x0644, 0x06cc, 0x0627, 0x0631, 0x062f, 0} // 1000000000
260 : };
261 :
262 :
263 6 : DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XComponentContext >& rxContext ) : m_xContext(rxContext),translit(NULL)
264 : {
265 :
266 6 : }
267 :
268 0 : DefaultNumberingProvider::~DefaultNumberingProvider()
269 : {
270 0 : delete translit;
271 0 : }
272 :
273 0 : void DefaultNumberingProvider::impl_loadTranslit()
274 : {
275 0 : if ( !translit )
276 0 : translit = new TransliterationImpl(m_xContext);
277 0 : }
278 :
279 : Sequence< Reference<container::XIndexAccess> >
280 0 : DefaultNumberingProvider::getDefaultOutlineNumberings(const Locale& rLocale ) throw(RuntimeException)
281 : {
282 0 : return LocaleData().getOutlineNumberingLevels( rLocale );
283 : }
284 :
285 : Sequence< Sequence<beans::PropertyValue> >
286 0 : DefaultNumberingProvider::getDefaultContinuousNumberingLevels( const Locale& rLocale ) throw(RuntimeException)
287 : {
288 0 : return LocaleData().getContinuousNumberingLevels( rLocale );
289 : }
290 :
291 0 : OUString toRoman( sal_Int32 n )
292 : {
293 :
294 : // i, ii, iii, iv, v, vi, vii, vii, viii, ix
295 : // (Dummy),1000,500,100,50,10,5,1
296 : static const sal_Char coRomanArr[] = "MDCLXVI--"; // +2 Dummy entries !!
297 0 : const sal_Char* cRomanStr = coRomanArr;
298 0 : sal_uInt16 nMask = 1000;
299 0 : sal_uInt32 nOver1000 = n / nMask;
300 0 : n -= ( nOver1000 * nMask );
301 :
302 0 : OUStringBuffer sTmp;
303 0 : while(nOver1000--)
304 0 : sTmp.append(sal_Unicode(*coRomanArr));
305 :
306 0 : while( nMask )
307 : {
308 0 : sal_uInt8 nZahl = sal_uInt8( n / nMask );
309 0 : sal_uInt8 nDiff = 1;
310 0 : n %= nMask;
311 :
312 0 : if( 5 < nZahl )
313 : {
314 0 : if( nZahl < 9 )
315 0 : sTmp.append(sal_Unicode(*(cRomanStr-1)));
316 0 : ++nDiff;
317 0 : nZahl -= 5;
318 : }
319 0 : switch( nZahl )
320 : {
321 0 : case 3: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
322 0 : case 2: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
323 0 : case 1: sTmp.append(sal_Unicode(*cRomanStr)); break;
324 0 : case 4: sTmp.append(sal_Unicode(*cRomanStr)).append(sal_Unicode(*(cRomanStr-nDiff))); break;
325 0 : case 5: sTmp.append(sal_Unicode(*(cRomanStr-nDiff))); break;
326 : }
327 :
328 0 : nMask /= 10; // to the next decade
329 0 : cRomanStr += 2;
330 : }
331 0 : return sTmp.makeStringAndClear();
332 : }
333 :
334 : // not used:
335 :
336 : static
337 0 : void lcl_formatChars( sal_Unicode table[], int tableSize, int n, OUString& s )
338 : {
339 : // string representation of n is appended to s.
340 : // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>AB, ...
341 : // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>ab, ...
342 :
343 0 : if( n>=tableSize ) lcl_formatChars( table, tableSize, (n-tableSize)/tableSize, s );
344 :
345 0 : s += OUString::valueOf( table[ n % tableSize ] );
346 0 : }
347 :
348 : static
349 0 : void lcl_formatChars1( sal_Unicode table[], int tableSize, int n, OUString& s )
350 : {
351 : // string representation of n is appended to s.
352 : // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>BB, ...
353 : // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>bb, ...
354 :
355 0 : int repeat_count = n / tableSize + 1;
356 :
357 0 : for( int i=0; i<repeat_count; i++ )
358 0 : s += OUString::valueOf( table[ n%tableSize ] );
359 0 : }
360 :
361 : static
362 0 : void lcl_formatChars2( sal_Unicode table_capital[], sal_Unicode table_small[], int tableSize, int n, OUString& s )
363 : {
364 : // string representation of n is appended to s.
365 : // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Ab, ...
366 :
367 0 : if( n>=tableSize )
368 : {
369 0 : lcl_formatChars2( table_capital, table_small, tableSize, (n-tableSize)/tableSize, s );
370 0 : s += OUString::valueOf( table_small[ n % tableSize ] );
371 : } else
372 0 : s += OUString::valueOf( table_capital[ n % tableSize ] );
373 0 : }
374 :
375 : static
376 0 : void lcl_formatChars3( sal_Unicode table_capital[], sal_Unicode table_small[], int tableSize, int n, OUString& s )
377 : {
378 : // string representation of n is appended to s.
379 : // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Bb, ...
380 :
381 0 : int repeat_count = n / tableSize + 1;
382 0 : s += OUString::valueOf( table_capital[ n%tableSize ] );
383 :
384 0 : for( int i=1; i<repeat_count; i++ )
385 0 : s += OUString::valueOf( table_small[ n%tableSize ] );
386 0 : }
387 :
388 :
389 : /** Returns number's representation in persian words up to 999999999999
390 : respectively limited by sal_Int32 >=0.
391 : The caller assures that nNumber is not negative.
392 : */
393 : static
394 0 : void lcl_formatPersianWord( sal_Int32 nNumber, OUString& rsResult )
395 : throw( IllegalArgumentException, RuntimeException )
396 : {
397 0 : OUStringBuffer aTemp(64);
398 : unsigned int nDigit;
399 0 : sal_Unicode asPersianWord_conjunction_data[] = {0x20,0x0648,0x20,0};
400 0 : OUString asPersianWord_conjunction( asPersianWord_conjunction_data );
401 0 : unsigned char nSection = 0;
402 :
403 0 : while (int nPart = nNumber % 1000)
404 : {
405 0 : if (nSection)
406 : {
407 0 : if (nSection > SAL_N_ELEMENTS( table_PersianWord_decadeX))
408 0 : throw IllegalArgumentException(); // does not happen with sal_Int32
409 0 : aTemp.insert( 0, asPersianWord_conjunction).insert( 0, table_PersianWord_decadeX[nSection-1]);
410 : }
411 :
412 0 : if ((nDigit = nPart % 100) < 20)
413 : {
414 0 : if (aTemp.getLength())
415 0 : aTemp.insert( 0, sal_Unicode(0x0020));
416 0 : aTemp.insert( 0, table_PersianWord_decade1[nDigit]);
417 : }
418 : else
419 : {
420 0 : if ((nDigit = nPart % 10) != 0)
421 : {
422 0 : if (aTemp.getLength())
423 0 : aTemp.insert( 0, asPersianWord_conjunction);
424 0 : aTemp.insert( 0, table_PersianWord_decade1[nDigit]);
425 : }
426 0 : if ((nDigit = (nPart / 10) % 10) != 0)
427 : {
428 0 : if (aTemp.getLength())
429 0 : aTemp.insert( 0, asPersianWord_conjunction);
430 0 : aTemp.insert( 0, table_PersianWord_decade2[nDigit-2]);
431 : }
432 : }
433 :
434 0 : if ((nDigit = nPart / 100) != 0)
435 : {
436 0 : if (aTemp.getLength())
437 0 : aTemp.insert( 0, asPersianWord_conjunction);
438 0 : aTemp.insert( 0, table_PersianWord_decade3[nDigit-1]);
439 : }
440 :
441 0 : nNumber /= 1000;
442 0 : nSection++;
443 : }
444 0 : rsResult += aTemp.makeStringAndClear();
445 0 : }
446 :
447 :
448 : // Greek Letter Numbering
449 :
450 : // KERAIA separates numerals from other text
451 : #define STIGMA (sal_Unicode) 0x03DB
452 : #define LEFT_KERAIA (sal_Unicode) 0x0375
453 : #define MYRIAD_SYM (sal_Unicode) 0x039C
454 : #define DOT_SYM (sal_Unicode) 0x002E
455 : #define SIGMA_OFFSET 19
456 : #define TAU_OFFSET 20
457 : #define MYRIAD 10000
458 :
459 : /*
460 : * Return the 1-999999 number's representation in the Greek numbering system.
461 : * Adding a "left keraia" to represent numbers in the range 10000 ... 999999 is
462 : * not orthodox, so it's better to use the myriad notation and call this method
463 : * only for numbers up to 9999.
464 : */
465 : static
466 0 : OUString gr_smallNum(sal_Unicode table[], int n)
467 : {
468 0 : if (n > 9999)
469 0 : throw IllegalArgumentException();
470 :
471 0 : int i = 0;
472 0 : OUStringBuffer sb;
473 0 : for (int v = n; v > 0; v /= 10, i++) {
474 0 : int digit = v % 10;
475 0 : if (digit == 0)
476 0 : continue;
477 :
478 0 : sal_Unicode sign = table[(digit - 1) + 9 * (i % 3)];
479 0 : if (sign == STIGMA) {
480 0 : sb.insert(0, table[TAU_OFFSET]);
481 0 : sb.insert(0, table[SIGMA_OFFSET]);
482 : } else {
483 0 : sb.insert(0, sign);
484 : }
485 :
486 0 : if (i > 2)
487 0 : sb.insert(0, LEFT_KERAIA);
488 : }
489 :
490 0 : return sb.makeStringAndClear();
491 : }
492 :
493 : static
494 0 : void lcl_formatCharsGR( sal_Unicode table[], int n, OUString& s )
495 : {
496 0 : OUStringBuffer sb;
497 0 : int myriadPower = 2;
498 :
499 0 : for (int divisor = MYRIAD * MYRIAD; divisor > 1; divisor /= MYRIAD, myriadPower--) {
500 0 : if (n > divisor - 1) {
501 : /*
502 : * Follow the Diophantus representation of:
503 : * A myriad sign, M(10000) as many times as the power
504 : * followed by the multiplier for the myriad
505 : * followed by a dot
506 : * followed by the rest
507 : * This is enough for 32-bit integers
508 : */
509 0 : for (int i = 0; i < myriadPower; i++)
510 0 : sb.append(MYRIAD_SYM);
511 :
512 0 : sb.append(gr_smallNum(table, n/divisor));
513 0 : n %= divisor;
514 :
515 0 : if (n > 0)
516 0 : sb.append(DOT_SYM);
517 : }
518 : }
519 0 : sb.append(gr_smallNum(table,n));
520 :
521 0 : s += sb.makeStringAndClear();
522 0 : }
523 :
524 : static
525 284 : int should_ignore( OUString s )
526 : {
527 : // return true if blank or null
528 284 : return s.compareToAscii(" ")==0 || (!s.isEmpty() && s[0]==0);
529 : }
530 :
531 : static
532 568 : Any getPropertyByName( const Sequence<beans::PropertyValue>& aProperties,
533 : const char* name, sal_Bool bRequired )
534 : {
535 1278 : for( int i=0; i<aProperties.getLength(); i++ )
536 994 : if( aProperties[i].Name.equalsAscii(name) )
537 284 : return aProperties[i].Value;
538 284 : if(bRequired)
539 0 : throw IllegalArgumentException();
540 284 : return Any();
541 : }
542 :
543 : //XNumberingFormatter
544 : OUString
545 142 : DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyValue>& aProperties,
546 : const Locale& aLocale )
547 : throw( IllegalArgumentException, RuntimeException )
548 : {
549 : // the Sequence of PropertyValues is expected to have at least 4 elements:
550 : // elt Name Type purpose
551 : // -----------------------------------------------------------------
552 : //
553 : // 0. "Prefix" OUString
554 : // 1. "NumberingType" sal_Int16 type of formatting from style::NumberingType (roman, arabic, etc)
555 : // 2. "Suffix" OUString
556 : // ... ... ...
557 : // n. "Value" sal_Int32 the number to be formatted
558 : // example:
559 : // given the Sequence { '(', NumberingType::ROMAN_UPPER, ')', ..., 7 }
560 : // makeNumberingString() returns the string "(VII)".
561 :
562 : // Q: why is the type of numType sal_Int16 instead of style::NumberingType?
563 : // A: an Any can't hold a style::NumberingType for some reason.
564 : // add.: style::NumberingType holds constants of type sal_Int16, it's not an enum type
565 :
566 142 : sal_Int16 natNum = 0;
567 142 : sal_Int16 tableSize = 0;
568 142 : sal_Unicode *table = NULL; // initialize to avoid compiler warning
569 142 : sal_Bool recycleSymbol = sal_False;
570 142 : Locale locale;
571 :
572 142 : OUString prefix;
573 142 : sal_Int16 numType = -1; // type of formatting from style::NumberingType (roman, arabic, etc)
574 142 : OUString suffix;
575 142 : sal_Int32 number = -12345; // the number that needs to be formatted.
576 :
577 : // int nProperties = aProperties.getLength();
578 : // int last = nProperties-1;
579 :
580 : try {
581 142 : getPropertyByName(aProperties, "Prefix", sal_False) >>=prefix;
582 0 : } catch (Exception&) {
583 : //prefix _must_ be empty here!
584 : }
585 : try {
586 142 : getPropertyByName(aProperties, "Suffix", sal_False) >>=suffix;
587 0 : } catch (Exception&) {
588 : //suffix _must_ be empty here!
589 : }
590 : try {
591 142 : getPropertyByName(aProperties, "NumberingType", sal_True) >>=numType;
592 0 : } catch (Exception& ) {
593 0 : numType = -1;
594 : }
595 : try {
596 142 : getPropertyByName(aProperties, "Value", sal_True) >>=number;
597 0 : } catch (Exception& ) {
598 0 : number = -1;
599 : }
600 :
601 142 : if( number <= 0 )
602 0 : throw IllegalArgumentException();
603 :
604 : // start empty
605 142 : OUString result;
606 :
607 : // append prefix
608 142 : if( !should_ignore(prefix) ) result += prefix;
609 :
610 : // append formatted number
611 : using namespace style::NumberingType;
612 142 : switch( numType )
613 : {
614 : case CHARS_UPPER_LETTER:
615 0 : lcl_formatChars( upperLetter, 26, number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>AB, ...
616 0 : break;
617 : case CHARS_LOWER_LETTER:
618 0 : lcl_formatChars( lowerLetter, 26, number-1, result );
619 0 : break;
620 : case ROMAN_UPPER:
621 0 : result += toRoman( number );
622 0 : break;
623 : case ROMAN_LOWER:
624 0 : result += toRoman( number ).toAsciiLowerCase();
625 0 : break;
626 : case ARABIC:
627 142 : result += OUString::valueOf( number );
628 142 : break;
629 : case NUMBER_NONE:
630 0 : return OUString(""); // ignore prefix and suffix
631 : case CHAR_SPECIAL:
632 : // apparently, we're supposed to return an empty string in this case...
633 0 : return OUString(""); // ignore prefix and suffix
634 : case PAGE_DESCRIPTOR:
635 : case BITMAP:
636 : OSL_ASSERT(0);
637 0 : throw IllegalArgumentException();
638 : case CHARS_UPPER_LETTER_N:
639 0 : lcl_formatChars1( upperLetter, 26, number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
640 0 : break;
641 : case CHARS_LOWER_LETTER_N:
642 0 : lcl_formatChars1( lowerLetter, 26, number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
643 0 : break;
644 : case TRANSLITERATION:
645 : try {
646 0 : const OUString &tmp = OUString::valueOf( number );
647 0 : OUString transliteration;
648 0 : getPropertyByName(aProperties, "Transliteration", sal_True) >>= transliteration;
649 0 : impl_loadTranslit();
650 0 : translit->loadModuleByImplName(transliteration, aLocale);
651 0 : result += translit->transliterateString2String(tmp, 0, tmp.getLength());
652 0 : } catch (Exception& ) {
653 : // When translteration property is missing, return default number (bug #101141#)
654 0 : result += OUString::valueOf( number );
655 : // OSL_ASSERT(0);
656 : // throw IllegalArgumentException();
657 : }
658 0 : break;
659 : case NATIVE_NUMBERING:
660 0 : natNum = NativeNumberMode::NATNUM1;
661 0 : locale = aLocale;
662 0 : break;
663 : case FULLWIDTH_ARABIC:
664 0 : natNum = NativeNumberMode::NATNUM3;
665 0 : locale = aLocale;
666 0 : break;
667 : case NUMBER_LOWER_ZH:
668 0 : natNum = NativeNumberMode::NATNUM7;
669 0 : locale.Language = OUString("zh");
670 0 : break;
671 : case NUMBER_UPPER_ZH_TW:
672 0 : locale.Country = OUString("TW");
673 : case NUMBER_UPPER_ZH:
674 0 : natNum = NativeNumberMode::NATNUM8;
675 0 : locale.Language = OUString("zh");
676 0 : break;
677 : case NUMBER_TRADITIONAL_JA:
678 0 : natNum = NativeNumberMode::NATNUM8;
679 0 : locale.Language = OUString("ja");
680 0 : break;
681 : case NUMBER_UPPER_KO:
682 0 : natNum = NativeNumberMode::NATNUM8;
683 0 : locale.Language = OUString("ko");
684 0 : break;
685 : case NUMBER_HANGUL_KO:
686 0 : natNum = NativeNumberMode::NATNUM11;
687 0 : locale.Language = OUString("ko");
688 0 : break;
689 :
690 : case CIRCLE_NUMBER:
691 0 : table = table_CircledNumber;
692 0 : tableSize = SAL_N_ELEMENTS(table_CircledNumber);
693 0 : break;
694 : case TIAN_GAN_ZH:
695 0 : table = table_TianGan_zh;
696 0 : tableSize = SAL_N_ELEMENTS(table_TianGan_zh);
697 0 : break;
698 : case DI_ZI_ZH:
699 0 : table = table_DiZi_zh;
700 0 : tableSize = SAL_N_ELEMENTS(table_DiZi_zh);
701 0 : break;
702 : case AIU_FULLWIDTH_JA:
703 0 : table = table_AIUFullWidth_ja_JP;
704 0 : tableSize = SAL_N_ELEMENTS(table_AIUFullWidth_ja_JP);
705 0 : recycleSymbol = sal_True;
706 0 : break;
707 : case AIU_HALFWIDTH_JA:
708 0 : table = table_AIUHalfWidth_ja_JP;
709 0 : tableSize = SAL_N_ELEMENTS(table_AIUHalfWidth_ja_JP);
710 0 : recycleSymbol = sal_True;
711 0 : break;
712 : case IROHA_FULLWIDTH_JA:
713 0 : table = table_IROHAFullWidth_ja_JP;
714 0 : tableSize = SAL_N_ELEMENTS(table_IROHAFullWidth_ja_JP);
715 0 : recycleSymbol = sal_True;
716 0 : break;
717 : case IROHA_HALFWIDTH_JA:
718 0 : table = table_IROHAHalfWidth_ja_JP;
719 0 : tableSize = SAL_N_ELEMENTS(table_IROHAHalfWidth_ja_JP);
720 0 : recycleSymbol = sal_True;
721 0 : break;
722 : case HANGUL_JAMO_KO:
723 0 : table = table_HangulJamo_ko;
724 0 : tableSize = SAL_N_ELEMENTS(table_HangulJamo_ko);
725 0 : recycleSymbol = sal_True;
726 0 : break;
727 : case HANGUL_SYLLABLE_KO:
728 0 : table = table_HangulSyllable_ko;
729 0 : tableSize = SAL_N_ELEMENTS(table_HangulSyllable_ko);
730 0 : recycleSymbol = sal_True;
731 0 : break;
732 : case HANGUL_CIRCLED_JAMO_KO:
733 0 : table = table_HangulCircledJamo_ko;
734 0 : tableSize = SAL_N_ELEMENTS(table_HangulCircledJamo_ko);
735 0 : recycleSymbol = sal_True;
736 0 : break;
737 : case HANGUL_CIRCLED_SYLLABLE_KO:
738 0 : table = table_HangulCircledSyllable_ko;
739 0 : tableSize = SAL_N_ELEMENTS(table_HangulCircledSyllable_ko);
740 0 : recycleSymbol = sal_True;
741 0 : break;
742 : case CHARS_ARABIC:
743 0 : lcl_formatChars(table_Alphabet_ar, SAL_N_ELEMENTS(table_Alphabet_ar), number - 1, result);
744 0 : break;
745 : case CHARS_ARABIC_ABJAD:
746 0 : lcl_formatChars(table_Alphabet_ar_abjad, SAL_N_ELEMENTS(table_Alphabet_ar_abjad), number - 1, result);
747 0 : break;
748 : case CHARS_THAI:
749 0 : lcl_formatChars(table_Alphabet_th, SAL_N_ELEMENTS(table_Alphabet_th), number - 1, result);
750 0 : break;
751 : case CHARS_HEBREW:
752 0 : lcl_formatChars(table_Alphabet_he, SAL_N_ELEMENTS(table_Alphabet_he), number - 1, result);
753 0 : break;
754 : case CHARS_NEPALI:
755 0 : lcl_formatChars(table_Alphabet_ne, SAL_N_ELEMENTS(table_Alphabet_ne), number - 1, result);
756 0 : break;
757 : case CHARS_KHMER:
758 0 : lcl_formatChars(table_Alphabet_km, SAL_N_ELEMENTS(table_Alphabet_km), number - 1, result);
759 0 : break;
760 : case CHARS_LAO:
761 0 : lcl_formatChars(table_Alphabet_lo, SAL_N_ELEMENTS(table_Alphabet_lo), number - 1, result);
762 0 : break;
763 : case CHARS_MYANMAR:
764 0 : lcl_formatChars(table_Alphabet_my, SAL_N_ELEMENTS(table_Alphabet_my), number - 1, result);
765 0 : break;
766 : case CHARS_TIBETAN:
767 0 : lcl_formatChars(table_Alphabet_dz, SAL_N_ELEMENTS(table_Alphabet_dz), number - 1, result);
768 0 : break;
769 : case CHARS_CYRILLIC_UPPER_LETTER_BG:
770 : lcl_formatChars2( table_CyrillicUpperLetter_bg,
771 : table_CyrillicLowerLetter_bg,
772 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg), number-1,
773 0 : result); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Ab, ...
774 0 : break;
775 : case CHARS_CYRILLIC_LOWER_LETTER_BG:
776 : lcl_formatChars( table_CyrillicLowerLetter_bg,
777 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg), number-1,
778 0 : result); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>ab, ...
779 0 : break;
780 : case CHARS_CYRILLIC_UPPER_LETTER_N_BG:
781 : lcl_formatChars3( table_CyrillicUpperLetter_bg,
782 : table_CyrillicLowerLetter_bg,
783 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg), number-1,
784 0 : result); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Bb, ...
785 0 : break;
786 : case CHARS_CYRILLIC_LOWER_LETTER_N_BG:
787 : lcl_formatChars1( table_CyrillicLowerLetter_bg,
788 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg), number-1,
789 0 : result); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>bb, ...
790 0 : break;
791 : case CHARS_CYRILLIC_UPPER_LETTER_RU:
792 : lcl_formatChars2( table_CyrillicUpperLetter_ru,
793 : table_CyrillicLowerLetter_ru,
794 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru), number-1,
795 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
796 0 : break;
797 : case CHARS_CYRILLIC_LOWER_LETTER_RU:
798 : lcl_formatChars( table_CyrillicLowerLetter_ru,
799 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru), number-1,
800 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
801 0 : break;
802 : case CHARS_CYRILLIC_UPPER_LETTER_N_RU:
803 : lcl_formatChars3( table_CyrillicUpperLetter_ru,
804 : table_CyrillicLowerLetter_ru,
805 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru), number-1,
806 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
807 0 : break;
808 : case CHARS_CYRILLIC_LOWER_LETTER_N_RU:
809 : lcl_formatChars1( table_CyrillicLowerLetter_ru,
810 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru), number-1,
811 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
812 0 : break;
813 : case CHARS_CYRILLIC_UPPER_LETTER_SR:
814 : lcl_formatChars2( table_CyrillicUpperLetter_sr,
815 : table_CyrillicLowerLetter_sr,
816 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr), number-1,
817 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
818 0 : break;
819 : case CHARS_CYRILLIC_LOWER_LETTER_SR:
820 : lcl_formatChars( table_CyrillicLowerLetter_sr,
821 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr), number-1,
822 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
823 0 : break;
824 : case CHARS_CYRILLIC_UPPER_LETTER_N_SR:
825 : lcl_formatChars3( table_CyrillicUpperLetter_sr,
826 : table_CyrillicLowerLetter_sr,
827 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr), number-1,
828 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
829 0 : break;
830 : case CHARS_CYRILLIC_LOWER_LETTER_N_SR:
831 : lcl_formatChars1( table_CyrillicLowerLetter_sr,
832 : SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr), number-1,
833 0 : result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
834 0 : break;
835 :
836 : case CHARS_GREEK_LOWER_LETTER:
837 0 : lcl_formatCharsGR( table_GreekLowerLetter, number, result);
838 0 : break;
839 :
840 : case CHARS_GREEK_UPPER_LETTER:
841 0 : lcl_formatCharsGR( table_GreekUpperLetter, number, result);
842 0 : break;
843 :
844 : case CHARS_PERSIAN:
845 0 : lcl_formatChars(table_Alphabet_fa, SAL_N_ELEMENTS(table_Alphabet_fa), number - 1, result);
846 0 : break;
847 :
848 : case CHARS_PERSIAN_WORD:
849 0 : lcl_formatPersianWord(number, result);
850 0 : break;
851 :
852 : default:
853 : OSL_ASSERT(0);
854 0 : throw IllegalArgumentException();
855 : }
856 :
857 142 : if (natNum) {
858 0 : NativeNumberSupplier sNatNum;
859 0 : result += sNatNum.getNativeNumberString(OUString::valueOf( number ), locale, natNum);
860 142 : } else if (tableSize) {
861 0 : if ( number > tableSize && !recycleSymbol)
862 0 : result += OUString::valueOf( number);
863 : else
864 0 : result += OUString(&table[--number % tableSize], 1);
865 : }
866 :
867 : // append suffix
868 142 : if( !should_ignore(suffix) ) result += suffix;
869 :
870 142 : return result;
871 : }
872 :
873 : #define LANG_ALL (1 << 0)
874 : #define LANG_CJK (1 << 1)
875 : #define LANG_CTL (1 << 2)
876 :
877 : struct Supported_NumberingType
878 : {
879 : sal_Int16 nType;
880 : const sal_Char* cSymbol;
881 : sal_Int16 langOption;
882 : };
883 : static const Supported_NumberingType aSupportedTypes[] =
884 : {
885 : {style::NumberingType::CHARS_UPPER_LETTER, "A", LANG_ALL},
886 : {style::NumberingType::CHARS_LOWER_LETTER, "a", LANG_ALL},
887 : {style::NumberingType::ROMAN_UPPER, "I", LANG_ALL},
888 : {style::NumberingType::ROMAN_LOWER, "i", LANG_ALL},
889 : {style::NumberingType::ARABIC, "1", LANG_ALL},
890 : {style::NumberingType::NUMBER_NONE, "''", LANG_ALL},
891 : {style::NumberingType::CHAR_SPECIAL, "Bullet", LANG_ALL},
892 : {style::NumberingType::PAGE_DESCRIPTOR, "Page", LANG_ALL},
893 : {style::NumberingType::BITMAP, "Bitmap", LANG_ALL},
894 : {style::NumberingType::CHARS_UPPER_LETTER_N, "AAA", LANG_ALL},
895 : {style::NumberingType::CHARS_LOWER_LETTER_N, "aaa", LANG_ALL},
896 : {style::NumberingType::NATIVE_NUMBERING, "Native Numbering", LANG_CJK|LANG_CTL},
897 : {style::NumberingType::FULLWIDTH_ARABIC, NULL, LANG_CJK},
898 : {style::NumberingType::CIRCLE_NUMBER, NULL, LANG_CJK},
899 : {style::NumberingType::NUMBER_LOWER_ZH, NULL, LANG_CJK},
900 : {style::NumberingType::NUMBER_UPPER_ZH, NULL, LANG_CJK},
901 : {style::NumberingType::NUMBER_UPPER_ZH_TW, NULL, LANG_CJK},
902 : {style::NumberingType::TIAN_GAN_ZH, NULL, LANG_CJK},
903 : {style::NumberingType::DI_ZI_ZH, NULL, LANG_CJK},
904 : {style::NumberingType::NUMBER_TRADITIONAL_JA, NULL, LANG_CJK},
905 : {style::NumberingType::AIU_FULLWIDTH_JA, NULL, LANG_CJK},
906 : {style::NumberingType::AIU_HALFWIDTH_JA, NULL, LANG_CJK},
907 : {style::NumberingType::IROHA_FULLWIDTH_JA, NULL, LANG_CJK},
908 : {style::NumberingType::IROHA_HALFWIDTH_JA, NULL, LANG_CJK},
909 : {style::NumberingType::NUMBER_UPPER_KO, NULL, LANG_CJK},
910 : {style::NumberingType::NUMBER_HANGUL_KO, NULL, LANG_CJK},
911 : {style::NumberingType::HANGUL_JAMO_KO, NULL, LANG_CJK},
912 : {style::NumberingType::HANGUL_SYLLABLE_KO, NULL, LANG_CJK},
913 : {style::NumberingType::HANGUL_CIRCLED_JAMO_KO, NULL, LANG_CJK},
914 : {style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO, NULL, LANG_CJK},
915 : {style::NumberingType::CHARS_ARABIC, NULL, LANG_CTL},
916 : {style::NumberingType::CHARS_ARABIC_ABJAD, NULL, LANG_CTL},
917 : {style::NumberingType::CHARS_THAI, NULL, LANG_CTL},
918 : {style::NumberingType::CHARS_HEBREW, NULL, LANG_CTL},
919 : {style::NumberingType::CHARS_NEPALI, NULL, LANG_CTL},
920 : {style::NumberingType::CHARS_KHMER, NULL, LANG_CTL},
921 : {style::NumberingType::CHARS_LAO, NULL, LANG_CTL},
922 : {style::NumberingType::CHARS_MYANMAR, NULL, LANG_CTL},
923 : {style::NumberingType::CHARS_TIBETAN, NULL, LANG_CTL},
924 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_BG, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_A S_CYR_B ", ... (bg)", LANG_ALL},
925 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_BG, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_A S_CYR_B ", ... (bg)", LANG_ALL},
926 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_BG, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_B S_CYR_B ", ... (bg)", LANG_ALL},
927 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_BG, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_B S_CYR_B ", ... (bg)", LANG_ALL},
928 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_A S_CYR_B ", ... (ru)", LANG_ALL},
929 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_A S_CYR_B ", ... (ru)", LANG_ALL},
930 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_B S_CYR_B ", ... (ru)", LANG_ALL},
931 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_B S_CYR_B ", ... (ru)", LANG_ALL},
932 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_SR, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_A S_CYR_B ", ... (sr)", LANG_ALL},
933 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_SR, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_A S_CYR_B ", ... (sr)", LANG_ALL},
934 : {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_SR, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_B S_CYR_B ", ... (sr)", LANG_ALL},
935 : {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_SR, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_B S_CYR_B ", ... (sr)", LANG_ALL},
936 : {style::NumberingType::CHARS_PERSIAN, NULL, LANG_CTL},
937 : {style::NumberingType::CHARS_PERSIAN_WORD, NULL, LANG_CTL},
938 : {style::NumberingType::CHARS_GREEK_UPPER_LETTER, C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL},
939 : {style::NumberingType::CHARS_GREEK_LOWER_LETTER, S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL},
940 : };
941 : static const sal_Int32 nSupported_NumberingTypes = sizeof(aSupportedTypes) / sizeof(Supported_NumberingType);
942 :
943 0 : OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
944 : throw(RuntimeException)
945 : {
946 0 : if (aSupportedTypes[index].cSymbol)
947 0 : return OUString(aSupportedTypes[index].cSymbol, strlen(aSupportedTypes[index].cSymbol), RTL_TEXTENCODING_UTF8);
948 : // return OUString::createFromAscii(aSupportedTypes[index].cSymbol);
949 : else {
950 0 : OUString result;
951 0 : Locale aLocale(OUString("en"), OUString(), OUString());
952 0 : Sequence<beans::PropertyValue> aProperties(2);
953 0 : aProperties[0].Name = OUString("NumberingType");
954 0 : aProperties[0].Value <<= aSupportedTypes[index].nType;
955 0 : aProperties[1].Name = OUString("Value");
956 0 : for (sal_Int32 j = 1; j <= 3; j++) {
957 0 : aProperties[1].Value <<= j;
958 0 : result += makeNumberingString( aProperties, aLocale );
959 0 : result += OUString(", ");
960 : }
961 0 : result += OUString("...");
962 0 : return result;
963 : }
964 : }
965 :
966 : sal_Bool SAL_CALL
967 0 : DefaultNumberingProvider::isScriptFlagEnabled(const OUString& aName) throw(RuntimeException)
968 : {
969 0 : if (! xHierarchicalNameAccess.is()) {
970 : Reference< XMultiServiceFactory > xConfigProvider =
971 0 : configuration::theDefaultProvider::get(m_xContext);
972 :
973 0 : if (! xConfigProvider.is())
974 0 : throw RuntimeException();
975 :
976 0 : Sequence< Any > aArgs(1);
977 0 : beans::PropertyValue aPath;
978 0 : aPath.Name = OUString("nodepath");
979 0 : aPath.Value <<= OUString("/org.openoffice.Office.Common/I18N"),
980 0 : aArgs[0] <<= aPath;
981 :
982 0 : Reference<XInterface> xInterface = xConfigProvider->createInstanceWithArguments(
983 0 : OUString("com.sun.star.configuration.ConfigurationAccess"), aArgs);
984 :
985 0 : xHierarchicalNameAccess.set(xInterface, UNO_QUERY);
986 :
987 0 : if (! xHierarchicalNameAccess.is())
988 0 : throw RuntimeException();
989 : }
990 :
991 0 : Any aEnabled = xHierarchicalNameAccess->getByHierarchicalName(aName);
992 :
993 0 : sal_Bool enabled = sal_False;
994 :
995 0 : aEnabled >>= enabled;
996 :
997 0 : return enabled;
998 : }
999 :
1000 0 : Sequence< sal_Int16 > DefaultNumberingProvider::getSupportedNumberingTypes( )
1001 : throw(RuntimeException)
1002 : {
1003 0 : Sequence< sal_Int16 > aRet(nSupported_NumberingTypes );
1004 0 : sal_Int16* pArray = aRet.getArray();
1005 :
1006 0 : sal_Bool cjkEnabled = isScriptFlagEnabled(OUString("CJK/CJKFont"));
1007 0 : sal_Bool ctlEnabled = isScriptFlagEnabled(OUString("CTL/CTLFont"));
1008 :
1009 0 : for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++) {
1010 0 : if ( (aSupportedTypes[i].langOption & LANG_ALL) ||
1011 : ((aSupportedTypes[i].langOption & LANG_CJK) && cjkEnabled) ||
1012 : ((aSupportedTypes[i].langOption & LANG_CTL) && ctlEnabled) )
1013 0 : pArray[i] = aSupportedTypes[i].nType;
1014 : }
1015 0 : return aRet;
1016 : }
1017 :
1018 0 : sal_Int16 DefaultNumberingProvider::getNumberingType( const OUString& rNumberingIdentifier )
1019 : throw(RuntimeException)
1020 : {
1021 0 : for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
1022 0 : if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
1023 0 : return aSupportedTypes[i].nType;
1024 0 : throw RuntimeException();
1025 : }
1026 :
1027 0 : sal_Bool DefaultNumberingProvider::hasNumberingType( const OUString& rNumberingIdentifier )
1028 : throw(RuntimeException)
1029 : {
1030 0 : for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
1031 0 : if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
1032 0 : return sal_True;
1033 0 : return sal_False;
1034 : }
1035 :
1036 0 : OUString DefaultNumberingProvider::getNumberingIdentifier( sal_Int16 nNumberingType )
1037 : throw(RuntimeException)
1038 : {
1039 0 : for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
1040 0 : if(nNumberingType == aSupportedTypes[i].nType)
1041 0 : return makeNumberingIdentifier(i);
1042 0 : return OUString();
1043 : }
1044 :
1045 : const sal_Char cDefaultNumberingProvider[] = "com.sun.star.text.DefaultNumberingProvider";
1046 0 : OUString DefaultNumberingProvider::getImplementationName(void)
1047 : throw( RuntimeException )
1048 : {
1049 0 : return OUString::createFromAscii(cDefaultNumberingProvider);
1050 : }
1051 :
1052 0 : sal_Bool DefaultNumberingProvider::supportsService(const rtl::OUString& rServiceName)
1053 : throw( RuntimeException )
1054 : {
1055 0 : return rServiceName.equalsAscii(cDefaultNumberingProvider);
1056 : }
1057 :
1058 0 : Sequence< OUString > DefaultNumberingProvider::getSupportedServiceNames(void)
1059 : throw( RuntimeException )
1060 : {
1061 0 : Sequence< OUString > aRet(1);
1062 0 : aRet[0] = OUString::createFromAscii(cDefaultNumberingProvider);
1063 0 : return aRet;
1064 : }
1065 :
1066 : } } } }
1067 :
1068 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|