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