1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="i18n_XLocaleData" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35
36Sub RunTest()
37
38'*************************************************************************
39' INTERFACE:
40' com.sun.star.i18n.XLocaleData
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim AllNames As Variant, nNamesCount As Integer, i As Integer
45    Dim Locale As Variant, oInfo As Variant, LocItem As Variant
46    Dim AllCalendars As Variant, AllCurrencies As Variant
47    Dim AllFormats As Variant, Implementations As Variant
48    Dim sOpt As Variant, size As Variant
49    Dim rtLit As Variant, fbc As Variant, rw As Variant
50
51    Test.StartMethod("getAllInstalledLocaleNames()")
52    bOK = true
53    AllNames = oObj.getAllInstalledLocaleNames()
54    nNamesCount = ubound(AllNames)
55    Out.Log("Found " + nNamesCount + " Loacales registered in the system")
56
57    for i = 0 to nNamesCount
58        Out.Log("" + i + "). " + AllNames(i).Country + ";" + AllNames(i).Language + ";" + AllNames(i).Variant)
59    next i
60
61    Randomize
62    Locale = AllNames(rnd * nNamesCount)
63    Out.Log("Choose for testing : " + Locale.Country)
64
65    bOK = bOK AND NOT isNULL(Locale)
66    Test.MethodTested("getAllInstalledLocaleNames()", bOK)
67
68    Test.StartMethod("getLanguageCountryInfo()")
69    bOK = true
70    oInfo = oObj.getLanguageCountryInfo(Locale)
71    bOK = bOK AND oInfo.Language = Locale.Language
72    bOK = bOK AND oInfo.Country = Locale.Country
73    Out.Log("Language: " + oInfo.Language + _
74           ", LanguageDefaultName: " + oInfo.LanguageDefaultName + _
75           ", Country: " + oInfo.Country + _
76           ", CountryDefaultName: " + oInfo.CountryDefaultName + _
77           ", Variant: " + oInfo.Variant)
78
79    Test.MethodTested("getLanguageCountryInfo()", bOK)
80
81    Test.StartMethod("getLocaleItem()")
82    bOK = true
83    LocItem = oObj.getLocaleItem(Locale)
84    bOK = bOK AND LocItem.unoID &lt;&gt; ""
85    Out.Log(" unoID: " + LocItem.unoID + _
86           " dateSeparator: " + LocItem.dateSeparator + _
87           " thousandSeparator: " + LocItem.thousandSeparator + _
88           " decimalSeparator: " + LocItem.decimalSeparator + _
89           " timeSeparator: " + LocItem.timeSeparator + _
90           " time100SecSeparator: " + LocItem.time100SecSeparator + _
91           " listSeparator: " + LocItem.listSeparator + _
92           " quotationStart: " + LocItem.quotationStart + _
93           " quotationEnd: " + LocItem.quotationEnd + _
94           " doubleQuotationStart: " + LocItem.doubleQuotationStart + _
95           " doubleQuotationEnd: " + LocItem.doubleQuotationEnd + _
96           " timeAM: " + LocItem.timeAM + _
97           " timePM: " + LocItem.timePM + _
98           " measurementSystem: " + LocItem.measurementSystem + _
99           " LongDateDayOfWeekSeparator: " + LocItem.LongDateDayOfWeekSeparator + _
100           " LongDateDaySeparator: " + LocItem.LongDateDaySeparator + _
101           " LongDateMonthSeparator: " + LocItem.LongDateMonthSeparator + _
102           " LongDateYearSeparator: " + LocItem.LongDateYearSeparator)
103    Test.MethodTested("getLocaleItem()", bOK)
104
105    Test.StartMethod("getAllCalendars()")
106    bOK = true
107    AllCalendars = oObj.getAllCalendars(Locale)
108    bOK = bOK AND NOT isNULL(AllCalendars(0))
109    Out.Log("Found " + ubound(AllCalendars) + 1 + " calendar(s) used in this Locale")
110
111    Dim Days As Variant, Months As Variant, Eras As Variant
112    Dim j As Integer
113    for i = 0 to ubound(AllCalendars)
114
115        Out.Log("Calendar " + i + 1 + ":")
116        Out.Log("  Days:")
117        Days = AllCalendars(i).Days
118        for j = 0 to ubound(Days)
119            Out.Log("    " + j + ") ID: " + Days(j).ID + ", AbbrevName: " + Days(j).AbbrevName + ", FullName: " + Days(j).FullName)
120        next j
121        Out.Log("  Months:")
122        Months = AllCalendars(i).Months
123        for j = 0 to ubound(Months)
124            Out.Log("    " + j + ") ID: " + Months(j).ID + ", AbbrevName: " + Months(j).AbbrevName + ", FullName: " + Months(j).FullName)
125        next j
126        Out.Log("  Eras:")
127        Eras = AllCalendars(i).Eras
128        for j = 0 to ubound(Eras)
129            Out.Log("    " + j + ") ID: " + Eras(j).ID + ", AbbrevName: " + Eras(j).AbbrevName + ", FullName: " + Eras(j).FullName)
130        next j
131        Out.Log("  StartOfWeek: " + AllCalendars(i).StartOfWeek)
132        Out.Log("  MinimumNumberOfDaysForFirstWeek: " + AllCalendars(i).MinimumNumberOfDaysForFirstWeek)
133        Out.Log("  Default: " + AllCalendars(i).Default)
134        Out.Log("  Name: " + AllCalendars(i).Name)
135    next i
136
137    Test.MethodTested("getAllCalendars()", bOK)
138
139    Test.StartMethod("getAllCurrencies()")
140    bOK = true
141    AllCurrencies = oObj.getAllCurrencies(Locale)
142    Out.Log("Found " + ubound(AllCurrencies) + 1 + " Currencies used in this Locale")
143    bOK = bOK AND NOT isNULL(AllCurrencies(0))
144    for i = 0 to ubound(AllCurrencies)
145        Out.Log("Currency " + i + 1 + ":")
146        Out.Log("  ID: " + AllCurrencies(i).ID + _
147              "  Symbol: " + AllCurrencies(i).Symbol + _
148              "  BankSymbol: " + AllCurrencies(i).BankSymbol + _
149              "  Name: " + AllCurrencies(i).Name + _
150              "  Default: " + AllCurrencies(i).Default)
151    next i
152
153    Test.MethodTested("getAllCurrencies()", bOK)
154
155    Test.StartMethod("getAllFormats()")
156    bOK = true
157    AllFormats = oObj.getAllFormats(Locale)
158    Out.Log("Found " + ubound(AllFormats) + 1 + " FormatElement(s) used in this Locale")
159    bOK = bOK AND NOT isNULL(AllFormats(0))
160    for i = 0 to ubound(AllFormats)
161        Out.Log("FormatElement " + i + 1 + ":")
162        Out.Log("  formatCode: " + AllFormats(i).formatCode + _
163              "  formatName: " + AllFormats(i).formatName + _
164              "  formatKey: " + AllFormats(i).formatKey + _
165              "  formatType: " + AllFormats(i).formatType + _
166              "  formatUsage: " + AllFormats(i).formatUsage + _
167              "  formatIndex: " + AllFormats(i).formatIndex + _
168              "  isDefault: " + AllFormats(i).isDefault)
169   	next i
170    Test.MethodTested("getAllFormats()", bOK)
171
172    Test.StartMethod("getCollatorImplementations()")
173    bOK = true
174    Implementations = oObj.getCollatorImplementations(Locale)
175    Out.Log("Found " + (ubound(Implementations) + 1) + " Implementation(s) used in this Locale")
176    bOK = bOK AND NOT isNULL(Implementations(0))
177    for i = 0 to ubound(Implementations)
178        Out.Log("Implementation " + (i + 1) + ":")
179        Out.Log("  unoID: " + Implementations(i).unoID )
180        Out.Log("  isDefault: " + Implementations(i).isDefault)
181    next i
182    Test.MethodTested("getCollatorImplementations()", bOK)
183
184    Test.StartMethod("getSearchOptions()")
185    bOK = true
186    sOpt = oObj.getSearchOptions(Locale)
187    size = ubound(sOpt)
188    Out.Log("There are : " + (size + 1) + " search options.")
189    for i = 0 to size
190    	Out.Log("'" + sOpt(i) + "'")
191    next i
192    bOK = bOK AND isArray(sOpt)
193    Test.MethodTested("getSearchOptions()", bOK)
194
195    Test.StartMethod("getCollationOptions()")
196    bOK = true
197    sOpt = oObj.getCollationOptions(Locale)
198    size = ubound(sOpt)
199    Out.Log("There are : " + (size + 1) + " collation options.")
200    for i = 0 to size
201    	Out.Log("'" + sOpt(i) + "'")
202    next i
203    bOK = bOK AND isArray(sOpt)
204    Test.MethodTested("getCollationOptions()", bOK)
205
206    Test.StartMethod("getTransliterations()")
207    bOK = true
208    rtLit = oObj.getTransliterations(Locale)
209    bOK = bOK AND NOT isNULL(rtLit)
210    for i = 0 to ubound(rtLit)
211        Out.Log("" + i + 1 +") " + rtLit(i))
212    next i
213    Test.MethodTested("getTransliterations()", bOK)
214
215    Test.StartMethod("getForbiddenCharacters()")
216    bOK = true
217    fbc = oObj.getForbiddenCharacters(Locale)
218
219    Out.Log(" beginLine: " + fbc.beginLine)
220    Out.Log(" endLine: " + fbc.endLine)
221
222    bOK = bOK AND NOT isNULL(fbc)
223    Test.MethodTested("getForbiddenCharacters()", bOK)
224
225    Test.StartMethod("getReservedWord()")
226    bOK = true
227    rw = oObj.getReservedWord(Locale)
228    bOK = bOK AND NOT isNULL(rw)
229    for i = 0 to ubound(rw)
230        Out.Log("" + i + 1 +") " + rw(i))
231    next i
232    Test.MethodTested("getReservedWord()", bOK)
233
234Exit Sub
235ErrHndl:
236    Test.Exception()
237    bOK = false
238    resume next
239End Sub
240</script:module>
241