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
37' Be sure that all variables are dimensioned:
38option explicit
39
40
41
42Sub RunTest()
43
44'*************************************************************************
45' INTERFACE:
46' com.sun.star.i18n.XLocaleData
47'*************************************************************************
48On Error Goto ErrHndl
49    Dim bOK As Boolean
50    Dim AllNames As Variant, nNamesCount As Integer, i As Integer
51    Dim Locale As Variant, oInfo As Variant, LocItem As Variant
52    Dim AllCalendars As Variant, AllCurrencies As Variant
53    Dim AllFormats As Variant, Implementations As Variant
54    Dim sOpt As Variant, size As Variant
55    Dim rtLit As Variant, fbc As Variant, rw As Variant
56
57    Test.StartMethod("getAllInstalledLocaleNames()")
58    bOK = true
59    AllNames = oObj.getAllInstalledLocaleNames()
60    nNamesCount = ubound(AllNames)
61    Out.Log("Found " + nNamesCount + " Loacales registered in the system")
62
63    for i = 0 to nNamesCount
64        Out.Log("" + i + "). " + AllNames(i).Country + ";" + AllNames(i).Language + ";" + AllNames(i).Variant)
65    next i
66
67    Randomize
68    Locale = AllNames(rnd * nNamesCount)
69    Out.Log("Choose for testing : " + Locale.Country)
70
71    bOK = bOK AND NOT isNULL(Locale)
72    Test.MethodTested("getAllInstalledLocaleNames()", bOK)
73
74    Test.StartMethod("getLanguageCountryInfo()")
75    bOK = true
76    oInfo = oObj.getLanguageCountryInfo(Locale)
77    bOK = bOK AND oInfo.Language = Locale.Language
78    bOK = bOK AND oInfo.Country = Locale.Country
79    Out.Log("Language: " + oInfo.Language + _
80           ", LanguageDefaultName: " + oInfo.LanguageDefaultName + _
81           ", Country: " + oInfo.Country + _
82           ", CountryDefaultName: " + oInfo.CountryDefaultName + _
83           ", Variant: " + oInfo.Variant)
84
85    Test.MethodTested("getLanguageCountryInfo()", bOK)
86
87    Test.StartMethod("getLocaleItem()")
88    bOK = true
89    LocItem = oObj.getLocaleItem(Locale)
90    bOK = bOK AND LocItem.unoID &lt;&gt; ""
91    Out.Log(" unoID: " + LocItem.unoID + _
92           " dateSeparator: " + LocItem.dateSeparator + _
93           " thousandSeparator: " + LocItem.thousandSeparator + _
94           " decimalSeparator: " + LocItem.decimalSeparator + _
95           " timeSeparator: " + LocItem.timeSeparator + _
96           " time100SecSeparator: " + LocItem.time100SecSeparator + _
97           " listSeparator: " + LocItem.listSeparator + _
98           " quotationStart: " + LocItem.quotationStart + _
99           " quotationEnd: " + LocItem.quotationEnd + _
100           " doubleQuotationStart: " + LocItem.doubleQuotationStart + _
101           " doubleQuotationEnd: " + LocItem.doubleQuotationEnd + _
102           " timeAM: " + LocItem.timeAM + _
103           " timePM: " + LocItem.timePM + _
104           " measurementSystem: " + LocItem.measurementSystem + _
105           " LongDateDayOfWeekSeparator: " + LocItem.LongDateDayOfWeekSeparator + _
106           " LongDateDaySeparator: " + LocItem.LongDateDaySeparator + _
107           " LongDateMonthSeparator: " + LocItem.LongDateMonthSeparator + _
108           " LongDateYearSeparator: " + LocItem.LongDateYearSeparator)
109    Test.MethodTested("getLocaleItem()", bOK)
110
111    Test.StartMethod("getAllCalendars()")
112    bOK = true
113    AllCalendars = oObj.getAllCalendars(Locale)
114    bOK = bOK AND NOT isNULL(AllCalendars(0))
115    Out.Log("Found " + ubound(AllCalendars) + 1 + " calendar(s) used in this Locale")
116
117    Dim Days As Variant, Months As Variant, Eras As Variant
118    Dim j As Integer
119    for i = 0 to ubound(AllCalendars)
120
121        Out.Log("Calendar " + i + 1 + ":")
122        Out.Log("  Days:")
123        Days = AllCalendars(i).Days
124        for j = 0 to ubound(Days)
125            Out.Log("    " + j + ") ID: " + Days(j).ID + ", AbbrevName: " + Days(j).AbbrevName + ", FullName: " + Days(j).FullName)
126        next j
127        Out.Log("  Months:")
128        Months = AllCalendars(i).Months
129        for j = 0 to ubound(Months)
130            Out.Log("    " + j + ") ID: " + Months(j).ID + ", AbbrevName: " + Months(j).AbbrevName + ", FullName: " + Months(j).FullName)
131        next j
132        Out.Log("  Eras:")
133        Eras = AllCalendars(i).Eras
134        for j = 0 to ubound(Eras)
135            Out.Log("    " + j + ") ID: " + Eras(j).ID + ", AbbrevName: " + Eras(j).AbbrevName + ", FullName: " + Eras(j).FullName)
136        next j
137        Out.Log("  StartOfWeek: " + AllCalendars(i).StartOfWeek)
138        Out.Log("  MinimumNumberOfDaysForFirstWeek: " + AllCalendars(i).MinimumNumberOfDaysForFirstWeek)
139        Out.Log("  Default: " + AllCalendars(i).Default)
140        Out.Log("  Name: " + AllCalendars(i).Name)
141    next i
142
143    Test.MethodTested("getAllCalendars()", bOK)
144
145    Test.StartMethod("getAllCurrencies()")
146    bOK = true
147    AllCurrencies = oObj.getAllCurrencies(Locale)
148    Out.Log("Found " + ubound(AllCurrencies) + 1 + " Currencies used in this Locale")
149    bOK = bOK AND NOT isNULL(AllCurrencies(0))
150    for i = 0 to ubound(AllCurrencies)
151        Out.Log("Currency " + i + 1 + ":")
152        Out.Log("  ID: " + AllCurrencies(i).ID + _
153              "  Symbol: " + AllCurrencies(i).Symbol + _
154              "  BankSymbol: " + AllCurrencies(i).BankSymbol + _
155              "  Name: " + AllCurrencies(i).Name + _
156              "  Default: " + AllCurrencies(i).Default)
157    next i
158
159    Test.MethodTested("getAllCurrencies()", bOK)
160
161    Test.StartMethod("getAllFormats()")
162    bOK = true
163    AllFormats = oObj.getAllFormats(Locale)
164    Out.Log("Found " + ubound(AllFormats) + 1 + " FormatElement(s) used in this Locale")
165    bOK = bOK AND NOT isNULL(AllFormats(0))
166    for i = 0 to ubound(AllFormats)
167        Out.Log("FormatElement " + i + 1 + ":")
168        Out.Log("  formatCode: " + AllFormats(i).formatCode + _
169              "  formatName: " + AllFormats(i).formatName + _
170              "  formatKey: " + AllFormats(i).formatKey + _
171              "  formatType: " + AllFormats(i).formatType + _
172              "  formatUsage: " + AllFormats(i).formatUsage + _
173              "  formatIndex: " + AllFormats(i).formatIndex + _
174              "  isDefault: " + AllFormats(i).isDefault)
175   	next i
176    Test.MethodTested("getAllFormats()", bOK)
177
178    Test.StartMethod("getCollatorImplementations()")
179    bOK = true
180    Implementations = oObj.getCollatorImplementations(Locale)
181    Out.Log("Found " + (ubound(Implementations) + 1) + " Implementation(s) used in this Locale")
182    bOK = bOK AND NOT isNULL(Implementations(0))
183    for i = 0 to ubound(Implementations)
184        Out.Log("Implementation " + (i + 1) + ":")
185        Out.Log("  unoID: " + Implementations(i).unoID )
186        Out.Log("  isDefault: " + Implementations(i).isDefault)
187    next i
188    Test.MethodTested("getCollatorImplementations()", bOK)
189
190    Test.StartMethod("getSearchOptions()")
191    bOK = true
192    sOpt = oObj.getSearchOptions(Locale)
193    size = ubound(sOpt)
194    Out.Log("There are : " + (size + 1) + " search options.")
195    for i = 0 to size
196    	Out.Log("'" + sOpt(i) + "'")
197    next i
198    bOK = bOK AND isArray(sOpt)
199    Test.MethodTested("getSearchOptions()", bOK)
200
201    Test.StartMethod("getCollationOptions()")
202    bOK = true
203    sOpt = oObj.getCollationOptions(Locale)
204    size = ubound(sOpt)
205    Out.Log("There are : " + (size + 1) + " collation options.")
206    for i = 0 to size
207    	Out.Log("'" + sOpt(i) + "'")
208    next i
209    bOK = bOK AND isArray(sOpt)
210    Test.MethodTested("getCollationOptions()", bOK)
211
212    Test.StartMethod("getTransliterations()")
213    bOK = true
214    rtLit = oObj.getTransliterations(Locale)
215    bOK = bOK AND NOT isNULL(rtLit)
216    for i = 0 to ubound(rtLit)
217        Out.Log("" + i + 1 +") " + rtLit(i))
218    next i
219    Test.MethodTested("getTransliterations()", bOK)
220
221    Test.StartMethod("getForbiddenCharacters()")
222    bOK = true
223    fbc = oObj.getForbiddenCharacters(Locale)
224
225    Out.Log(" beginLine: " + fbc.beginLine)
226    Out.Log(" endLine: " + fbc.endLine)
227
228    bOK = bOK AND NOT isNULL(fbc)
229    Test.MethodTested("getForbiddenCharacters()", bOK)
230
231    Test.StartMethod("getReservedWord()")
232    bOK = true
233    rw = oObj.getReservedWord(Locale)
234    bOK = bOK AND NOT isNULL(rw)
235    for i = 0 to ubound(rw)
236        Out.Log("" + i + 1 +") " + rw(i))
237    next i
238    Test.MethodTested("getReservedWord()", bOK)
239
240Exit Sub
241ErrHndl:
242    Test.Exception()
243    bOK = false
244    resume next
245End Sub
246</script:module>
247