1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_i18npool.hxx"
30*cdf0e10cSrcweir #include <defaultnumberingprovider.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/style/NumberingType.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
34*cdf0e10cSrcweir #include <localedata.hxx>
35*cdf0e10cSrcweir #include <nativenumbersupplier.hxx>
36*cdf0e10cSrcweir #include <stdio.h>
37*cdf0e10cSrcweir #include <string.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir // Cyrillic upper case
40*cdf0e10cSrcweir #define C_CYR_A "\xD0\x90"
41*cdf0e10cSrcweir #define C_CYR_B "\xD0\x91"
42*cdf0e10cSrcweir // Cyrillic lower case
43*cdf0e10cSrcweir #define S_CYR_A "\xD0\xB0"
44*cdf0e10cSrcweir #define S_CYR_B "\xD0\xB1"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <math.h>
47*cdf0e10cSrcweir #include <rtl/ustring.hxx>
48*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
49*cdf0e10cSrcweir #include <com/sun/star/i18n/XTransliteration.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/i18n/TransliterationType.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/i18n/TransliterationModulesNew.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/i18n/XLocaleData.hpp>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include <bullet.h>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using namespace com::sun::star;
57*cdf0e10cSrcweir using namespace com::sun::star::uno;
58*cdf0e10cSrcweir using namespace com::sun::star::lang;
59*cdf0e10cSrcweir using namespace ::rtl;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir static sal_Unicode table_Alphabet_ar[] = {
64*cdf0e10cSrcweir 	0x0623, 0x0628, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E,
65*cdf0e10cSrcweir 	0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635,
66*cdf0e10cSrcweir 	0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x0642,
67*cdf0e10cSrcweir 	0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649
68*cdf0e10cSrcweir };
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir static sal_Unicode table_Alphabet_th[] = {
71*cdf0e10cSrcweir 	0x0E01, 0x0E02, 0x0E04, 0x0E07,
72*cdf0e10cSrcweir 	0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
73*cdf0e10cSrcweir 	0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
74*cdf0e10cSrcweir 	0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
75*cdf0e10cSrcweir 	0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
76*cdf0e10cSrcweir 	0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir static sal_Unicode table_Alphabet_he[] = {
80*cdf0e10cSrcweir 	0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
81*cdf0e10cSrcweir 	0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0, 0x05E1, 0x05E2,
82*cdf0e10cSrcweir 	0x05E4, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir static sal_Unicode table_Alphabet_ne[] = {
86*cdf0e10cSrcweir     0x0915, 0x0916, 0x0917, 0x0918, 0x0919, 0x091A, 0x091B, 0x091C,
87*cdf0e10cSrcweir     0x091D, 0x091E, 0x091F, 0x0920, 0x0921, 0x0922, 0x0923, 0x0924,
88*cdf0e10cSrcweir     0x0925, 0x0926, 0x0927, 0x0928, 0x092A, 0x092B, 0x092C, 0x092D,
89*cdf0e10cSrcweir     0x092E, 0x092F, 0x0930, 0x0932, 0x0935, 0x0936, 0x0937, 0x0938,
90*cdf0e10cSrcweir     0x0939
91*cdf0e10cSrcweir };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir static sal_Unicode table_Alphabet_km[] = {
94*cdf0e10cSrcweir 	0x1780, 0x1781, 0x1782, 0x1783, 0x1784, 0x1785, 0x1786, 0x1787,
95*cdf0e10cSrcweir 	0x1788, 0x1789, 0x178A, 0x178B, 0x178C, 0x178D, 0x178E, 0x178F,
96*cdf0e10cSrcweir 	0x1790, 0x1791, 0x1792, 0x1793, 0x1794, 0x1795, 0x1796, 0x1797,
97*cdf0e10cSrcweir 	0x1798, 0x1799, 0x179A, 0x179B, 0x179C, 0x179F,
98*cdf0e10cSrcweir 	0x17A0, 0x17A1, 0x17A2
99*cdf0e10cSrcweir };
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir static sal_Unicode table_Alphabet_lo[] = {
102*cdf0e10cSrcweir     0x0E81, 0x0E82, 0x0E84, 0x0E87, 0x0E88, 0x0E8A, 0x0E8D, 0x0E94,
103*cdf0e10cSrcweir     0x0E95, 0x0E96, 0x0E97, 0x0E99, 0x0E9A, 0x0E9B, 0x0E9C,
104*cdf0e10cSrcweir     0x0E9D, 0x0E9E, 0x0E9F, 0x0EA1, 0x0EA2, 0x0EA3, 0x0EA5, 0x0EA7,
105*cdf0e10cSrcweir     0x0EAA, 0x0EAB, 0x0EAD, 0x0EAE, 0x0EAF, 0x0EAE, 0x0EDC, 0x0EDD
106*cdf0e10cSrcweir };
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir static sal_Unicode table_Alphabet_dz[] = {
109*cdf0e10cSrcweir     0x0F40, 0x0F41, 0x0F42, 0x0F44, 0x0F45, 0x0F46, 0x0F47, 0x0F49,
110*cdf0e10cSrcweir     0x0F4F, 0x0F50, 0x0F51, 0x0F53, 0x0F54, 0x0F55, 0x0F56, 0x0F58,
111*cdf0e10cSrcweir     0x0F59, 0x0F5A, 0x0F5B, 0x0F5D, 0x0F5E, 0x0F5F, 0x0F60, 0x0F61,
112*cdf0e10cSrcweir     0x0F62, 0x0F63, 0x0F64, 0x0F66, 0x0F67, 0x0F68
113*cdf0e10cSrcweir };
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir static sal_Unicode table_Alphabet_my[] = {
116*cdf0e10cSrcweir     0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007,
117*cdf0e10cSrcweir     0x1008,/*0x1009,*/0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F,
118*cdf0e10cSrcweir     0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017,
119*cdf0e10cSrcweir     0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F,
120*cdf0e10cSrcweir     0x1020, 0x1021
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir // Bulgarian Cyrillic upper case letters
124*cdf0e10cSrcweir static sal_Unicode table_CyrillicUpperLetter_bg[] = {
125*cdf0e10cSrcweir     0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418,
126*cdf0e10cSrcweir     0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422,
127*cdf0e10cSrcweir     0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042E,
128*cdf0e10cSrcweir     0x042F
129*cdf0e10cSrcweir };
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir // Bulgarian cyrillic lower case letters
132*cdf0e10cSrcweir static sal_Unicode table_CyrillicLowerLetter_bg[] = {
133*cdf0e10cSrcweir     0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438,
134*cdf0e10cSrcweir     0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442,
135*cdf0e10cSrcweir     0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044E,
136*cdf0e10cSrcweir     0x044F
137*cdf0e10cSrcweir };
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir // Russian Cyrillic upper letters
140*cdf0e10cSrcweir static sal_Unicode table_CyrillicUpperLetter_ru[] = {
141*cdf0e10cSrcweir     0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
142*cdf0e10cSrcweir     0x0418, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420,
143*cdf0e10cSrcweir     0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
144*cdf0e10cSrcweir     0x0429, 0x042B, 0x042D, 0x042E, 0x042F
145*cdf0e10cSrcweir };
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir // Russian cyrillic lower letters
148*cdf0e10cSrcweir static sal_Unicode table_CyrillicLowerLetter_ru[] = {
149*cdf0e10cSrcweir     0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
150*cdf0e10cSrcweir     0x0438, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440,
151*cdf0e10cSrcweir     0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448,
152*cdf0e10cSrcweir     0x0449, 0x044B, 0x044D, 0x044E, 0x044F
153*cdf0e10cSrcweir };
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir // Serbian Cyrillic upper letters
156*cdf0e10cSrcweir static sal_Unicode table_CyrillicUpperLetter_sr[] = {
157*cdf0e10cSrcweir     0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0402, 0x0415, 0x0416,
158*cdf0e10cSrcweir     0x0417, 0x0418, 0x0408, 0x041A, 0x041B, 0x0409, 0x041C, 0x041D,
159*cdf0e10cSrcweir     0x040A, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x040B, 0x0423,
160*cdf0e10cSrcweir     0x0424, 0x0425, 0x0426, 0x0427, 0x040F, 0x0428
161*cdf0e10cSrcweir };
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir // Serbian cyrillic lower letters
164*cdf0e10cSrcweir static sal_Unicode table_CyrillicLowerLetter_sr[] = {
165*cdf0e10cSrcweir     0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0452, 0x0435, 0x0436,
166*cdf0e10cSrcweir     0x0437, 0x0438, 0x0458, 0x043A, 0x043B, 0x0459, 0x043C, 0x043D,
167*cdf0e10cSrcweir     0x045A, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x045B, 0x0443,
168*cdf0e10cSrcweir     0x0444, 0x0445, 0x0446, 0x0447, 0x045F, 0x0448
169*cdf0e10cSrcweir };
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir static sal_Unicode table_Alphabet_fa[] = {
172*cdf0e10cSrcweir     0x0622, 0x0628, 0x067E, 0x062A, 0x062B, 0x062C, 0x0686, 0x062D,
173*cdf0e10cSrcweir     0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0698, 0x0633, 0x0634,
174*cdf0e10cSrcweir     0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x0640, 0x0641, 0x0642,
175*cdf0e10cSrcweir     0x06A9, 0x06AF, 0x0644, 0x0645, 0x0646, 0x0648, 0x0647, 0x06CC
176*cdf0e10cSrcweir };
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir static sal_Unicode upperLetter[] = {
179*cdf0e10cSrcweir     0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
180*cdf0e10cSrcweir     0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
181*cdf0e10cSrcweir     0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
182*cdf0e10cSrcweir };
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir static sal_Unicode lowerLetter[] = {
185*cdf0e10cSrcweir     0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
186*cdf0e10cSrcweir     0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
187*cdf0e10cSrcweir     0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
188*cdf0e10cSrcweir };
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XMultiServiceFactory >& xMSF ) : xSMgr(xMSF),translit(NULL)
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir DefaultNumberingProvider::~DefaultNumberingProvider()
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir         delete translit;
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir void DefaultNumberingProvider::impl_loadTranslit()
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     if ( !translit )
203*cdf0e10cSrcweir         translit = new TransliterationImpl(xSMgr);
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir Sequence< Reference<container::XIndexAccess> >
207*cdf0e10cSrcweir DefaultNumberingProvider::getDefaultOutlineNumberings(const Locale& rLocale ) throw(RuntimeException)
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir      return LocaleData().getOutlineNumberingLevels( rLocale );
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir Sequence< Sequence<beans::PropertyValue> >
213*cdf0e10cSrcweir DefaultNumberingProvider::getDefaultContinuousNumberingLevels( const Locale& rLocale ) throw(RuntimeException)
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir      return LocaleData().getContinuousNumberingLevels( rLocale );
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir OUString toRoman( sal_Int32 n )
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir //              i, ii, iii, iv, v, vi, vii, vii, viii, ix
222*cdf0e10cSrcweir //                                                      (Dummy),1000,500,100,50,10,5,1
223*cdf0e10cSrcweir         static const sal_Char coRomanArr[] = "MDCLXVI--";       // +2 Dummy entries !!
224*cdf0e10cSrcweir         const sal_Char* cRomanStr = coRomanArr;
225*cdf0e10cSrcweir         sal_uInt16 nMask = 1000;
226*cdf0e10cSrcweir         sal_uInt32 nOver1000 = n / nMask;
227*cdf0e10cSrcweir         n -= ( nOver1000 * nMask );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir         OUStringBuffer sTmp;
230*cdf0e10cSrcweir     while(nOver1000--)
231*cdf0e10cSrcweir         sTmp.append(sal_Unicode(*coRomanArr));
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir         while( nMask )
234*cdf0e10cSrcweir         {
235*cdf0e10cSrcweir                 sal_uInt8 nZahl = sal_uInt8( n / nMask );
236*cdf0e10cSrcweir                 sal_uInt8 nDiff = 1;
237*cdf0e10cSrcweir                 n %= nMask;
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir                 if( 5 < nZahl )
240*cdf0e10cSrcweir                 {
241*cdf0e10cSrcweir                         if( nZahl < 9 )
242*cdf0e10cSrcweir                                 sTmp.append(sal_Unicode(*(cRomanStr-1)));
243*cdf0e10cSrcweir                         ++nDiff;
244*cdf0e10cSrcweir                         nZahl -= 5;
245*cdf0e10cSrcweir                 }
246*cdf0e10cSrcweir                 switch( nZahl )
247*cdf0e10cSrcweir                 {
248*cdf0e10cSrcweir                 case 3: sTmp.append(sal_Unicode(*cRomanStr));           //no break!
249*cdf0e10cSrcweir                 case 2: sTmp.append(sal_Unicode(*cRomanStr));           //no break!
250*cdf0e10cSrcweir                 case 1: sTmp.append(sal_Unicode(*cRomanStr));           break;
251*cdf0e10cSrcweir                 case 4: sTmp.append(sal_Unicode(*cRomanStr)).append(sal_Unicode(*(cRomanStr-nDiff))); break;
252*cdf0e10cSrcweir                 case 5: sTmp.append(sal_Unicode(*(cRomanStr-nDiff)));   break;
253*cdf0e10cSrcweir                 }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir                 nMask /= 10;                    // to the next decade
256*cdf0e10cSrcweir                 cRomanStr += 2;
257*cdf0e10cSrcweir         }
258*cdf0e10cSrcweir         return sTmp.makeStringAndClear();
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir // not used:
262*cdf0e10cSrcweir #if 0
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir static
265*cdf0e10cSrcweir const char* expected_name( int i, int last )
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir      if(0);
268*cdf0e10cSrcweir      else if( i==0    ) return "Prefix";
269*cdf0e10cSrcweir      else if( i==1    ) return "NumberingType";
270*cdf0e10cSrcweir      else if( i==2    ) return "Suffix";
271*cdf0e10cSrcweir      else if( i==last ) return "Value";
272*cdf0e10cSrcweir      else { OSL_ASSERT(0); return ""; }
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir static
275*cdf0e10cSrcweir const char* expected_type( int i, int last )
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir      if(0);
278*cdf0e10cSrcweir      else if( i==0    ) return "OUString";
279*cdf0e10cSrcweir      else if( i==1    ) return "sal_Int16";
280*cdf0e10cSrcweir      else if( i==2    ) return "OUString";
281*cdf0e10cSrcweir      else if( i==last ) return "sal_Int32";
282*cdf0e10cSrcweir      else { OSL_ASSERT(0); return ""; }
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir static
285*cdf0e10cSrcweir void failedToConvert( int i, int last )
286*cdf0e10cSrcweir {
287*cdf0e10cSrcweir      throw IllegalArgumentException();
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir #endif
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir static
293*cdf0e10cSrcweir void lcl_formatChars( sal_Unicode table[], int tableSize, int n, OUString& s )
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir      // string representation of n is appended to s.
296*cdf0e10cSrcweir      // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>AB, ...
297*cdf0e10cSrcweir      // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>ab, ...
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir      if( n>=tableSize ) lcl_formatChars( table, tableSize, (n-tableSize)/tableSize, s );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir      s += OUString::valueOf( table[ n % tableSize ] );
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir static
305*cdf0e10cSrcweir void lcl_formatChars1( sal_Unicode table[], int tableSize, int n, OUString& s )
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir      // string representation of n is appended to s.
308*cdf0e10cSrcweir      // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>AA, 27=>BB, ...
309*cdf0e10cSrcweir      // if A=='a' then 0=>a, 1=>b, ..., 25=>z, 26=>aa, 27=>bb, ...
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir      int repeat_count = n / tableSize + 1;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir      for( int i=0; i<repeat_count; i++ )
314*cdf0e10cSrcweir          s += OUString::valueOf( table[ n%tableSize ] );
315*cdf0e10cSrcweir }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir static
318*cdf0e10cSrcweir void lcl_formatChars2( sal_Unicode table_capital[], sal_Unicode table_small[], int tableSize, int n, OUString& s )
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir      // string representation of n is appended to s.
321*cdf0e10cSrcweir      // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Ab, ...
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir      if( n>=tableSize )
324*cdf0e10cSrcweir      {
325*cdf0e10cSrcweir           lcl_formatChars2( table_capital, table_small, tableSize, (n-tableSize)/tableSize, s );
326*cdf0e10cSrcweir           s += OUString::valueOf( table_small[ n % tableSize ] );
327*cdf0e10cSrcweir      } else
328*cdf0e10cSrcweir           s += OUString::valueOf( table_capital[ n % tableSize ] );
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir static
332*cdf0e10cSrcweir void lcl_formatChars3( sal_Unicode table_capital[], sal_Unicode table_small[], int tableSize, int n, OUString& s )
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir      // string representation of n is appended to s.
335*cdf0e10cSrcweir      // if A=='A' then 0=>A, 1=>B, ..., 25=>Z, 26=>Aa, 27=>Bb, ...
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir      int repeat_count = n / tableSize + 1;
338*cdf0e10cSrcweir      s += OUString::valueOf( table_capital[ n%tableSize ] );
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir      for( int i=1; i<repeat_count; i++ )
341*cdf0e10cSrcweir          s += OUString::valueOf( table_small[ n%tableSize ] );
342*cdf0e10cSrcweir }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir static
345*cdf0e10cSrcweir int should_ignore( OUString s )
346*cdf0e10cSrcweir {
347*cdf0e10cSrcweir         // return true if blank or null
348*cdf0e10cSrcweir         return s.compareToAscii(" ")==0 || (s.getLength()>0 && s[0]==0);
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir static
352*cdf0e10cSrcweir Any getPropertyByName( const Sequence<beans::PropertyValue>& aProperties,
353*cdf0e10cSrcweir                                                 const char* name, sal_Bool bRequired )
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir         for( int i=0; i<aProperties.getLength(); i++ )
356*cdf0e10cSrcweir                 if( aProperties[i].Name.equalsAscii(name) )
357*cdf0e10cSrcweir                         return aProperties[i].Value;
358*cdf0e10cSrcweir         if(bRequired)
359*cdf0e10cSrcweir             throw IllegalArgumentException();
360*cdf0e10cSrcweir         return Any();
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir //XNumberingFormatter
364*cdf0e10cSrcweir OUString
365*cdf0e10cSrcweir DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyValue>& aProperties,
366*cdf0e10cSrcweir                                                const Locale& aLocale )
367*cdf0e10cSrcweir      throw( IllegalArgumentException, RuntimeException )
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir      // the Sequence of PropertyValues is expected to have at least 4 elements:
370*cdf0e10cSrcweir      // elt Name              Type             purpose
371*cdf0e10cSrcweir      // -----------------------------------------------------------------
372*cdf0e10cSrcweir      //
373*cdf0e10cSrcweir      // 0.  "Prefix"          OUString
374*cdf0e10cSrcweir      // 1.  "NumberingType"   sal_Int16        type of formatting from style::NumberingType (roman, arabic, etc)
375*cdf0e10cSrcweir      // 2.  "Suffix"          OUString
376*cdf0e10cSrcweir      // ... ...               ...
377*cdf0e10cSrcweir      // n.  "Value"           sal_Int32        the number to be formatted
378*cdf0e10cSrcweir      // example:
379*cdf0e10cSrcweir      // given the Sequence { '(', NumberingType::ROMAN_UPPER, ')', ..., 7 }
380*cdf0e10cSrcweir      // makeNumberingString() returns the string "(VII)".
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir      // Q: why is the type of numType sal_Int16 instead of style::NumberingType?
383*cdf0e10cSrcweir      // A: an Any can't hold a style::NumberingType for some reason.
384*cdf0e10cSrcweir         //      add.: style::NumberingType holds constants of type sal_Int16, it's not an enum type
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir      sal_Int16 natNum = 0;
387*cdf0e10cSrcweir      sal_Int16 tableSize = 0;
388*cdf0e10cSrcweir      sal_Unicode *table = NULL;     // initialize to avoid compiler warning
389*cdf0e10cSrcweir      sal_Bool recycleSymbol = sal_False;
390*cdf0e10cSrcweir      Locale locale;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir      OUString  prefix;
393*cdf0e10cSrcweir      sal_Int16        numType = -1; // type of formatting from style::NumberingType (roman, arabic, etc)
394*cdf0e10cSrcweir      OUString  suffix;
395*cdf0e10cSrcweir      sal_Int32        number = -12345; // the number that needs to be formatted.
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir //     int nProperties = aProperties.getLength();
398*cdf0e10cSrcweir //     int last        = nProperties-1;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir      try {
401*cdf0e10cSrcweir         getPropertyByName(aProperties, "Prefix", sal_False)      >>=prefix;
402*cdf0e10cSrcweir      } catch (Exception&) {
403*cdf0e10cSrcweir         //prefix _must_ be empty here!
404*cdf0e10cSrcweir      }
405*cdf0e10cSrcweir      try {
406*cdf0e10cSrcweir         getPropertyByName(aProperties, "Suffix", sal_False)      >>=suffix;
407*cdf0e10cSrcweir      } catch (Exception&) {
408*cdf0e10cSrcweir         //suffix _must_ be empty here!
409*cdf0e10cSrcweir      }
410*cdf0e10cSrcweir      try {
411*cdf0e10cSrcweir         getPropertyByName(aProperties, "NumberingType", sal_True)   >>=numType;
412*cdf0e10cSrcweir      } catch (Exception& ) {
413*cdf0e10cSrcweir         numType = -1;
414*cdf0e10cSrcweir      }
415*cdf0e10cSrcweir      try {
416*cdf0e10cSrcweir         getPropertyByName(aProperties, "Value", sal_True)       >>=number;
417*cdf0e10cSrcweir      } catch (Exception& ) {
418*cdf0e10cSrcweir         number = -1;
419*cdf0e10cSrcweir      }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir      if( number <= 0 )
422*cdf0e10cSrcweir           throw IllegalArgumentException();
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir      // start empty
425*cdf0e10cSrcweir      OUString result;
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir       // append prefix
428*cdf0e10cSrcweir       if( !should_ignore(prefix) ) result += prefix;
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir       // append formatted number
431*cdf0e10cSrcweir       using namespace style::NumberingType;
432*cdf0e10cSrcweir       switch( numType )
433*cdf0e10cSrcweir       {
434*cdf0e10cSrcweir           case CHARS_UPPER_LETTER:
435*cdf0e10cSrcweir                lcl_formatChars( upperLetter, 26, number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>AB, ...
436*cdf0e10cSrcweir                break;
437*cdf0e10cSrcweir           case CHARS_LOWER_LETTER:
438*cdf0e10cSrcweir                lcl_formatChars( lowerLetter, 26, number-1, result );
439*cdf0e10cSrcweir                break;
440*cdf0e10cSrcweir           case ROMAN_UPPER:
441*cdf0e10cSrcweir                result += toRoman( number );
442*cdf0e10cSrcweir                break;
443*cdf0e10cSrcweir           case ROMAN_LOWER:
444*cdf0e10cSrcweir                result += toRoman( number ).toAsciiLowerCase();
445*cdf0e10cSrcweir                break;
446*cdf0e10cSrcweir           case ARABIC:
447*cdf0e10cSrcweir                result += OUString::valueOf( number );
448*cdf0e10cSrcweir                break;
449*cdf0e10cSrcweir           case NUMBER_NONE:
450*cdf0e10cSrcweir                return OUString::createFromAscii(""); // ignore prefix and suffix
451*cdf0e10cSrcweir           case CHAR_SPECIAL:
452*cdf0e10cSrcweir                // apparently, we're supposed to return an empty string in this case...
453*cdf0e10cSrcweir                return OUString::createFromAscii(""); // ignore prefix and suffix
454*cdf0e10cSrcweir           case PAGE_DESCRIPTOR:
455*cdf0e10cSrcweir           case BITMAP:
456*cdf0e10cSrcweir                OSL_ASSERT(0);
457*cdf0e10cSrcweir                throw IllegalArgumentException();
458*cdf0e10cSrcweir           case CHARS_UPPER_LETTER_N:
459*cdf0e10cSrcweir                lcl_formatChars1( upperLetter, 26, number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
460*cdf0e10cSrcweir                break;
461*cdf0e10cSrcweir           case CHARS_LOWER_LETTER_N:
462*cdf0e10cSrcweir                lcl_formatChars1( lowerLetter, 26,  number-1, result ); // 1=>A, 2=>B, ..., 26=>Z, 27=>AA, 28=>BB, ...
463*cdf0e10cSrcweir                break;
464*cdf0e10cSrcweir           case TRANSLITERATION:
465*cdf0e10cSrcweir                try {
466*cdf0e10cSrcweir                     const OUString &tmp = OUString::valueOf( number );
467*cdf0e10cSrcweir                     OUString transliteration;
468*cdf0e10cSrcweir                     getPropertyByName(aProperties, "Transliteration", sal_True) >>= transliteration;
469*cdf0e10cSrcweir                     impl_loadTranslit();
470*cdf0e10cSrcweir                     translit->loadModuleByImplName(transliteration, aLocale);
471*cdf0e10cSrcweir                     result += translit->transliterateString2String(tmp, 0, tmp.getLength());
472*cdf0e10cSrcweir                } catch (Exception& ) {
473*cdf0e10cSrcweir                     // When translteration property is missing, return default number (bug #101141#)
474*cdf0e10cSrcweir                     result += OUString::valueOf( number );
475*cdf0e10cSrcweir                     // OSL_ASSERT(0);
476*cdf0e10cSrcweir                     // throw IllegalArgumentException();
477*cdf0e10cSrcweir                }
478*cdf0e10cSrcweir                break;
479*cdf0e10cSrcweir           case NATIVE_NUMBERING:
480*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM1;
481*cdf0e10cSrcweir                 locale = aLocale;
482*cdf0e10cSrcweir                 break;
483*cdf0e10cSrcweir           case FULLWIDTH_ARABIC:
484*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM3;
485*cdf0e10cSrcweir                 locale = aLocale;
486*cdf0e10cSrcweir                 break;
487*cdf0e10cSrcweir           case NUMBER_LOWER_ZH:
488*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM7;
489*cdf0e10cSrcweir                 locale.Language = OUString::createFromAscii("zh");
490*cdf0e10cSrcweir                 break;
491*cdf0e10cSrcweir           case NUMBER_UPPER_ZH_TW:
492*cdf0e10cSrcweir                 locale.Country = OUString::createFromAscii("TW");
493*cdf0e10cSrcweir           case NUMBER_UPPER_ZH:
494*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM8;
495*cdf0e10cSrcweir                 locale.Language = OUString::createFromAscii("zh");
496*cdf0e10cSrcweir                 break;
497*cdf0e10cSrcweir           case NUMBER_TRADITIONAL_JA:
498*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM8;
499*cdf0e10cSrcweir                 locale.Language = OUString::createFromAscii("ja");
500*cdf0e10cSrcweir                 break;
501*cdf0e10cSrcweir           case NUMBER_UPPER_KO:
502*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM8;
503*cdf0e10cSrcweir                 locale.Language = OUString::createFromAscii("ko");
504*cdf0e10cSrcweir                 break;
505*cdf0e10cSrcweir           case NUMBER_HANGUL_KO:
506*cdf0e10cSrcweir                 natNum = NativeNumberMode::NATNUM11;
507*cdf0e10cSrcweir                 locale.Language = OUString::createFromAscii("ko");
508*cdf0e10cSrcweir                 break;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir           case CIRCLE_NUMBER:
511*cdf0e10cSrcweir               table = table_CircledNumber;
512*cdf0e10cSrcweir               tableSize = sizeof(table_CircledNumber) / sizeof(sal_Unicode);
513*cdf0e10cSrcweir               break;
514*cdf0e10cSrcweir           case TIAN_GAN_ZH:
515*cdf0e10cSrcweir               table = table_TianGan_zh;
516*cdf0e10cSrcweir               tableSize = sizeof(table_TianGan_zh) / sizeof(sal_Unicode);
517*cdf0e10cSrcweir               break;
518*cdf0e10cSrcweir           case DI_ZI_ZH:
519*cdf0e10cSrcweir               table = table_DiZi_zh;
520*cdf0e10cSrcweir               tableSize = sizeof(table_DiZi_zh) / sizeof(sal_Unicode);
521*cdf0e10cSrcweir               break;
522*cdf0e10cSrcweir           case AIU_FULLWIDTH_JA:
523*cdf0e10cSrcweir               table = table_AIUFullWidth_ja_JP;
524*cdf0e10cSrcweir               tableSize = sizeof(table_AIUFullWidth_ja_JP) / sizeof(sal_Unicode);
525*cdf0e10cSrcweir               recycleSymbol = sal_True;
526*cdf0e10cSrcweir               break;
527*cdf0e10cSrcweir           case AIU_HALFWIDTH_JA:
528*cdf0e10cSrcweir               table = table_AIUHalfWidth_ja_JP;
529*cdf0e10cSrcweir               tableSize = sizeof(table_AIUHalfWidth_ja_JP) / sizeof(sal_Unicode);
530*cdf0e10cSrcweir               recycleSymbol = sal_True;
531*cdf0e10cSrcweir               break;
532*cdf0e10cSrcweir           case IROHA_FULLWIDTH_JA:
533*cdf0e10cSrcweir               table = table_IROHAFullWidth_ja_JP;
534*cdf0e10cSrcweir               tableSize = sizeof(table_IROHAFullWidth_ja_JP) / sizeof(sal_Unicode);
535*cdf0e10cSrcweir               recycleSymbol = sal_True;
536*cdf0e10cSrcweir               break;
537*cdf0e10cSrcweir           case IROHA_HALFWIDTH_JA:
538*cdf0e10cSrcweir               table = table_IROHAHalfWidth_ja_JP;
539*cdf0e10cSrcweir               tableSize = sizeof(table_IROHAHalfWidth_ja_JP) / sizeof(sal_Unicode);
540*cdf0e10cSrcweir               recycleSymbol = sal_True;
541*cdf0e10cSrcweir               break;
542*cdf0e10cSrcweir           case HANGUL_JAMO_KO:
543*cdf0e10cSrcweir               table = table_HangulJamo_ko;
544*cdf0e10cSrcweir               tableSize = sizeof(table_HangulJamo_ko) / sizeof(sal_Unicode);
545*cdf0e10cSrcweir               recycleSymbol = sal_True;
546*cdf0e10cSrcweir               break;
547*cdf0e10cSrcweir           case HANGUL_SYLLABLE_KO:
548*cdf0e10cSrcweir               table = table_HangulSyllable_ko;
549*cdf0e10cSrcweir               tableSize = sizeof(table_HangulSyllable_ko) / sizeof(sal_Unicode);
550*cdf0e10cSrcweir               recycleSymbol = sal_True;
551*cdf0e10cSrcweir               break;
552*cdf0e10cSrcweir           case HANGUL_CIRCLED_JAMO_KO:
553*cdf0e10cSrcweir               table = table_HangulCircledJamo_ko;
554*cdf0e10cSrcweir               tableSize = sizeof(table_HangulCircledJamo_ko) / sizeof(sal_Unicode);
555*cdf0e10cSrcweir               recycleSymbol = sal_True;
556*cdf0e10cSrcweir               break;
557*cdf0e10cSrcweir           case HANGUL_CIRCLED_SYLLABLE_KO:
558*cdf0e10cSrcweir               table = table_HangulCircledSyllable_ko;
559*cdf0e10cSrcweir               tableSize = sizeof(table_HangulCircledSyllable_ko) / sizeof(sal_Unicode);
560*cdf0e10cSrcweir               recycleSymbol = sal_True;
561*cdf0e10cSrcweir               break;
562*cdf0e10cSrcweir           case CHARS_ARABIC:
563*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_ar, sizeof(table_Alphabet_ar) / sizeof(sal_Unicode), number - 1, result);
564*cdf0e10cSrcweir               break;
565*cdf0e10cSrcweir           case CHARS_THAI:
566*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_th, sizeof(table_Alphabet_th) / sizeof(sal_Unicode), number - 1, result);
567*cdf0e10cSrcweir               break;
568*cdf0e10cSrcweir           case CHARS_HEBREW:
569*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_he, sizeof(table_Alphabet_he) / sizeof(sal_Unicode), number - 1, result);
570*cdf0e10cSrcweir               break;
571*cdf0e10cSrcweir           case CHARS_NEPALI:
572*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_ne, sizeof(table_Alphabet_ne) / sizeof(sal_Unicode), number - 1, result);
573*cdf0e10cSrcweir               break;
574*cdf0e10cSrcweir           case CHARS_KHMER:
575*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_km, sizeof(table_Alphabet_km) / sizeof(sal_Unicode), number - 1, result);
576*cdf0e10cSrcweir               break;
577*cdf0e10cSrcweir           case CHARS_LAO:
578*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_lo, sizeof(table_Alphabet_lo) / sizeof(sal_Unicode), number - 1, result);
579*cdf0e10cSrcweir               break;
580*cdf0e10cSrcweir           case CHARS_MYANMAR:
581*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_my, sizeof(table_Alphabet_my) / sizeof(sal_Unicode), number - 1, result);
582*cdf0e10cSrcweir               break;
583*cdf0e10cSrcweir          case CHARS_TIBETAN:
584*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_dz, sizeof(table_Alphabet_dz) / sizeof(sal_Unicode), number - 1, result);
585*cdf0e10cSrcweir               break;
586*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_BG:
587*cdf0e10cSrcweir               lcl_formatChars2( table_CyrillicUpperLetter_bg,
588*cdf0e10cSrcweir                       table_CyrillicLowerLetter_bg,
589*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg) /
590*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg[0]), number-1,
591*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Ab, ...
592*cdf0e10cSrcweir               break;
593*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_BG:
594*cdf0e10cSrcweir               lcl_formatChars( table_CyrillicLowerLetter_bg,
595*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg) /
596*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg[0]), number-1,
597*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>ab, ...
598*cdf0e10cSrcweir               break;
599*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_N_BG:
600*cdf0e10cSrcweir               lcl_formatChars3( table_CyrillicUpperLetter_bg,
601*cdf0e10cSrcweir                       table_CyrillicLowerLetter_bg,
602*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg) /
603*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg[0]), number-1,
604*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 28=>z, 29=>Aa, 30=>Bb, ...
605*cdf0e10cSrcweir               break;
606*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_N_BG:
607*cdf0e10cSrcweir               lcl_formatChars1( table_CyrillicLowerLetter_bg,
608*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg) /
609*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_bg[0]), number-1,
610*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 28=>z, 29=>aa, 30=>bb, ...
611*cdf0e10cSrcweir               break;
612*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_RU:
613*cdf0e10cSrcweir               lcl_formatChars2( table_CyrillicUpperLetter_ru,
614*cdf0e10cSrcweir                       table_CyrillicLowerLetter_ru,
615*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru) /
616*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru[0]), number-1,
617*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
618*cdf0e10cSrcweir               break;
619*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_RU:
620*cdf0e10cSrcweir               lcl_formatChars( table_CyrillicLowerLetter_ru,
621*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru) /
622*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru[0]), number-1,
623*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
624*cdf0e10cSrcweir               break;
625*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_N_RU:
626*cdf0e10cSrcweir               lcl_formatChars3( table_CyrillicUpperLetter_ru,
627*cdf0e10cSrcweir                       table_CyrillicLowerLetter_ru,
628*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru) /
629*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru[0]), number-1,
630*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
631*cdf0e10cSrcweir               break;
632*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_N_RU:
633*cdf0e10cSrcweir               lcl_formatChars1( table_CyrillicLowerLetter_ru,
634*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru) /
635*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_ru[0]), number-1,
636*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
637*cdf0e10cSrcweir               break;
638*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_SR:
639*cdf0e10cSrcweir               lcl_formatChars2( table_CyrillicUpperLetter_sr,
640*cdf0e10cSrcweir                       table_CyrillicLowerLetter_sr,
641*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr) /
642*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr[0]), number-1,
643*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Ab, ...
644*cdf0e10cSrcweir               break;
645*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_SR:
646*cdf0e10cSrcweir               lcl_formatChars( table_CyrillicLowerLetter_sr,
647*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr) /
648*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr[0]), number-1,
649*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>ab, ...
650*cdf0e10cSrcweir               break;
651*cdf0e10cSrcweir          case CHARS_CYRILLIC_UPPER_LETTER_N_SR:
652*cdf0e10cSrcweir               lcl_formatChars3( table_CyrillicUpperLetter_sr,
653*cdf0e10cSrcweir                       table_CyrillicLowerLetter_sr,
654*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr) /
655*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr[0]), number-1,
656*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>Aa, 29=>Bb, ...
657*cdf0e10cSrcweir               break;
658*cdf0e10cSrcweir          case CHARS_CYRILLIC_LOWER_LETTER_N_SR:
659*cdf0e10cSrcweir               lcl_formatChars1( table_CyrillicLowerLetter_sr,
660*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr) /
661*cdf0e10cSrcweir                       sizeof(table_CyrillicLowerLetter_sr[0]), number-1,
662*cdf0e10cSrcweir                       result); // 1=>a, 2=>b, ..., 27=>z, 28=>aa, 29=>bb, ...
663*cdf0e10cSrcweir               break;
664*cdf0e10cSrcweir           case CHARS_PERSIAN:
665*cdf0e10cSrcweir               lcl_formatChars(table_Alphabet_fa, sizeof(table_Alphabet_fa) / sizeof(sal_Unicode), number - 1, result);
666*cdf0e10cSrcweir               break;
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir           default:
669*cdf0e10cSrcweir                OSL_ASSERT(0);
670*cdf0e10cSrcweir                throw IllegalArgumentException();
671*cdf0e10cSrcweir       }
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir         if (natNum) {
674*cdf0e10cSrcweir             NativeNumberSupplier sNatNum;
675*cdf0e10cSrcweir             result += sNatNum.getNativeNumberString(OUString::valueOf( number ), locale, natNum);
676*cdf0e10cSrcweir         } else if (tableSize) {
677*cdf0e10cSrcweir             if ( number > tableSize && !recycleSymbol)
678*cdf0e10cSrcweir                 result += OUString::valueOf( number);
679*cdf0e10cSrcweir             else
680*cdf0e10cSrcweir                 result += OUString(&table[--number % tableSize], 1);
681*cdf0e10cSrcweir         }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir         // append suffix
684*cdf0e10cSrcweir         if( !should_ignore(suffix) ) result += suffix;
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir         return result;
687*cdf0e10cSrcweir }
688*cdf0e10cSrcweir /* -----------------------------21.02.01 15:57--------------------------------
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir #define LANG_ALL        (1 << 0)
693*cdf0e10cSrcweir #define LANG_CJK        (1 << 1)
694*cdf0e10cSrcweir #define LANG_CTL        (1 << 2)
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir struct Supported_NumberingType
697*cdf0e10cSrcweir {
698*cdf0e10cSrcweir         sal_Int16               nType;
699*cdf0e10cSrcweir         const sal_Char* cSymbol;
700*cdf0e10cSrcweir         sal_Int16               langOption;
701*cdf0e10cSrcweir };
702*cdf0e10cSrcweir static const Supported_NumberingType aSupportedTypes[] =
703*cdf0e10cSrcweir {
704*cdf0e10cSrcweir         {style::NumberingType::CHARS_UPPER_LETTER,      "A", LANG_ALL},
705*cdf0e10cSrcweir         {style::NumberingType::CHARS_LOWER_LETTER,      "a", LANG_ALL},
706*cdf0e10cSrcweir         {style::NumberingType::ROMAN_UPPER,                     "I", LANG_ALL},
707*cdf0e10cSrcweir         {style::NumberingType::ROMAN_LOWER,                     "i", LANG_ALL},
708*cdf0e10cSrcweir         {style::NumberingType::ARABIC,                          "1", LANG_ALL},
709*cdf0e10cSrcweir         {style::NumberingType::NUMBER_NONE,                     "''", LANG_ALL},
710*cdf0e10cSrcweir         {style::NumberingType::CHAR_SPECIAL,                    "Bullet", LANG_ALL},
711*cdf0e10cSrcweir         {style::NumberingType::PAGE_DESCRIPTOR,                 "Page", LANG_ALL},
712*cdf0e10cSrcweir         {style::NumberingType::BITMAP,                          "Bitmap", LANG_ALL},
713*cdf0e10cSrcweir         {style::NumberingType::CHARS_UPPER_LETTER_N,    "AAA", LANG_ALL},
714*cdf0e10cSrcweir         {style::NumberingType::CHARS_LOWER_LETTER_N,    "aaa", LANG_ALL},
715*cdf0e10cSrcweir         {style::NumberingType::NATIVE_NUMBERING,        "Native Numbering", LANG_CJK|LANG_CTL},
716*cdf0e10cSrcweir         {style::NumberingType::FULLWIDTH_ARABIC,        NULL, LANG_CJK},
717*cdf0e10cSrcweir         {style::NumberingType::CIRCLE_NUMBER,           NULL, LANG_CJK},
718*cdf0e10cSrcweir         {style::NumberingType::NUMBER_LOWER_ZH,         NULL, LANG_CJK},
719*cdf0e10cSrcweir         {style::NumberingType::NUMBER_UPPER_ZH,         NULL, LANG_CJK},
720*cdf0e10cSrcweir         {style::NumberingType::NUMBER_UPPER_ZH_TW,      NULL, LANG_CJK},
721*cdf0e10cSrcweir         {style::NumberingType::TIAN_GAN_ZH,             NULL, LANG_CJK},
722*cdf0e10cSrcweir         {style::NumberingType::DI_ZI_ZH,                NULL, LANG_CJK},
723*cdf0e10cSrcweir         {style::NumberingType::NUMBER_TRADITIONAL_JA,   NULL, LANG_CJK},
724*cdf0e10cSrcweir         {style::NumberingType::AIU_FULLWIDTH_JA,        NULL, LANG_CJK},
725*cdf0e10cSrcweir         {style::NumberingType::AIU_HALFWIDTH_JA,        NULL, LANG_CJK},
726*cdf0e10cSrcweir         {style::NumberingType::IROHA_FULLWIDTH_JA,      NULL, LANG_CJK},
727*cdf0e10cSrcweir         {style::NumberingType::IROHA_HALFWIDTH_JA,      NULL, LANG_CJK},
728*cdf0e10cSrcweir         {style::NumberingType::NUMBER_UPPER_KO,         NULL, LANG_CJK},
729*cdf0e10cSrcweir         {style::NumberingType::NUMBER_HANGUL_KO,        NULL, LANG_CJK},
730*cdf0e10cSrcweir         {style::NumberingType::HANGUL_JAMO_KO,          NULL, LANG_CJK},
731*cdf0e10cSrcweir         {style::NumberingType::HANGUL_SYLLABLE_KO,      NULL, LANG_CJK},
732*cdf0e10cSrcweir         {style::NumberingType::HANGUL_CIRCLED_JAMO_KO,  NULL, LANG_CJK},
733*cdf0e10cSrcweir         {style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO,      NULL, LANG_CJK},
734*cdf0e10cSrcweir         {style::NumberingType::CHARS_ARABIC,    NULL, LANG_CTL},
735*cdf0e10cSrcweir         {style::NumberingType::CHARS_THAI,      NULL, LANG_CTL},
736*cdf0e10cSrcweir         {style::NumberingType::CHARS_HEBREW,    NULL, LANG_CTL},
737*cdf0e10cSrcweir         {style::NumberingType::CHARS_NEPALI,    NULL, LANG_CTL},
738*cdf0e10cSrcweir         {style::NumberingType::CHARS_KHMER,     NULL, LANG_CTL},
739*cdf0e10cSrcweir         {style::NumberingType::CHARS_LAO,       NULL, LANG_CTL},
740*cdf0e10cSrcweir         {style::NumberingType::CHARS_MYANMAR,   NULL, LANG_CTL},
741*cdf0e10cSrcweir         {style::NumberingType::CHARS_TIBETAN,   NULL, LANG_CTL},
742*cdf0e10cSrcweir         {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},
743*cdf0e10cSrcweir         {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},
744*cdf0e10cSrcweir         {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},
745*cdf0e10cSrcweir         {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},
746*cdf0e10cSrcweir         {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},
747*cdf0e10cSrcweir         {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},
748*cdf0e10cSrcweir         {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},
749*cdf0e10cSrcweir         {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},
750*cdf0e10cSrcweir         {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},
751*cdf0e10cSrcweir         {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},
752*cdf0e10cSrcweir         {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},
753*cdf0e10cSrcweir         {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},
754*cdf0e10cSrcweir         {style::NumberingType::CHARS_PERSIAN,   NULL, LANG_CTL},
755*cdf0e10cSrcweir };
756*cdf0e10cSrcweir static const sal_Int32 nSupported_NumberingTypes = sizeof(aSupportedTypes) / sizeof(Supported_NumberingType);
757*cdf0e10cSrcweir /* -----------------------------21.02.01 15:57--------------------------------
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
762*cdf0e10cSrcweir                                 throw(RuntimeException)
763*cdf0e10cSrcweir {
764*cdf0e10cSrcweir         if (aSupportedTypes[index].cSymbol)
765*cdf0e10cSrcweir             return OUString(aSupportedTypes[index].cSymbol, strlen(aSupportedTypes[index].cSymbol), RTL_TEXTENCODING_UTF8);
766*cdf0e10cSrcweir //            return OUString::createFromAscii(aSupportedTypes[index].cSymbol);
767*cdf0e10cSrcweir         else {
768*cdf0e10cSrcweir             OUString result;
769*cdf0e10cSrcweir             Locale aLocale(OUString::createFromAscii("en"), OUString(), OUString());
770*cdf0e10cSrcweir             Sequence<beans::PropertyValue> aProperties(2);
771*cdf0e10cSrcweir             aProperties[0].Name = OUString::createFromAscii("NumberingType");
772*cdf0e10cSrcweir             aProperties[0].Value <<= aSupportedTypes[index].nType;
773*cdf0e10cSrcweir             aProperties[1].Name = OUString::createFromAscii("Value");
774*cdf0e10cSrcweir             for (sal_Int32 j = 1; j <= 3; j++) {
775*cdf0e10cSrcweir                 aProperties[1].Value <<= j;
776*cdf0e10cSrcweir                 result += makeNumberingString( aProperties, aLocale );
777*cdf0e10cSrcweir                 result += OUString::createFromAscii(", ");
778*cdf0e10cSrcweir             }
779*cdf0e10cSrcweir             result += OUString::createFromAscii("...");
780*cdf0e10cSrcweir             return result;
781*cdf0e10cSrcweir         }
782*cdf0e10cSrcweir }
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir sal_Bool SAL_CALL
785*cdf0e10cSrcweir DefaultNumberingProvider::isScriptFlagEnabled(const OUString& aName) throw(RuntimeException)
786*cdf0e10cSrcweir {
787*cdf0e10cSrcweir     if (! xHierarchicalNameAccess.is()) {
788*cdf0e10cSrcweir         Reference< XInterface > xInterface;
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir         xInterface = xSMgr->createInstance(OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"));
791*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xConfigProvider =
792*cdf0e10cSrcweir                 Reference< XMultiServiceFactory >(xInterface, UNO_QUERY );
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir         if (! xConfigProvider.is())
795*cdf0e10cSrcweir             throw RuntimeException();
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir         Sequence< Any > aArgs(1);
798*cdf0e10cSrcweir         beans::PropertyValue aPath;
799*cdf0e10cSrcweir         aPath.Name = OUString::createFromAscii("nodepath");
800*cdf0e10cSrcweir         aPath.Value <<= OUString::createFromAscii("/org.openoffice.Office.Common/I18N"),
801*cdf0e10cSrcweir         aArgs[0] <<= aPath;
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir         xInterface = xConfigProvider->createInstanceWithArguments(
804*cdf0e10cSrcweir             OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), aArgs);
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir         xHierarchicalNameAccess.set(xInterface, UNO_QUERY);
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir         if (! xHierarchicalNameAccess.is())
809*cdf0e10cSrcweir             throw RuntimeException();
810*cdf0e10cSrcweir     }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir     Any aEnabled = xHierarchicalNameAccess->getByHierarchicalName(aName);
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir     sal_Bool enabled = sal_False;
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir     aEnabled >>= enabled;
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir     return enabled;
819*cdf0e10cSrcweir }
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir Sequence< sal_Int16 > DefaultNumberingProvider::getSupportedNumberingTypes(  )
822*cdf0e10cSrcweir                                 throw(RuntimeException)
823*cdf0e10cSrcweir {
824*cdf0e10cSrcweir         Sequence< sal_Int16 > aRet(nSupported_NumberingTypes );
825*cdf0e10cSrcweir         sal_Int16* pArray = aRet.getArray();
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir         sal_Bool cjkEnabled = isScriptFlagEnabled(OUString::createFromAscii("CJK/CJKFont"));
828*cdf0e10cSrcweir         sal_Bool ctlEnabled = isScriptFlagEnabled(OUString::createFromAscii("CTL/CTLFont"));
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir         for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++) {
831*cdf0e10cSrcweir             if ( (aSupportedTypes[i].langOption & LANG_ALL) ||
832*cdf0e10cSrcweir                     ((aSupportedTypes[i].langOption & LANG_CJK) && cjkEnabled) ||
833*cdf0e10cSrcweir                     ((aSupportedTypes[i].langOption & LANG_CTL) && ctlEnabled) )
834*cdf0e10cSrcweir                 pArray[i] = aSupportedTypes[i].nType;
835*cdf0e10cSrcweir         }
836*cdf0e10cSrcweir         return aRet;
837*cdf0e10cSrcweir }
838*cdf0e10cSrcweir /* -----------------------------21.02.01 15:57--------------------------------
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
841*cdf0e10cSrcweir sal_Int16 DefaultNumberingProvider::getNumberingType( const OUString& rNumberingIdentifier )
842*cdf0e10cSrcweir                                 throw(RuntimeException)
843*cdf0e10cSrcweir {
844*cdf0e10cSrcweir         for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
845*cdf0e10cSrcweir                 if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
846*cdf0e10cSrcweir                         return aSupportedTypes[i].nType;
847*cdf0e10cSrcweir         throw RuntimeException();
848*cdf0e10cSrcweir }
849*cdf0e10cSrcweir /* -----------------------------21.02.01 15:57--------------------------------
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
852*cdf0e10cSrcweir sal_Bool DefaultNumberingProvider::hasNumberingType( const OUString& rNumberingIdentifier )
853*cdf0e10cSrcweir                                 throw(RuntimeException)
854*cdf0e10cSrcweir {
855*cdf0e10cSrcweir         for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
856*cdf0e10cSrcweir                 if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
857*cdf0e10cSrcweir                         return sal_True;
858*cdf0e10cSrcweir         return sal_False;
859*cdf0e10cSrcweir }
860*cdf0e10cSrcweir /* -----------------------------21.02.01 15:57--------------------------------
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
863*cdf0e10cSrcweir OUString DefaultNumberingProvider::getNumberingIdentifier( sal_Int16 nNumberingType )
864*cdf0e10cSrcweir                                 throw(RuntimeException)
865*cdf0e10cSrcweir {
866*cdf0e10cSrcweir         for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
867*cdf0e10cSrcweir             if(nNumberingType == aSupportedTypes[i].nType)
868*cdf0e10cSrcweir                 return makeNumberingIdentifier(i);
869*cdf0e10cSrcweir         return OUString();
870*cdf0e10cSrcweir }
871*cdf0e10cSrcweir /* -----------------------------05.07.01 13:34--------------------------------
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
874*cdf0e10cSrcweir const sal_Char cDefaultNumberingProvider[] = "com.sun.star.text.DefaultNumberingProvider";
875*cdf0e10cSrcweir OUString DefaultNumberingProvider::getImplementationName(void)
876*cdf0e10cSrcweir                 throw( RuntimeException )
877*cdf0e10cSrcweir {
878*cdf0e10cSrcweir     return OUString::createFromAscii(cDefaultNumberingProvider);
879*cdf0e10cSrcweir }
880*cdf0e10cSrcweir /* -----------------------------05.07.01 13:34--------------------------------
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
883*cdf0e10cSrcweir sal_Bool DefaultNumberingProvider::supportsService(const rtl::OUString& rServiceName)
884*cdf0e10cSrcweir                 throw( RuntimeException )
885*cdf0e10cSrcweir {
886*cdf0e10cSrcweir     return rServiceName.equalsAscii(cDefaultNumberingProvider);
887*cdf0e10cSrcweir }
888*cdf0e10cSrcweir /* -----------------------------05.07.01 13:34--------------------------------
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
891*cdf0e10cSrcweir Sequence< OUString > DefaultNumberingProvider::getSupportedServiceNames(void)
892*cdf0e10cSrcweir                 throw( RuntimeException )
893*cdf0e10cSrcweir {
894*cdf0e10cSrcweir     Sequence< OUString > aRet(1);
895*cdf0e10cSrcweir     aRet[0] = OUString::createFromAscii(cDefaultNumberingProvider);
896*cdf0e10cSrcweir     return aRet;
897*cdf0e10cSrcweir }
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir } } } }
900