1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="i18n_XLocaleData" script:language="StarBasic">
'*************************************************************************
'
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org. If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'*************************************************************************
'*************************************************************************
' Be sure that all variables are dimensioned:
option explicit
Sub RunTest()
'*************************************************************************
' INTERFACE:
' com.sun.star.i18n.XLocaleData
'*************************************************************************
On Error Goto ErrHndl
Dim bOK As Boolean
Dim AllNames As Variant, nNamesCount As Integer, i As Integer
Dim Locale As Variant, oInfo As Variant, LocItem As Variant
Dim AllCalendars As Variant, AllCurrencies As Variant
Dim AllFormats As Variant, Implementations As Variant
Dim sOpt As Variant, size As Variant
Dim rtLit As Variant, fbc As Variant, rw As Variant
Test.StartMethod("getAllInstalledLocaleNames()")
bOK = true
AllNames = oObj.getAllInstalledLocaleNames()
nNamesCount = ubound(AllNames)
Out.Log("Found " + nNamesCount + " Loacales registered in the system")
for i = 0 to nNamesCount
Out.Log("" + i + "). " + AllNames(i).Country + ";" + AllNames(i).Language + ";" + AllNames(i).Variant)
next i
Randomize
Locale = AllNames(rnd * nNamesCount)
Out.Log("Choose for testing : " + Locale.Country)
bOK = bOK AND NOT isNULL(Locale)
Test.MethodTested("getAllInstalledLocaleNames()", bOK)
Test.StartMethod("getLanguageCountryInfo()")
bOK = true
oInfo = oObj.getLanguageCountryInfo(Locale)
bOK = bOK AND oInfo.Language = Locale.Language
bOK = bOK AND oInfo.Country = Locale.Country
Out.Log("Language: " + oInfo.Language + _
", LanguageDefaultName: " + oInfo.LanguageDefaultName + _
", Country: " + oInfo.Country + _
", CountryDefaultName: " + oInfo.CountryDefaultName + _
", Variant: " + oInfo.Variant)
Test.MethodTested("getLanguageCountryInfo()", bOK)
Test.StartMethod("getLocaleItem()")
bOK = true
LocItem = oObj.getLocaleItem(Locale)
bOK = bOK AND LocItem.unoID <> ""
Out.Log(" unoID: " + LocItem.unoID + _
" dateSeparator: " + LocItem.dateSeparator + _
" thousandSeparator: " + LocItem.thousandSeparator + _
" decimalSeparator: " + LocItem.decimalSeparator + _
" timeSeparator: " + LocItem.timeSeparator + _
" time100SecSeparator: " + LocItem.time100SecSeparator + _
" listSeparator: " + LocItem.listSeparator + _
" quotationStart: " + LocItem.quotationStart + _
" quotationEnd: " + LocItem.quotationEnd + _
" doubleQuotationStart: " + LocItem.doubleQuotationStart + _
" doubleQuotationEnd: " + LocItem.doubleQuotationEnd + _
" timeAM: " + LocItem.timeAM + _
" timePM: " + LocItem.timePM + _
" measurementSystem: " + LocItem.measurementSystem + _
" LongDateDayOfWeekSeparator: " + LocItem.LongDateDayOfWeekSeparator + _
" LongDateDaySeparator: " + LocItem.LongDateDaySeparator + _
" LongDateMonthSeparator: " + LocItem.LongDateMonthSeparator + _
" LongDateYearSeparator: " + LocItem.LongDateYearSeparator)
Test.MethodTested("getLocaleItem()", bOK)
Test.StartMethod("getAllCalendars()")
bOK = true
AllCalendars = oObj.getAllCalendars(Locale)
bOK = bOK AND NOT isNULL(AllCalendars(0))
Out.Log("Found " + ubound(AllCalendars) + 1 + " calendar(s) used in this Locale")
Dim Days As Variant, Months As Variant, Eras As Variant
Dim j As Integer
for i = 0 to ubound(AllCalendars)
Out.Log("Calendar " + i + 1 + ":")
Out.Log(" Days:")
Days = AllCalendars(i).Days
for j = 0 to ubound(Days)
Out.Log(" " + j + ") ID: " + Days(j).ID + ", AbbrevName: " + Days(j).AbbrevName + ", FullName: " + Days(j).FullName)
next j
Out.Log(" Months:")
Months = AllCalendars(i).Months
for j = 0 to ubound(Months)
Out.Log(" " + j + ") ID: " + Months(j).ID + ", AbbrevName: " + Months(j).AbbrevName + ", FullName: " + Months(j).FullName)
next j
Out.Log(" Eras:")
Eras = AllCalendars(i).Eras
for j = 0 to ubound(Eras)
Out.Log(" " + j + ") ID: " + Eras(j).ID + ", AbbrevName: " + Eras(j).AbbrevName + ", FullName: " + Eras(j).FullName)
next j
Out.Log(" StartOfWeek: " + AllCalendars(i).StartOfWeek)
Out.Log(" MinimumNumberOfDaysForFirstWeek: " + AllCalendars(i).MinimumNumberOfDaysForFirstWeek)
Out.Log(" Default: " + AllCalendars(i).Default)
Out.Log(" Name: " + AllCalendars(i).Name)
next i
Test.MethodTested("getAllCalendars()", bOK)
Test.StartMethod("getAllCurrencies()")
bOK = true
AllCurrencies = oObj.getAllCurrencies(Locale)
Out.Log("Found " + ubound(AllCurrencies) + 1 + " Currencies used in this Locale")
bOK = bOK AND NOT isNULL(AllCurrencies(0))
for i = 0 to ubound(AllCurrencies)
Out.Log("Currency " + i + 1 + ":")
Out.Log(" ID: " + AllCurrencies(i).ID + _
" Symbol: " + AllCurrencies(i).Symbol + _
" BankSymbol: " + AllCurrencies(i).BankSymbol + _
" Name: " + AllCurrencies(i).Name + _
" Default: " + AllCurrencies(i).Default)
next i
Test.MethodTested("getAllCurrencies()", bOK)
Test.StartMethod("getAllFormats()")
bOK = true
AllFormats = oObj.getAllFormats(Locale)
Out.Log("Found " + ubound(AllFormats) + 1 + " FormatElement(s) used in this Locale")
bOK = bOK AND NOT isNULL(AllFormats(0))
for i = 0 to ubound(AllFormats)
Out.Log("FormatElement " + i + 1 + ":")
Out.Log(" formatCode: " + AllFormats(i).formatCode + _
" formatName: " + AllFormats(i).formatName + _
" formatKey: " + AllFormats(i).formatKey + _
" formatType: " + AllFormats(i).formatType + _
" formatUsage: " + AllFormats(i).formatUsage + _
" formatIndex: " + AllFormats(i).formatIndex + _
" isDefault: " + AllFormats(i).isDefault)
next i
Test.MethodTested("getAllFormats()", bOK)
Test.StartMethod("getCollatorImplementations()")
bOK = true
Implementations = oObj.getCollatorImplementations(Locale)
Out.Log("Found " + (ubound(Implementations) + 1) + " Implementation(s) used in this Locale")
bOK = bOK AND NOT isNULL(Implementations(0))
for i = 0 to ubound(Implementations)
Out.Log("Implementation " + (i + 1) + ":")
Out.Log(" unoID: " + Implementations(i).unoID )
Out.Log(" isDefault: " + Implementations(i).isDefault)
next i
Test.MethodTested("getCollatorImplementations()", bOK)
Test.StartMethod("getSearchOptions()")
bOK = true
sOpt = oObj.getSearchOptions(Locale)
size = ubound(sOpt)
Out.Log("There are : " + (size + 1) + " search options.")
for i = 0 to size
Out.Log("'" + sOpt(i) + "'")
next i
bOK = bOK AND isArray(sOpt)
Test.MethodTested("getSearchOptions()", bOK)
Test.StartMethod("getCollationOptions()")
bOK = true
sOpt = oObj.getCollationOptions(Locale)
size = ubound(sOpt)
Out.Log("There are : " + (size + 1) + " collation options.")
for i = 0 to size
Out.Log("'" + sOpt(i) + "'")
next i
bOK = bOK AND isArray(sOpt)
Test.MethodTested("getCollationOptions()", bOK)
Test.StartMethod("getTransliterations()")
bOK = true
rtLit = oObj.getTransliterations(Locale)
bOK = bOK AND NOT isNULL(rtLit)
for i = 0 to ubound(rtLit)
Out.Log("" + i + 1 +") " + rtLit(i))
next i
Test.MethodTested("getTransliterations()", bOK)
Test.StartMethod("getForbiddenCharacters()")
bOK = true
fbc = oObj.getForbiddenCharacters(Locale)
Out.Log(" beginLine: " + fbc.beginLine)
Out.Log(" endLine: " + fbc.endLine)
bOK = bOK AND NOT isNULL(fbc)
Test.MethodTested("getForbiddenCharacters()", bOK)
Test.StartMethod("getReservedWord()")
bOK = true
rw = oObj.getReservedWord(Locale)
bOK = bOK AND NOT isNULL(rw)
for i = 0 to ubound(rw)
Out.Log("" + i + 1 +") " + rw(i))
next i
Test.MethodTested("getReservedWord()", bOK)
Exit Sub
ErrHndl:
Test.Exception()
bOK = false
resume next
End Sub
</script:module>
|