| <?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"> |
| |
| |
| '************************************************************************* |
| ' |
| ' Licensed to the Apache Software Foundation (ASF) under one |
| ' or more contributor license agreements. See the NOTICE file |
| ' distributed with this work for additional information |
| ' regarding copyright ownership. The ASF licenses this file |
| ' to you under the Apache License, Version 2.0 (the |
| ' "License"); you may not use this file except in compliance |
| ' with the License. You may obtain a copy of the License at |
| ' |
| ' http://www.apache.org/licenses/LICENSE-2.0 |
| ' |
| ' Unless required by applicable law or agreed to in writing, |
| ' software distributed under the License is distributed on an |
| ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ' KIND, either express or implied. See the License for the |
| ' specific language governing permissions and limitations |
| ' under the 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> |