1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <defaultnumberingprovider.hxx>
21 #include <transliterationImpl.hxx>
22 #include <com/sun/star/i18n/NativeNumberMode.hpp>
23 #include <com/sun/star/lang/IllegalArgumentException.hpp>
24 #include <com/sun/star/style/NumberingType.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/configuration/theDefaultProvider.hpp>
27 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
28 #include <osl/diagnose.h>
29 #include <rtl/ref.hxx>
30 #include <localedata.hxx>
31 #include <nativenumbersupplier.hxx>
33 #include <comphelper/propertysequence.hxx>
34 #include <cppuhelper/supportsservice.hxx>
36 // Cyrillic upper case
37 #define C_CYR_A "\xD0\x90"
38 #define C_CYR_B "\xD0\x91"
39 // Cyrillic lower case
40 #define S_CYR_A "\xD0\xB0"
41 #define S_CYR_B "\xD0\xB1"
44 #define C_GR_A "\xCE\x91"
45 #define C_GR_B "\xCE\x92"
47 #define S_GR_A "\xCE\xB1"
48 #define S_GR_B "\xCE\xB2"
51 #define S_HE_ALEPH "\xD7\x90"
52 #define S_HE_YOD "\xD7\x99"
53 #define S_HE_QOF "\xD7\xA7"
56 #define S_AR_ONE "\xd9\xa1"
57 #define S_AR_TWO "\xd9\xa2"
58 #define S_AR_THREE "\xd9\xa3"
61 #define S_FA_ONE "\xDB\xB1"
62 #define S_FA_TWO "\xDB\xB2"
63 #define S_FA_THREE "\xDB\xB3"
66 #define S_HI_ONE "\xDB\xB1"
67 #define S_HI_TWO "\xDB\xB2"
68 #define S_HI_THREE "\xDB\xB3"
70 #include <sal/macros.h>
71 #include <rtl/ustring.hxx>
72 #include <rtl/ustrbuf.hxx>
76 using namespace com::sun::star
;
77 using namespace com::sun::star::uno
;
78 using namespace ::com::sun::star::i18n
;
79 using namespace com::sun::star::lang
;
83 static const sal_Unicode table_Alphabet_ar
[] = {
84 0x0623, 0x0628, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E,
85 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635,
86 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x0642,
87 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649
90 static const sal_Unicode table_Alphabet_ar_abjad
[] = {
91 0x0627, 0x0628, 0x062c, 0x062f, 0x0647, 0x0648, 0x0632, 0x062d,
92 0x0637, 0x064a, 0x0643, 0x0644, 0x0645, 0x0646, 0x0633, 0x0639,
93 0x0641, 0x0635, 0x0642, 0x0631, 0x0634, 0x062a, 0x062b, 0x062e,
94 0x0630, 0x0636, 0x0638, 0x063a
97 static const sal_Unicode table_Alphabet_th
[] = {
98 0x0E01, 0x0E02, 0x0E04, 0x0E07,
99 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
100 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
101 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
102 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
103 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E
106 static const sal_Unicode table_Alphabet_he
[] = {
107 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
108 0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0, 0x05E1, 0x05E2,
109 0x05E4, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA
112 static const sal_Unicode table_Alphabet_ne
[] = {
113 0x0915, 0x0916, 0x0917, 0x0918, 0x0919, 0x091A, 0x091B, 0x091C,
114 0x091D, 0x091E, 0x091F, 0x0920, 0x0921, 0x0922, 0x0923, 0x0924,
115 0x0925, 0x0926, 0x0927, 0x0928, 0x092A, 0x092B, 0x092C, 0x092D,
116 0x092E, 0x092F, 0x0930, 0x0932, 0x0935, 0x0936, 0x0937, 0x0938,
120 static const sal_Unicode table_Alphabet_km
[] = {
121 0x1780, 0x1781, 0x1782, 0x1783, 0x1784, 0x1785, 0x1786, 0x1787,
122 0x1788, 0x1789, 0x178A, 0x178B, 0x178C, 0x178D, 0x178E, 0x178F,
123 0x1790, 0x1791, 0x1792, 0x1793, 0x1794, 0x1795, 0x1796, 0x1797,
124 0x1798, 0x1799, 0x179A, 0x179B, 0x179C, 0x179F,
125 0x17A0, 0x17A1, 0x17A2
128 static const sal_Unicode table_Alphabet_lo
[] = {
129 0x0E81, 0x0E82, 0x0E84, 0x0E87, 0x0E88, 0x0E8A, 0x0E8D, 0x0E94,
130 0x0E95, 0x0E96, 0x0E97, 0x0E99, 0x0E9A, 0x0E9B, 0x0E9C,
131 0x0E9D, 0x0E9E, 0x0E9F, 0x0EA1, 0x0EA2, 0x0EA3, 0x0EA5, 0x0EA7,
132 0x0EAA, 0x0EAB, 0x0EAD, 0x0EAE, 0x0EAF, 0x0EAE, 0x0EDC, 0x0EDD
135 static const sal_Unicode table_Alphabet_dz
[] = {
136 0x0F40, 0x0F41, 0x0F42, 0x0F44, 0x0F45, 0x0F46, 0x0F47, 0x0F49,
137 0x0F4F, 0x0F50, 0x0F51, 0x0F53, 0x0F54, 0x0F55, 0x0F56, 0x0F58,
138 0x0F59, 0x0F5A, 0x0F5B, 0x0F5D, 0x0F5E, 0x0F5F, 0x0F60, 0x0F61,
139 0x0F62, 0x0F63, 0x0F64, 0x0F66, 0x0F67, 0x0F68
142 static const sal_Unicode table_Alphabet_my
[] = {
143 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007,
144 0x1008,/*0x1009,*/0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F,
145 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017,
146 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F,
150 // Bulgarian Cyrillic upper case letters
151 static const sal_Unicode table_CyrillicUpperLetter_bg
[] = {
152 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418,
153 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422,
154 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042E,
158 // Bulgarian cyrillic lower case letters
159 static const sal_Unicode table_CyrillicLowerLetter_bg
[] = {
160 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438,
161 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442,
162 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044E,
166 // Russian Cyrillic upper letters
167 static const sal_Unicode table_CyrillicUpperLetter_ru
[] = {
168 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
169 0x0418, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420,
170 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
171 0x0429, 0x042B, 0x042D, 0x042E, 0x042F
174 // Russian cyrillic lower letters
175 static const sal_Unicode table_CyrillicLowerLetter_ru
[] = {
176 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
177 0x0438, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440,
178 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448,
179 0x0449, 0x044B, 0x044D, 0x044E, 0x044F
182 // Serbian Cyrillic upper letters
183 static const sal_Unicode table_CyrillicUpperLetter_sr
[] = {
184 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0402, 0x0415, 0x0416,
185 0x0417, 0x0418, 0x0408, 0x041A, 0x041B, 0x0409, 0x041C, 0x041D,
186 0x040A, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x040B, 0x0423,
187 0x0424, 0x0425, 0x0426, 0x0427, 0x040F, 0x0428
190 // Serbian cyrillic lower letters
191 static const sal_Unicode table_CyrillicLowerLetter_sr
[] = {
192 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0452, 0x0435, 0x0436,
193 0x0437, 0x0438, 0x0458, 0x043A, 0x043B, 0x0459, 0x043C, 0x043D,
194 0x045A, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x045B, 0x0443,
195 0x0444, 0x0445, 0x0446, 0x0447, 0x045F, 0x0448
198 static const sal_Unicode table_GreekUpperLetter
[] = {
199 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x03DB, 0x0396, 0x0397, 0x0398,
200 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03DF,
201 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03E0
204 static const sal_Unicode table_GreekLowerLetter
[] = {
205 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03DB, 0x03B6, 0x03B7, 0x03B8,
206 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03DF,
207 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03E1
210 static const sal_Unicode table_Alphabet_fa
[] = {
211 0x0622, 0x0628, 0x067E, 0x062A, 0x062B, 0x062C, 0x0686, 0x062D,
212 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0698, 0x0633, 0x0634,
213 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x0640, 0x0641, 0x0642,
214 0x06A9, 0x06AF, 0x0644, 0x0645, 0x0646, 0x0648, 0x0647, 0x06CC
217 static const sal_Unicode upperLetter
[] = {
218 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
219 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
220 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
223 static const sal_Unicode lowerLetter
[] = {
224 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
225 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
226 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
229 // Tables used for numbering in persian words
230 static const sal_Unicode table_PersianWord_decade1
[][7]={
232 {0x06cc, 0x06a9, 0}, // 1
233 {0x062f, 0x0648, 0}, // 2
234 {0x0633, 0x0647, 0}, // 3
235 {0x0686, 0x0647, 0x0627, 0x0631, 0}, // 4
236 {0x067e, 0x0646, 0x062c, 0}, // 5
237 {0x0634, 0x0634, 0}, // 6
238 {0x0647, 0x0641, 0x062a, 0}, // 7
239 {0x0647, 0x0634, 0x062a, 0}, // 8
240 {0x0646, 0x0647, 0}, // 9
241 {0x062f, 0x0647, 0}, // 10
242 {0x06cc, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 11
243 {0x062f, 0x0648, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 12
244 {0x0633, 0x06cc, 0x0632, 0x062f, 0x0647, 0}, // 13
245 {0x0686, 0x0647, 0x0627, 0x0631, 0x062f, 0x0647, 0}, // 14
246 {0x067e, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 15
247 {0x0634, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 16
248 {0x0647, 0x0641, 0x062f, 0x0647, 0}, // 17
249 {0x0647, 0x062c, 0x062f, 0x0647, 0}, // 18
250 {0x0646, 0x0648, 0x0632, 0x062f, 0x0647, 0} // 19
253 static const sal_Unicode table_PersianWord_decade2
[][6]={
254 {0x0628, 0x06cc, 0x0633, 0x062a, 0}, // 20
255 {0x0633, 0x06cc, 0}, // 30
256 {0x0686, 0x0647, 0x0644, 0}, // 40
257 {0x067e, 0x0646, 0x062c, 0x0627, 0x0647, 0}, // 50
258 {0x0634, 0x0635, 0x062a, 0}, // 60
259 {0x0647, 0x0641, 0x062a, 0x0627, 0x062f, 0}, // 70
260 {0x0647, 0x0634, 0x062a, 0x0627, 0x062f, 0}, // 80
261 {0x0646, 0x0648, 0x062f, 0} // 90
264 static const sal_Unicode table_PersianWord_decade3
[][7]={
265 {0x0635, 0x062f, 0}, // 100
266 {0x062f, 0x0648, 0x06cc, 0x0633, 0x062a, 0}, // 200
267 {0x0633, 0x06cc, 0x0635, 0x062f, 0}, // 300
268 {0x0686, 0x0647, 0x0627, 0x0631, 0x0635, 0x062f, 0}, // 400
269 {0x067e, 0x0627, 0x0646, 0x0635, 0x062f, 0}, // 500
270 {0x0634, 0x0635, 0x062f, 0}, // 600
271 {0x0647, 0x0641, 0x062a, 0x0635, 0x062f, 0}, // 700
272 {0x0647, 0x0634, 0x062a, 0x0635, 0x062f, 0}, // 800
273 {0x0646, 0x0647, 0x0635, 0x062f, 0} // 900
276 static const sal_Unicode table_PersianWord_decadeX
[][8]={
277 {0x0647, 0x0632, 0x0627, 0x0631, 0}, // 1000
278 {0x0645, 0x06cc, 0x0644, 0x06cc, 0x0648, 0x0646, 0}, // 1000000
279 {0x0645, 0x06cc, 0x0644, 0x06cc, 0x0627, 0x0631, 0x062f, 0} // 1000000000
283 DefaultNumberingProvider::DefaultNumberingProvider( const Reference
< XComponentContext
>& rxContext
) : m_xContext(rxContext
)
288 DefaultNumberingProvider::~DefaultNumberingProvider()
292 Sequence
< Reference
<container::XIndexAccess
> >
293 DefaultNumberingProvider::getDefaultOutlineNumberings(const Locale
& rLocale
)
295 return LocaleDataImpl::get()->getOutlineNumberingLevels( rLocale
);
298 Sequence
< Sequence
<beans::PropertyValue
> >
299 DefaultNumberingProvider::getDefaultContinuousNumberingLevels( const Locale
& rLocale
)
301 return LocaleDataImpl::get()->getContinuousNumberingLevels( rLocale
);
304 static OUString
toRoman( sal_Int32 n
)
307 // i, ii, iii, iv, v, vi, vii, vii, viii, ix
308 // (Dummy),1000,500,100,50,10,5,1
309 static const sal_Char coRomanArr
[] = "MDCLXVI--"; // +2 Dummy entries !!
310 const sal_Char
* cRomanStr
= coRomanArr
;
311 sal_uInt16 nMask
= 1000;
312 sal_uInt32 nOver1000
= n
/ nMask
;
313 n
-= ( nOver1000
* nMask
);
317 sTmp
.append(*coRomanArr
);
321 sal_uInt8 nNumber
= sal_uInt8( n
/ nMask
);
328 sTmp
.append(*(cRomanStr
-1));
334 case 3: sTmp
.append(*cRomanStr
); [[fallthrough
]];
335 case 2: sTmp
.append(*cRomanStr
); [[fallthrough
]];
336 case 1: sTmp
.append(*cRomanStr
); break;
337 case 4: sTmp
.append(*cRomanStr
).append(*(cRomanStr
-nDiff
)); break;
338 case 5: sTmp
.append(*(cRomanStr
-nDiff
)); break;
341 nMask
/= 10; // to the next decade
344 return sTmp
.makeStringAndClear();
350 void lcl_formatChars( const sal_Unicode table
[], int tableSize
, int n
, OUString
& s
)
352 // string representation of n is appended to s.
353 // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>AB, ...
354 // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>ab, ...
356 if( n
>=tableSize
) lcl_formatChars( table
, tableSize
, (n
-tableSize
)/tableSize
, s
);
358 s
+= OUStringLiteral1( table
[ n
% tableSize
] );
362 void lcl_formatChars1( const sal_Unicode table
[], int tableSize
, int n
, OUString
& s
)
364 // string representation of n is appended to s.
365 // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>BB, ...
366 // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>bb, ...
368 int repeat_count
= n
/ tableSize
+ 1;
370 for( int i
=0; i
<repeat_count
; i
++ )
371 s
+= OUStringLiteral1( table
[ n
%tableSize
] );
375 void lcl_formatChars2( const sal_Unicode table_capital
[], const sal_Unicode table_small
[], int tableSize
, int n
, OUString
& s
)
377 // string representation of n is appended to s.
378 // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Ab, ...
382 lcl_formatChars2( table_capital
, table_small
, tableSize
, (n
-tableSize
)/tableSize
, s
);
383 s
+= OUStringLiteral1( table_small
[ n
% tableSize
] );
385 s
+= OUStringLiteral1( table_capital
[ n
% tableSize
] );
389 void lcl_formatChars3( const sal_Unicode table_capital
[], const sal_Unicode table_small
[], int tableSize
, int n
, OUString
& s
)
391 // string representation of n is appended to s.
392 // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Bb, ...
394 int repeat_count
= n
/ tableSize
+ 1;
395 s
+= OUStringLiteral1( table_capital
[ n
%tableSize
] );
397 for( int i
=1; i
<repeat_count
; i
++ )
398 s
+= OUStringLiteral1( table_small
[ n
%tableSize
] );
402 /** Returns number's representation in persian words up to 999999999999
403 respectively limited by sal_Int32 >=0.
404 The caller assures that nNumber is not negative.
406 @throws IllegalArgumentException
407 @throws RuntimeException
410 void lcl_formatPersianWord( sal_Int32 nNumber
, OUString
& rsResult
)
412 OUStringBuffer
aTemp(64);
413 static const sal_Unicode asPersianWord_conjunction_data
[] = {0x20,0x0648,0x20,0};
414 OUString
asPersianWord_conjunction( asPersianWord_conjunction_data
);
415 unsigned char nSection
= 0;
417 while (int nPart
= nNumber
% 1000)
421 if (nSection
> SAL_N_ELEMENTS( table_PersianWord_decadeX
))
422 throw IllegalArgumentException(); // does not happen with sal_Int32
423 aTemp
.insert( 0, asPersianWord_conjunction
).insert( 0, table_PersianWord_decadeX
[nSection
-1]);
427 if ((nDigit
= nPart
% 100) < 20)
429 if (!aTemp
.isEmpty())
430 aTemp
.insert( 0, u
' ');
431 aTemp
.insert( 0, table_PersianWord_decade1
[nDigit
]);
435 if ((nDigit
= nPart
% 10) != 0)
437 if (!aTemp
.isEmpty())
438 aTemp
.insert( 0, asPersianWord_conjunction
);
439 aTemp
.insert( 0, table_PersianWord_decade1
[nDigit
]);
441 if ((nDigit
= (nPart
/ 10) % 10) != 0)
443 if (!aTemp
.isEmpty())
444 aTemp
.insert( 0, asPersianWord_conjunction
);
445 aTemp
.insert( 0, table_PersianWord_decade2
[nDigit
-2]);
449 if ((nDigit
= nPart
/ 100) != 0)
451 if (!aTemp
.isEmpty())
452 aTemp
.insert( 0, asPersianWord_conjunction
);
453 aTemp
.insert( 0, table_PersianWord_decade3
[nDigit
-1]);
463 // Greek Letter Numbering
465 // KERAIA separates numerals from other text
466 #define STIGMA u'\x03DB'
467 #define LEFT_KERAIA u'\x0375'
468 #define MYRIAD_SYM u'\x039C'
470 #define SIGMA_OFFSET 19
471 #define TAU_OFFSET 20
475 * Return the 1-999999 number's representation in the Greek numbering system.
476 * Adding a "left keraia" to represent numbers in the range 10000 ... 999999 is
477 * not orthodox, so it's better to use the myriad notation and call this method
478 * only for numbers up to 9999.
481 OUString
gr_smallNum(const sal_Unicode table
[], int n
)
484 throw IllegalArgumentException();
488 for (int v
= n
; v
> 0; v
/= 10, i
++) {
493 sal_Unicode sign
= table
[(digit
- 1) + 9 * (i
% 3)];
494 if (sign
== STIGMA
) {
495 sb
.insert(0, table
[TAU_OFFSET
]);
496 sb
.insert(0, table
[SIGMA_OFFSET
]);
502 sb
.insert(0, LEFT_KERAIA
);
505 return sb
.makeStringAndClear();
509 void lcl_formatCharsGR(const sal_Unicode table
[], int n
, OUString
& s
)
514 for (int divisor
= MYRIAD
* MYRIAD
; divisor
> 1; divisor
/= MYRIAD
, myriadPower
--) {
515 if (n
> divisor
- 1) {
517 * Follow the Diophantus representation of:
518 * A myriad sign, M(10000) as many times as the power
519 * followed by the multiplier for the myriad
521 * followed by the rest
522 * This is enough for 32-bit integers
524 for (int i
= 0; i
< myriadPower
; i
++)
525 sb
.append(MYRIAD_SYM
);
527 sb
.append(gr_smallNum(table
, n
/divisor
));
534 sb
.append(gr_smallNum(table
,n
));
540 bool should_ignore( const OUString
& s
)
542 // return true if blank or null
543 return s
== " " || (!s
.isEmpty() && s
[0]==0);
547 Any
getPropertyByName( const Sequence
<beans::PropertyValue
>& aProperties
,
548 const char* name
, bool bRequired
)
550 for( int i
=0; i
<aProperties
.getLength(); i
++ )
551 if( aProperties
[i
].Name
.equalsAscii(name
) )
552 return aProperties
[i
].Value
;
554 throw IllegalArgumentException();
558 //XNumberingFormatter
560 DefaultNumberingProvider::makeNumberingString( const Sequence
<beans::PropertyValue
>& aProperties
,
561 const Locale
& aLocale
)
563 // the Sequence of PropertyValues is expected to have at least 4 elements:
564 // elt Name Type purpose
567 // 0. "Prefix" OUString
568 // 1. "NumberingType" sal_Int16 type of formatting from style::NumberingType (roman, arabic, etc)
569 // 2. "Suffix" OUString
571 // n. "Value" sal_Int32 the number to be formatted
573 // given the Sequence { '(', NumberingType::ROMAN_UPPER, ')', ..., 7 }
574 // makeNumberingString() returns the string "(VII)".
576 // Q: why is the type of numType sal_Int16 instead of style::NumberingType?
577 // A: an Any can't hold a style::NumberingType for some reason.
578 // add.: style::NumberingType holds constants of type sal_Int16, it's not an enum type
580 sal_Int16 natNum
= 0;
581 sal_Int16 tableSize
= 0;
582 const sal_Unicode
*table
= nullptr; // initialize to avoid compiler warning
583 bool bRecycleSymbol
= false;
584 OUString sNatNumParams
;
588 sal_Int16 numType
= -1; // type of formatting from style::NumberingType (roman, arabic, etc)
590 sal_Int32 number
= -12345; // the number that needs to be formatted.
592 // int nProperties = aProperties.getLength();
593 // int last = nProperties-1;
596 getPropertyByName(aProperties
, "Prefix", false) >>=prefix
;
597 } catch (Exception
&) {
598 //prefix _must_ be empty here!
601 getPropertyByName(aProperties
, "Suffix", false) >>=suffix
;
602 } catch (Exception
&) {
603 //suffix _must_ be empty here!
606 getPropertyByName(aProperties
, "NumberingType", true) >>=numType
;
607 } catch (Exception
& ) {
611 getPropertyByName(aProperties
, "Value", true) >>=number
;
612 } catch (Exception
& ) {
617 throw IllegalArgumentException();
623 if( !should_ignore(prefix
) ) result
+= prefix
;
625 // append formatted number
626 using namespace style::NumberingType
;
629 case CHARS_UPPER_LETTER
:
630 lcl_formatChars( upperLetter
, 26, number
-1, result
); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>AB, ...
632 case CHARS_LOWER_LETTER
:
633 lcl_formatChars( lowerLetter
, 26, number
-1, result
);
635 case TEXT_NUMBER
: // ordinal indicators (1st, 2nd, 3rd, ...)
636 natNum
= NativeNumberMode::NATNUM12
;
637 sNatNumParams
= "capitalize ordinal-number";
640 case TEXT_CARDINAL
: // cardinal number names (One, Two, Three, ...)
641 natNum
= NativeNumberMode::NATNUM12
;
642 sNatNumParams
= "capitalize";
645 case TEXT_ORDINAL
: // ordinal number names (First, Second, Third, ...)
646 natNum
= NativeNumberMode::NATNUM12
;
647 sNatNumParams
= "capitalize ordinal";
651 result
+= toRoman( number
);
654 result
+= toRoman( number
).toAsciiLowerCase();
657 result
+= OUString::number( number
);
660 return OUString(); // ignore prefix and suffix
662 // apparently, we're supposed to return an empty string in this case...
663 return OUString(); // ignore prefix and suffix
664 case PAGE_DESCRIPTOR
:
667 throw IllegalArgumentException();
668 case CHARS_UPPER_LETTER_N
:
669 lcl_formatChars1( upperLetter
, 26, number
-1, result
); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
671 case CHARS_LOWER_LETTER_N
:
672 lcl_formatChars1( lowerLetter
, 26, number
-1, result
); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
674 case TRANSLITERATION
:
676 const OUString
&tmp
= OUString::number( number
);
677 OUString transliteration
;
678 getPropertyByName(aProperties
, "Transliteration", true) >>= transliteration
;
680 translit
= new TransliterationImpl(m_xContext
);
681 translit
->loadModuleByImplName(transliteration
, aLocale
);
682 result
+= translit
->transliterateString2String(tmp
, 0, tmp
.getLength());
683 } catch (Exception
& ) {
684 // When transliteration property is missing, return default number (bug #101141#)
685 result
+= OUString::number( number
);
687 // throw IllegalArgumentException();
690 case NATIVE_NUMBERING
:
691 natNum
= NativeNumberMode::NATNUM1
;
694 case FULLWIDTH_ARABIC
:
695 natNum
= NativeNumberMode::NATNUM3
;
698 case NUMBER_LOWER_ZH
:
699 natNum
= NativeNumberMode::NATNUM7
;
700 locale
.Language
= "zh";
702 case NUMBER_UPPER_ZH
:
703 natNum
= NativeNumberMode::NATNUM8
;
704 locale
.Language
= "zh";
706 case NUMBER_UPPER_ZH_TW
:
707 natNum
= NativeNumberMode::NATNUM8
;
708 locale
.Language
= "zh";
709 locale
.Country
= "TW";
711 case NUMBER_TRADITIONAL_JA
:
712 natNum
= NativeNumberMode::NATNUM8
;
713 locale
.Language
= "ja";
715 case NUMBER_UPPER_KO
:
716 natNum
= NativeNumberMode::NATNUM8
;
717 locale
.Language
= "ko";
719 case NUMBER_HANGUL_KO
:
720 natNum
= NativeNumberMode::NATNUM11
;
721 locale
.Language
= "ko";
725 table
= table_CircledNumber
;
726 tableSize
= SAL_N_ELEMENTS(table_CircledNumber
);
729 table
= table_TianGan_zh
;
730 tableSize
= SAL_N_ELEMENTS(table_TianGan_zh
);
733 table
= table_DiZi_zh
;
734 tableSize
= SAL_N_ELEMENTS(table_DiZi_zh
);
736 case AIU_FULLWIDTH_JA
:
737 table
= table_AIUFullWidth_ja_JP
;
738 tableSize
= SAL_N_ELEMENTS(table_AIUFullWidth_ja_JP
);
739 bRecycleSymbol
= true;
741 case AIU_HALFWIDTH_JA
:
742 table
= table_AIUHalfWidth_ja_JP
;
743 tableSize
= SAL_N_ELEMENTS(table_AIUHalfWidth_ja_JP
);
744 bRecycleSymbol
= true;
746 case IROHA_FULLWIDTH_JA
:
747 table
= table_IROHAFullWidth_ja_JP
;
748 tableSize
= SAL_N_ELEMENTS(table_IROHAFullWidth_ja_JP
);
749 bRecycleSymbol
= true;
751 case IROHA_HALFWIDTH_JA
:
752 table
= table_IROHAHalfWidth_ja_JP
;
753 tableSize
= SAL_N_ELEMENTS(table_IROHAHalfWidth_ja_JP
);
754 bRecycleSymbol
= true;
757 table
= table_HangulJamo_ko
;
758 tableSize
= SAL_N_ELEMENTS(table_HangulJamo_ko
);
759 bRecycleSymbol
= true;
761 case HANGUL_SYLLABLE_KO
:
762 table
= table_HangulSyllable_ko
;
763 tableSize
= SAL_N_ELEMENTS(table_HangulSyllable_ko
);
764 bRecycleSymbol
= true;
766 case HANGUL_CIRCLED_JAMO_KO
:
767 table
= table_HangulCircledJamo_ko
;
768 tableSize
= SAL_N_ELEMENTS(table_HangulCircledJamo_ko
);
769 bRecycleSymbol
= true;
771 case HANGUL_CIRCLED_SYLLABLE_KO
:
772 table
= table_HangulCircledSyllable_ko
;
773 tableSize
= SAL_N_ELEMENTS(table_HangulCircledSyllable_ko
);
774 bRecycleSymbol
= true;
777 lcl_formatChars(table_Alphabet_ar
, SAL_N_ELEMENTS(table_Alphabet_ar
), number
- 1, result
);
779 case CHARS_ARABIC_ABJAD
:
780 lcl_formatChars(table_Alphabet_ar_abjad
, SAL_N_ELEMENTS(table_Alphabet_ar_abjad
), number
- 1, result
);
782 case NUMBER_ARABIC_INDIC
:
783 natNum
= NativeNumberMode::NATNUM1
;
784 locale
.Language
= "ar";
786 case NUMBER_EAST_ARABIC_INDIC
:
787 natNum
= NativeNumberMode::NATNUM1
;
788 locale
.Language
= "fa";
790 case NUMBER_INDIC_DEVANAGARI
:
791 natNum
= NativeNumberMode::NATNUM1
;
792 locale
.Language
= "hi";
795 lcl_formatChars(table_Alphabet_th
, SAL_N_ELEMENTS(table_Alphabet_th
), number
- 1, result
);
798 lcl_formatChars(table_Alphabet_he
, SAL_N_ELEMENTS(table_Alphabet_he
), number
- 1, result
);
801 natNum
= NativeNumberMode::NATNUM1
;
802 locale
.Language
= "he";
805 lcl_formatChars(table_Alphabet_ne
, SAL_N_ELEMENTS(table_Alphabet_ne
), number
- 1, result
);
808 lcl_formatChars(table_Alphabet_km
, SAL_N_ELEMENTS(table_Alphabet_km
), number
- 1, result
);
811 lcl_formatChars(table_Alphabet_lo
, SAL_N_ELEMENTS(table_Alphabet_lo
), number
- 1, result
);
814 lcl_formatChars(table_Alphabet_my
, SAL_N_ELEMENTS(table_Alphabet_my
), number
- 1, result
);
817 lcl_formatChars(table_Alphabet_dz
, SAL_N_ELEMENTS(table_Alphabet_dz
), number
- 1, result
);
819 case CHARS_CYRILLIC_UPPER_LETTER_BG
:
820 lcl_formatChars2( table_CyrillicUpperLetter_bg
,
821 table_CyrillicLowerLetter_bg
,
822 SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg
), number
-1,
823 result
); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Ab, ...
825 case CHARS_CYRILLIC_LOWER_LETTER_BG
:
826 lcl_formatChars( table_CyrillicLowerLetter_bg
,
827 SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg
), number
-1,
828 result
); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>ab, ...
830 case CHARS_CYRILLIC_UPPER_LETTER_N_BG
:
831 lcl_formatChars3( table_CyrillicUpperLetter_bg
,
832 table_CyrillicLowerLetter_bg
,
833 SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg
), number
-1,
834 result
); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Bb, ...
836 case CHARS_CYRILLIC_LOWER_LETTER_N_BG
:
837 lcl_formatChars1( table_CyrillicLowerLetter_bg
,
838 SAL_N_ELEMENTS(table_CyrillicLowerLetter_bg
), number
-1,
839 result
); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>bb, ...
841 case CHARS_CYRILLIC_UPPER_LETTER_RU
:
842 lcl_formatChars2( table_CyrillicUpperLetter_ru
,
843 table_CyrillicLowerLetter_ru
,
844 SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru
), number
-1,
845 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
847 case CHARS_CYRILLIC_LOWER_LETTER_RU
:
848 lcl_formatChars( table_CyrillicLowerLetter_ru
,
849 SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru
), number
-1,
850 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
852 case CHARS_CYRILLIC_UPPER_LETTER_N_RU
:
853 lcl_formatChars3( table_CyrillicUpperLetter_ru
,
854 table_CyrillicLowerLetter_ru
,
855 SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru
), number
-1,
856 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
858 case CHARS_CYRILLIC_LOWER_LETTER_N_RU
:
859 lcl_formatChars1( table_CyrillicLowerLetter_ru
,
860 SAL_N_ELEMENTS(table_CyrillicLowerLetter_ru
), number
-1,
861 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
863 case CHARS_CYRILLIC_UPPER_LETTER_SR
:
864 lcl_formatChars2( table_CyrillicUpperLetter_sr
,
865 table_CyrillicLowerLetter_sr
,
866 SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr
), number
-1,
867 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
869 case CHARS_CYRILLIC_LOWER_LETTER_SR
:
870 lcl_formatChars( table_CyrillicLowerLetter_sr
,
871 SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr
), number
-1,
872 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
874 case CHARS_CYRILLIC_UPPER_LETTER_N_SR
:
875 lcl_formatChars3( table_CyrillicUpperLetter_sr
,
876 table_CyrillicLowerLetter_sr
,
877 SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr
), number
-1,
878 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
880 case CHARS_CYRILLIC_LOWER_LETTER_N_SR
:
881 lcl_formatChars1( table_CyrillicLowerLetter_sr
,
882 SAL_N_ELEMENTS(table_CyrillicLowerLetter_sr
), number
-1,
883 result
); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
886 case CHARS_GREEK_LOWER_LETTER
:
887 lcl_formatCharsGR( table_GreekLowerLetter
, number
, result
);
890 case CHARS_GREEK_UPPER_LETTER
:
891 lcl_formatCharsGR( table_GreekUpperLetter
, number
, result
);
895 lcl_formatChars(table_Alphabet_fa
, SAL_N_ELEMENTS(table_Alphabet_fa
), number
- 1, result
);
898 case CHARS_PERSIAN_WORD
:
899 lcl_formatPersianWord(number
, result
);
904 throw IllegalArgumentException();
908 rtl::Reference
<NativeNumberSupplierService
> xNatNum(new NativeNumberSupplierService
);
909 result
+= xNatNum
->getNativeNumberStringParams(OUString::number(number
), locale
,
910 natNum
, sNatNumParams
);
911 } else if (tableSize
) {
912 if ( number
> tableSize
&& !bRecycleSymbol
)
913 result
+= OUString::number( number
);
915 result
+= OUString(&table
[--number
% tableSize
], 1);
919 if( !should_ignore(suffix
) ) result
+= suffix
;
924 #define LANG_ALL (1 << 0)
925 #define LANG_CJK (1 << 1)
926 #define LANG_CTL (1 << 2)
928 struct Supported_NumberingType
931 const sal_Char
* cSymbol
;
932 sal_Int16 langOption
;
934 static const Supported_NumberingType aSupportedTypes
[] =
936 {style::NumberingType::CHARS_UPPER_LETTER
, "A", LANG_ALL
},
937 {style::NumberingType::CHARS_LOWER_LETTER
, "a", LANG_ALL
},
938 {style::NumberingType::ROMAN_UPPER
, "I", LANG_ALL
},
939 {style::NumberingType::ROMAN_LOWER
, "i", LANG_ALL
},
940 {style::NumberingType::ARABIC
, "1", LANG_ALL
},
941 {style::NumberingType::NUMBER_NONE
, "''", LANG_ALL
},
942 {style::NumberingType::CHAR_SPECIAL
, "Bullet", LANG_ALL
},
943 {style::NumberingType::PAGE_DESCRIPTOR
, "Page", LANG_ALL
},
944 {style::NumberingType::BITMAP
, "Bitmap", LANG_ALL
},
945 {style::NumberingType::TEXT_NUMBER
, "1st", LANG_ALL
},
946 {style::NumberingType::TEXT_CARDINAL
, "One", LANG_ALL
},
947 {style::NumberingType::TEXT_ORDINAL
, "First", LANG_ALL
},
948 {style::NumberingType::CHARS_UPPER_LETTER_N
, "AAA", LANG_ALL
},
949 {style::NumberingType::CHARS_LOWER_LETTER_N
, "aaa", LANG_ALL
},
950 {style::NumberingType::NATIVE_NUMBERING
, "Native Numbering", LANG_CJK
|LANG_CTL
},
951 {style::NumberingType::FULLWIDTH_ARABIC
, nullptr, LANG_CJK
},
952 {style::NumberingType::CIRCLE_NUMBER
, nullptr, LANG_CJK
},
953 {style::NumberingType::NUMBER_LOWER_ZH
, nullptr, LANG_CJK
},
954 {style::NumberingType::NUMBER_UPPER_ZH
, nullptr, LANG_CJK
},
955 {style::NumberingType::NUMBER_UPPER_ZH_TW
, nullptr, LANG_CJK
},
956 {style::NumberingType::TIAN_GAN_ZH
, nullptr, LANG_CJK
},
957 {style::NumberingType::DI_ZI_ZH
, nullptr, LANG_CJK
},
958 {style::NumberingType::NUMBER_TRADITIONAL_JA
, nullptr, LANG_CJK
},
959 {style::NumberingType::AIU_FULLWIDTH_JA
, nullptr, LANG_CJK
},
960 {style::NumberingType::AIU_HALFWIDTH_JA
, nullptr, LANG_CJK
},
961 {style::NumberingType::IROHA_FULLWIDTH_JA
, nullptr, LANG_CJK
},
962 {style::NumberingType::IROHA_HALFWIDTH_JA
, nullptr, LANG_CJK
},
963 {style::NumberingType::NUMBER_UPPER_KO
, nullptr, LANG_CJK
},
964 {style::NumberingType::NUMBER_HANGUL_KO
, nullptr, LANG_CJK
},
965 {style::NumberingType::HANGUL_JAMO_KO
, nullptr, LANG_CJK
},
966 {style::NumberingType::HANGUL_SYLLABLE_KO
, nullptr, LANG_CJK
},
967 {style::NumberingType::HANGUL_CIRCLED_JAMO_KO
, nullptr, LANG_CJK
},
968 {style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO
, nullptr, LANG_CJK
},
969 {style::NumberingType::CHARS_ARABIC
, nullptr, LANG_CTL
},
970 {style::NumberingType::CHARS_ARABIC_ABJAD
, nullptr, LANG_CTL
},
971 {style::NumberingType::NUMBER_ARABIC_INDIC
, S_AR_ONE
", " S_AR_TWO
", " S_AR_THREE
", ...", LANG_CTL
},
972 {style::NumberingType::NUMBER_EAST_ARABIC_INDIC
, S_FA_ONE
", " S_FA_TWO
", " S_FA_THREE
", ...", LANG_CTL
},
973 {style::NumberingType::NUMBER_INDIC_DEVANAGARI
, S_HI_ONE
", " S_HI_TWO
", " S_HI_THREE
", ...", LANG_CTL
},
974 {style::NumberingType::CHARS_THAI
, nullptr, LANG_CTL
},
975 {style::NumberingType::CHARS_HEBREW
, nullptr, LANG_CTL
},
976 {style::NumberingType::NUMBER_HEBREW
, S_HE_ALEPH
", " S_HE_YOD
", " S_HE_QOF
", ...", LANG_CTL
},
977 {style::NumberingType::CHARS_NEPALI
, nullptr, LANG_CTL
},
978 {style::NumberingType::CHARS_KHMER
, nullptr, LANG_CTL
},
979 {style::NumberingType::CHARS_LAO
, nullptr, LANG_CTL
},
980 {style::NumberingType::CHARS_MYANMAR
, nullptr, LANG_CTL
},
981 {style::NumberingType::CHARS_TIBETAN
, nullptr, LANG_CTL
},
982 {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
},
983 {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
},
984 {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
},
985 {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
},
986 {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
},
987 {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
},
988 {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
},
989 {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
},
990 {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
},
991 {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
},
992 {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
},
993 {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
},
994 {style::NumberingType::CHARS_PERSIAN
, nullptr, LANG_CTL
},
995 {style::NumberingType::CHARS_PERSIAN_WORD
, nullptr, LANG_CTL
},
996 {style::NumberingType::CHARS_GREEK_UPPER_LETTER
, C_GR_A
", " C_GR_B
", ... (gr)", LANG_ALL
},
997 {style::NumberingType::CHARS_GREEK_LOWER_LETTER
, S_GR_A
", " S_GR_B
", ... (gr)", LANG_ALL
},
999 static const sal_Int32 nSupported_NumberingTypes
= SAL_N_ELEMENTS(aSupportedTypes
);
1001 OUString
DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index
)
1003 if (index
< 0 || index
>= nSupported_NumberingTypes
)
1004 throw RuntimeException();
1006 if (aSupportedTypes
[index
].cSymbol
)
1007 return OUString(aSupportedTypes
[index
].cSymbol
, strlen(aSupportedTypes
[index
].cSymbol
), RTL_TEXTENCODING_UTF8
);
1009 OUStringBuffer result
;
1010 Locale
aLocale("en", OUString(), OUString());
1011 Sequence
<beans::PropertyValue
> aProperties(2);
1012 aProperties
[0].Name
= "NumberingType";
1013 aProperties
[0].Value
<<= aSupportedTypes
[index
].nType
;
1014 aProperties
[1].Name
= "Value";
1015 for (sal_Int32 j
= 1; j
<= 3; j
++) {
1016 aProperties
[1].Value
<<= j
;
1017 result
.append( makeNumberingString( aProperties
, aLocale
) );
1018 result
.append(", ");
1020 result
.append("...");
1021 return result
.makeStringAndClear();
1026 DefaultNumberingProvider::isScriptFlagEnabled(const OUString
& aName
)
1028 if (! xHierarchicalNameAccess
.is()) {
1029 Reference
< XMultiServiceFactory
> xConfigProvider
=
1030 configuration::theDefaultProvider::get(m_xContext
);
1032 if (! xConfigProvider
.is())
1033 throw RuntimeException();
1035 uno::Sequence
<uno::Any
> aArgs(comphelper::InitAnyPropertySequence(
1037 {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/I18N"))}
1040 Reference
<XInterface
> xInterface
= xConfigProvider
->createInstanceWithArguments(
1041 "com.sun.star.configuration.ConfigurationAccess", aArgs
);
1043 xHierarchicalNameAccess
.set(xInterface
, UNO_QUERY_THROW
);
1046 Any aEnabled
= xHierarchicalNameAccess
->getByHierarchicalName(aName
);
1048 bool enabled
= false;
1050 aEnabled
>>= enabled
;
1055 Sequence
< sal_Int16
> DefaultNumberingProvider::getSupportedNumberingTypes( )
1057 Sequence
< sal_Int16
> aRet(nSupported_NumberingTypes
);
1058 sal_Int16
* pArray
= aRet
.getArray();
1060 bool cjkEnabled
= isScriptFlagEnabled("CJK/CJKFont");
1061 bool ctlEnabled
= isScriptFlagEnabled("CTL/CTLFont");
1063 for(sal_Int16 i
= 0; i
< nSupported_NumberingTypes
; i
++) {
1064 if ( (aSupportedTypes
[i
].langOption
& LANG_ALL
) ||
1065 ((aSupportedTypes
[i
].langOption
& LANG_CJK
) && cjkEnabled
) ||
1066 ((aSupportedTypes
[i
].langOption
& LANG_CTL
) && ctlEnabled
) )
1067 pArray
[i
] = aSupportedTypes
[i
].nType
;
1072 sal_Int16
DefaultNumberingProvider::getNumberingType( const OUString
& rNumberingIdentifier
)
1074 for(sal_Int16 i
= 0; i
< nSupported_NumberingTypes
; i
++)
1075 if(rNumberingIdentifier
== makeNumberingIdentifier(i
))
1076 return aSupportedTypes
[i
].nType
;
1077 throw RuntimeException();
1080 sal_Bool
DefaultNumberingProvider::hasNumberingType( const OUString
& rNumberingIdentifier
)
1082 for(sal_Int16 i
= 0; i
< nSupported_NumberingTypes
; i
++)
1083 if(rNumberingIdentifier
== makeNumberingIdentifier(i
))
1088 OUString
DefaultNumberingProvider::getNumberingIdentifier( sal_Int16 nNumberingType
)
1090 for(sal_Int16 i
= 0; i
< nSupported_NumberingTypes
; i
++)
1091 if(nNumberingType
== aSupportedTypes
[i
].nType
)
1092 return makeNumberingIdentifier(i
);
1096 OUString
DefaultNumberingProvider::getImplementationName()
1098 return OUString("com.sun.star.text.DefaultNumberingProvider");
1101 sal_Bool
DefaultNumberingProvider::supportsService(const OUString
& rServiceName
)
1103 return cppu::supportsService(this, rServiceName
);
1106 Sequence
< OUString
> DefaultNumberingProvider::getSupportedServiceNames()
1108 Sequence
< OUString
> aRet
{ "com.sun.star.text.DefaultNumberingProvider" };
1114 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1115 com_sun_star_text_DefaultNumberingProvider_get_implementation(
1116 css::uno::XComponentContext
*context
,
1117 css::uno::Sequence
<css::uno::Any
> const &)
1119 return cppu::acquire(new i18npool::DefaultNumberingProvider(context
));
1122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */