diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/i18n')
16 files changed, 1799 insertions, 0 deletions
diff --git a/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/i18n_XBreakIterator.xba b/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/i18n_XBreakIterator.xba new file mode 100644 index 000000000000..caea03d8e837 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/i18n_XBreakIterator.xba @@ -0,0 +1,408 @@ +<?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_XBreakIterator" 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 + +'************************************************************************* +' This Interface/Service test depends on the following GLOBAL variables, +' which must be specified in the object creation: + +' - Global oLocale As Object +' - Global UnicodeString As String +' - Global ScriptType(2, 1) As Integer + +'************************************************************************* + + + + + +const arrSize = 300 + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XBreakIterator +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim i As Integer + Dim nCharacterIteratorMode As Integer + Dim lDone As Long + Dim lRes As Long + Dim wordType As Integer + Dim Boundary As Variant + Dim BoundsToTest(arrSize) As new com.sun.star.i18n.Boundary + Dim Types(arrSize) As Integer + Dim nBoundsToTest As Integer + Dim iPos As Integer + Dim iType As Integer + Dim bFound As Boolean + Dim j As Integer + Dim NextCharacters(2, 3) As Integer + Dim PreviousCharacters(2, 3) As Integer + + Test.StartMethod("nextCharacters()") + bOK = true + nCharacterIteratorMode = com.sun.star.i18n.CharacterIteratorMode.SKIPCHARACTER + + 'Start from position : Travel ... chars : Actual position after : How many chars traveled + NextCharacters(0, 0) = 1 : NextCharacters(0, 1) = 5000 : NextCharacters(0, 2) = len(UnicodeString) : NextCharacters(0, 3) = len(UnicodeString) - 1 + NextCharacters(1, 0) = 5 : NextCharacters(1, 1) = -5000 : NextCharacters(1, 2) = 0 : NextCharacters(1, 3) = -5 + NextCharacters(2, 0) = 10 : NextCharacters(2, 1) = 6 : NextCharacters(2, 2) = 16 : NextCharacters(2, 3) = 6 + + for i = 0 to 2 + lRes = oObj.nextCharacters(UnicodeString, NextCharacters(i, 0), _ + oLocale, nCharacterIteratorMode, NextCharacters(i, 1), lDone) + Out.Log("Expected result is: lRes = " + NextCharacters(i, 2) + _ + "; lDone = " + NextCharacters(i, 3)) + Out.Log("Actual result is: lRes = " + lRes + "; lDone = " + lDone) + + bOK = bOK AND lRes = NextCharacters(i, 2) + bOK = bOK AND lDone = NextCharacters(i, 3) + next i + + Test.MethodTested("nextCharacters()", bOK) + + Test.StartMethod("previousCharacters()") + bOK = true + nCharacterIteratorMode = com.sun.star.i18n.CharacterIteratorMode.SKIPCHARACTER + + 'Start from position : Travel ... chars : Actual position after : How many chars traveled + PreviousCharacters(0, 0) = 10 : PreviousCharacters(0, 1) = -5000 : PreviousCharacters(0, 2) = len(UnicodeString) : PreviousCharacters(0, 3) = len(UnicodeString) - 10 + PreviousCharacters(1, 0) = 5 : PreviousCharacters(1, 1) = 5000 : PreviousCharacters(1, 2) = 0 : PreviousCharacters(1, 3) = 5 + PreviousCharacters(2, 0) = 10 : PreviousCharacters(2, 1) = 6 : PreviousCharacters(2, 2) = 4 : PreviousCharacters(2, 3) = 6 + + for i = 0 to 2 + lRes = oObj.previousCharacters(UnicodeString, PreviousCharacters(i, 0), _ + oLocale, nCharacterIteratorMode, PreviousCharacters(i, 1), lDone) + Out.Log("Expected result is: lRes = " + PreviousCharacters(i, 2) + _ + "; lDone = " + PreviousCharacters(i, 3)) + Out.Log("Actual result is: lRes = " + lRes + "; lDone = " + lDone) + + bOK = bOK AND lRes = PreviousCharacters(i, 2) + bOK = bOK AND lDone = PreviousCharacters(i, 3) + next i + + Test.MethodTested("previousCharacters()", bOK) + + + Test.StartMethod("nextWord()") + Test.StartMethod("previousWord()") + bOK = true + wordType = com.sun.star.i18n.WordType.ANYWORD_IGNOREWHITESPACES + Dim wordCount1 As Integer + Dim wordCount2 As Integer + wordCount1 = 0 + wordCount2 = 0 + i = 0 + nBoundsToTest = 0 + + while i < len(UnicodeString) - 1 + Boundary = oObj.nextWord(UnicodeString, i, oLocale, wordType) + i = Boundary.endPos - 1 + wordCount1 = wordCount1 + 1 + if ((nBoundsToTest < arrSize) AND (Boundary.endPos - Boundary.startPos > 3)) then + BoundsToTest(nBoundsToTest).startPos = Boundary.startPos + BoundsToTest(nBoundsToTest).endPos = Boundary.endPos ' Here we find out some words and + nBoundsToTest = nBoundsToTest + 1 ' get their bounds to test in future + end if + Out.Log("Word " + wordCount1 + "(" + Boundary.startPos + "," + Boundary.endPos + "): '" + _ + mid(UnicodeString, Boundary.startPos + 1, Boundary.endPos - Boundary.startPos) + "'") + wend + Out.Log("In text there are " + wordCount1 + " words, if count from left to right") + + while i > 0 + Boundary = oObj.previousWord(UnicodeString, i, oLocale, wordType) + i = Boundary.startPos + wordCount2 = wordCount2 + 1 + Out.Log("Word " + wordCount2 + "(" + Boundary.startPos + "," + Boundary.endPos + "): '" + _ + mid(UnicodeString, Boundary.startPos + 1, Boundary.endPos - Boundary.startPos) + "'") + wend + Out.Log("In text there are " + wordCount2 + " words, if count from right to left") + + bOK = bOK AND wordCount1 = wordCount2 + Test.MethodTested("previousWord()", bOK) + Test.MethodTested("nextWord()", bOK) + + Test.StartMethod("getWordBoundary()") + bOK = true + if (nBoundsToTest = 0) then + Out.Log("Couldn't find words longer than 3 letters.") + bOK = false + end if + + for i = 0 to nBoundsToTest - 1 + iPos = (BoundsToTest(i).endPos - BoundsToTest(i).startPos) / 2 + BoundsToTest(i).startPos ' calculate middle of the word + Boundary = oObj.getWordBoundary(UnicodeString, iPos, oLocale, wordType, true) + Out.Log("Expected result is: startPos = " + BoundsToTest(i).startPos + _ + "; endPos = " + BoundsToTest(i).endPos) + Out.Log("Actual result is: startPos = " + Boundary.startPos + "; endPos = " + Boundary.endPos + _ + " Word is: '" + mid(UnicodeString, Boundary.startPos + 1, Boundary.endPos - Boundary.startPos) + "'") + + bOK = bOK AND BoundsToTest(i).startPos = Boundary.startPos + bOK = bOK AND BoundsToTest(i).endPos = Boundary.endPos + next i + + Test.MethodTested("getWordBoundary()", bOK) + + Test.StartMethod("getWordType()") + bOK = true + for i = 0 to nBoundsToTest - 1 + iPos = (BoundsToTest(i).endPos - BoundsToTest(i).startPos) / 2 + BoundsToTest(i).startPos ' calculate middle of the word + wordType = oObj.getWordType(UnicodeString, iPos, oLocale) + bOK = bOK AND wordType >= 0 AND wordType <= 2 + next i + Test.MethodTested("getWordType()", bOK) + + Test.StartMethod("isBeginWord()") + bOK = true + if (nBoundsToTest = 0) then + Out.Log("Couldn't find words longer than 3 letters.") + bOK = false + end if + + for i = 0 to nBoundsToTest - 1 + bOK = bOK AND oObj.isBeginWord(UnicodeString, BoundsToTest(i).startPos, oLocale, com.sun.star.i18n.WordType.ANY_WORD) + bOK = bOK AND NOT oObj.isBeginWord(UnicodeString, BoundsToTest(i).startPos + 1, oLocale, com.sun.star.i18n.WordType.ANY_WORD) + next i + Test.MethodTested("isBeginWord()", bOK) + + Test.StartMethod("isEndWord()") + bOK = true + if (nBoundsToTest = 0) then + Out.Log("Couldn't find words longer than 3 letters.") + bOK = false + end if + + for i = 0 to nBoundsToTest - 1 + bOK = bOK AND oObj.isEndWord(UnicodeString, BoundsToTest(i).endPos, oLocale, com.sun.star.i18n.WordType.ANY_WORD) + bOK = bOK AND NOT oObj.isEndWord(UnicodeString, BoundsToTest(i).endPos - 1, oLocale, com.sun.star.i18n.WordType.ANY_WORD) + next i + Test.MethodTested("isEndWord()", bOK) + + Test.StartMethod("beginOfSentence()") + Test.StartMethod("endOfSentence()") + Dim sStart As Integer + Dim sEnd As Integer + + bOK = true + iPos = 0 + while (iPos <= len(UnicodeString))' AND bOK) + sStart = oObj.beginOfSentence(UnicodeString, iPos, oLocale) + sEnd = oObj.endOfSentence(UnicodeString, iPos, oLocale) + if (iPos < sStart OR iPos > sEnd) then + bOK = false + Out.Log("From position " + iPos + " sentence range is [" + sStart + ", " + sEnd + "]") + Out.Log("'" + mid(UnicodeString, sStart + 1, sEnd - sStart) + "'") + end if + iPos = iPos + 1 + wend + + if (bOK) then + bOK = oObj.beginOfSentence(UnicodeString, -10, oLocale) = -1 + bOK = oObj.endOfSentence(UnicodeString, -10, oLocale) = -1 + bOK = oObj.beginOfSentence(UnicodeString, len(UnicodeString) + 1, oLocale) = -1 + bOK = oObj.endOfSentence(UnicodeString, len(UnicodeString) + 1, oLocale) = -1 + if (NOT bOK) then Out.Log("When invalid position, returned range is NOT [-1, -1]") + end if + + Test.MethodTested("beginOfSentence()", bOK) + Test.MethodTested("endOfSentence()", bOK) + + Test.StartMethod("getLineBreak()") + bOK = true + Dim LineBreakResults As Variant + Dim _LineBreakHyphenationOptions As new com.sun.star.i18n.LineBreakHyphenationOptions + Dim _LineBreakUserOptions As new com.sun.star.i18n.LineBreakUserOptions + Dim breakPos As Long, pos As Long + _LineBreakUserOptions.applyForbiddenRules = false + _LineBreakUserOptions.allowHyphenateEnglish = false + + breakPos = 0 : pos = 0 + + while breakPos = 0 AND pos < len(UnicodeString) + LineBreakResults = oObj.getLineBreak(UnicodeString, pos, oLocale, 0, _LineBreakHyphenationOptions, _LineBreakUserOptions) + breakPos = LineBreakResults.BreakIndex + pos = pos + 1 + wend + + ' finally the position of break must be found in the middle and + ' it must be before the break position specified + bOK = (breakPos <= pos AND breakPos > 0) + + if (NOT bOK) then + Out.Log("The last position was: " + pos + ", and the break position was: " + breakPos) + end if + + Test.MethodTested("getLineBreak()", bOK) + + + Test.StartMethod("beginOfScript()") + Test.StartMethod("endOfScript()") + bOK = true + Out.Log("Searching for scripts...") + iPos = 0 + nBoundsToTest = 0 + + while iPos < len(UnicodeString) AND iPos > -1 AND nBoundsToTest < arrSize + iType = oObj.getScriptType(UnicodeString, iPos) + BoundsToTest(nBoundsToTest).startPos = oObj.beginOfScript(UnicodeString, iPos, iType) + BoundsToTest(nBoundsToTest).endPos = oObj.endOfScript(UnicodeString, iPos, iType) + Types(nBoundsToTest) = iType + iPos = BoundsToTest(nBoundsToTest).endPos + Out.Log("Type: " + iType + "; Bounds: [" + BoundsToTest(nBoundsToTest).startPos + "," + BoundsToTest(nBoundsToTest).endPos + "]") + nBoundsToTest = nBoundsToTest + 1 + wend + bOK = bOK AND nBoundsToTest > 0 + + Test.MethodTested("beginOfScript()", bOK) + Test.MethodTested("endOfScript()", bOK) + + + Test.StartMethod("nextScript()") + bOK = true + i = 1 + iPos = -1 + while i < nBoundsToTest AND bOK + iPos = oObj.nextScript(UnicodeString, iPos, Types(i)) + Out.Log("Expected index for Type " + Types(i) + " for nextScript is " + BoundsToTest(i).startPos) + bOK = bOK AND iPos = BoundsToTest(i).startPos + Out.Log("NextScript returned " + iPos + ";") + i = i + 1 + wend + Test.MethodTested("nextScript()", bOK) + + Test.StartMethod("previousScript()") + bOK = true + i = nBoundsToTest - 2 + iPos = len(UnicodeString) + 1 + while i >= 0 AND bOK + iPos = oObj.previousScript(UnicodeString, iPos, Types(i)) + Out.Log("Expected index for Type " + Types(i) + " for previousScript is " + BoundsToTest(i).startPos) + bOK = bOK AND iPos = BoundsToTest(i).startPos + Out.Log("PreviousScript returned " + iPos + ";") + i = i - 1 + wend + Test.MethodTested("previousScript()", bOK) + + Test.StartMethod("getScriptType()") + bOK = true + for i = 0 to 2 + iPos = oObj.getScriptType(UnicodeString, ScriptType(i, 0)) + Out.Log("Expected result is: ScriptType = " + ScriptType(i, 1)) + Out.Log("Actual result is: ScriptType = " + iPos) + bOK = bOK AND iPos = ScriptType(i, 1) + next i + Test.MethodTested("getScriptType()", bOK) + + Test.StartMethod("beginOfCharBlock()") + Test.StartMethod("endOfCharBlock()") + bOK = true + Out.Log("getting CharBlocks bounds...") + iPos = 0 + nBoundsToTest = 0 + + while iPos < len(UnicodeString) AND iPos > -1 AND nBoundsToTest < arrSize + iType = getCharBlockType(iPos) + BoundsToTest(nBoundsToTest).startPos = oObj.beginOfCharBlock(UnicodeString, iPos, oLocale, iType) + BoundsToTest(nBoundsToTest).endPos = oObj.endOfCharBlock(UnicodeString, iPos, oLocale, iType) + iPos = BoundsToTest(nBoundsToTest).endPos + Out.Log("" + nBoundsToTest + "). Bounds: [" + BoundsToTest(nBoundsToTest).startPos + "," + BoundsToTest(nBoundsToTest).endPos + "]; Type = " + iType) + Types(nBoundsToTest) = iType + nBoundsToTest = nBoundsToTest + 1 + wend + + for i = 0 to nBoundsToTest - 2 + bOK = bOK AND BoundsToTest(i).endPos = BoundsToTest(i + 1).startPos + next + Out.Log("Testing for no intersections : " + bOK) + bOK = bOK AND BoundsToTest(0).startPos = 0 + bOK = bOK AND BoundsToTest(nBoundsToTest - 1).endPos = len(UnicodeString) + Out.Log("Regions should starts with 0 and ends with " + len(UnicodeString)) + + Test.MethodTested("beginOfCharBlock()", bOK) + Test.MethodTested("endOfCharBlock()", bOK) + + Test.StartMethod("nextCharBlock()") + bOK = true + for i = 0 to nBoundsToTest - 1 + iPos = oObj.nextCharBlock(UnicodeString, BoundsToTest(i).startPos - 1, oLocale, Types(i)) + if (iPos <> BoundsToTest(i).startPos) then + bOK = false + Out.Log("nextCharBlock(UnicodeString, " + BoundsToTest(i).startPos - 1 + ", oLocale, " + Types(i) + ") should return " + BoundsToTest(i).startPos) + Out.Log("... and actual value is " + iPos) + end if + next i + Test.MethodTested("nextCharBlock()", bOK) + + Test.StartMethod("previousCharBlock()") + bOK = true + for i = 0 to nBoundsToTest - 1 + iPos = oObj.previousCharBlock(UnicodeString, BoundsToTest(i).endPos + 1, oLocale, Types(i)) + if (iPos <> BoundsToTest(i).startPos) then + bOK = false + Out.Log("previousCharBlock(UnicodeString, " + BoundsToTest(i).startPos - 1 +", oLocale, " + Types(i) + ") should return " + BoundsToTest(i).startPos) + Out.Log("... and actual value is " + iPos) + end if + next i + Test.MethodTested("previousCharBlock()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +Function getCharBlockType(pos As Integer) As Integer + Dim i As Integer + Dim cType As Integer + + cType = 0 + i = 1 + while (i < 31) + if (oObj.beginOfCharBlock(UnicodeString, pos, oLocale, i) <> -1) then + cType = i + i = 100 + end if + i = i + 1 + wend + + getCharBlockType = cType +End Function +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/script.xlb new file mode 100644 index 000000000000..245750532c7b --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XBreakIterator/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XBreakIterator" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XBreakIterator"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba b/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba new file mode 100644 index 000000000000..c3d7befd4987 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba @@ -0,0 +1,306 @@ +<?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_XCalendar" 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.XCalendar +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim oLocaleData As Object + Dim oLocale As Object + Dim allLocales As Variant + Dim allCalendars As Variant + Dim uniqueID As String + Dim oCalendar As Object + Dim dDateTime As Double + Dim aValue As Variant + Dim oldValue As Variant + Dim newValue As Variant + Dim i As Integer + + oLocaleData = createUnoService("com.sun.star.i18n.LocaleData") + allLocales = oLocaleData.getAllInstalledLocaleNames() + Out.Log("Found " + ubound(allLocales) + " Loacales registered in the system") + Randomize + oLocale = allLocales(rnd * ubound(allLocales)) + Out.Log("Choose for testing : " + oLocale.Country) + + Test.StartMethod("getAllCalendars()") + bOK = true + allCalendars = oObj.getAllCalendars(oLocale) + Out.Log("There are " + ubound(allCalendars) + 1 + " calendars for this locale.") + bOK = bOK AND NOT isNULL(allCalendars) + Test.MethodTested("getAllCalendars()", bOK) + + Test.StartMethod("loadDefaultCalendar()") + bOK = true + oObj.loadDefaultCalendar(oLocale) + bOK = bOK AND oObj.getLoadedCalendar().Default + Test.MethodTested("loadDefaultCalendar()", bOK) + + Test.StartMethod("getUniqueID()") + bOK = true + uniqueID = oObj.getUniqueID() + Out.Log("UniqueID for loaded calendar is " + uniqueID) + bOK = bOK AND (uniqueID = allCalendars(0)) + Test.MethodTested("getUniqueID()", bOK) + + Test.StartMethod("loadCalendar()") + bOK = true + oObj.loadCalendar(allCalendars(0), oLocale) + bOK = bOK AND NOT isNULL(oObj.getLoadedCalendar()) + Test.MethodTested("loadCalendar()", bOK) + + Test.StartMethod("getLoadedCalendar()") + bOK = true + oCalendar = oObj.getLoadedCalendar() + Out.Log("Loaded calendar's name is '" + oCalendar.Name + "'") + bOK = bOK AND NOT isNULL(oCalendar) + Test.MethodTested("getLoadedCalendar()", bOK) + + Test.StartMethod("setDateTime()") + Test.StartMethod("getDateTime()") + bOK = true + oObj.setDateTime(12345.25) + dDateTime = oObj.getDateTime() + bOK = bOK AND dDateTime = 12345.25 + Out.Log("Expected: 12345,25; Actual: " + dDateTime) + Test.MethodTested("setDateTime()", bOK) + Test.MethodTested("getDateTime()", bOK) + + Test.StartMethod("getFirstDayOfWeek()") + Test.StartMethod("setFirstDayOfWeek()") + bOK = true + oObj.setFirstDayOfWeek(com.sun.star.i18n.Weekdays.SATURDAY) + Out.Log("Expected: " + com.sun.star.i18n.Weekdays.SATURDAY + ", Actual: " + oObj.getFirstDayOfWeek()) + bOK = bOK AND oObj.getFirstDayOfWeek() = com.sun.star.i18n.Weekdays.SATURDAY + oObj.setFirstDayOfWeek(com.sun.star.i18n.Weekdays.SUNDAY) + Out.Log("Expected: " + com.sun.star.i18n.Weekdays.SUNDAY + ", Actual: " + oObj.getFirstDayOfWeek()) + bOK = bOK AND oObj.getFirstDayOfWeek() = com.sun.star.i18n.Weekdays.SUNDAY + + Test.MethodTested("getFirstDayOfWeek()", bOK) + Test.MethodTested("setFirstDayOfWeek()", bOK) + + Test.StartMethod("setValue()") + Test.StartMethod("getValue()") + bOK = true + bOK = bOK AND TestValue(1, com.sun.star.i18n.Months.JANUARY, 2001, com.sun.star.i18n.WeekDays.MONDAY, 1, 1) + '1.01.2001 - Monday, 1-st week of month, 1-st week of year + bOK = bOK AND TestValue(12, com.sun.star.i18n.Months.JULY, 2001, com.sun.star.i18n.WeekDays.THURSDAY, 2, 28) + '12.07.2001 - Thursday, 2-nd week of month, 28-st week of year + + Test.MethodTested("setValue()", bOK) + Test.MethodTested("getValue()", bOK) + + Test.StartMethod("addValue()") + bOK = true + + bOK = bOK AND TestAddValue("DST_OFFSET", com.sun.star.i18n.CalendarFieldIndex.DST_OFFSET, 1, 0) + bOK = bOK AND TestAddValue("DAY_OF_MONTH", com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 1, 0) + bOK = bOK AND TestAddValue("MONTH", com.sun.star.i18n.CalendarFieldIndex.MONTH, 3, 12) + bOK = bOK AND TestAddValue("YEAR", com.sun.star.i18n.CalendarFieldIndex.YEAR, -1, 0) + bOK = bOK AND TestAddValue("HOUR", com.sun.star.i18n.CalendarFieldIndex.HOUR, 7, 24) + bOK = bOK AND TestAddValue("MINUTE", com.sun.star.i18n.CalendarFieldIndex.MINUTE, 31, 60) + bOK = bOK AND TestAddValue("SECOND", com.sun.star.i18n.CalendarFieldIndex.SECOND, 13, 60) + bOK = bOK AND TestAddValue("MILLISECOND", com.sun.star.i18n.CalendarFieldIndex.MILLISECOND, 67, 1000) + bOK = bOK AND TestAddValue("ERA", com.sun.star.i18n.CalendarFieldIndex.ERA, -1, 0) + + Test.MethodTested("addValue()", bOK) + + Test.StartMethod("getNumberOfMonthsInYear()") + bOK = true + aValue = oObj.getNumberOfMonthsInYear() + Out.Log("There are " + aValue + " months in year") + bOK = bOK AND aValue = 12 + Test.MethodTested("getNumberOfMonthsInYear()", bOK) + + Test.StartMethod("getNumberOfDaysInWeek()") + bOK = true + aValue = oObj.getNumberOfDaysInWeek() + Out.Log("There are " + aValue + " days in week") + bOK = bOK AND aValue = 7 + Test.MethodTested("getNumberOfDaysInWeek()", bOK) + + Test.StartMethod("getMinimumNumberOfDaysForFirstWeek()") + bOK = true + aValue = oObj.getMinimumNumberOfDaysForFirstWeek() + Out.Log("MinimumNumberOfDaysForFirstWeek = " + aValue) + bOK = bOK AND aValue > 0 AND aValue < 8 + Test.MethodTested("getMinimumNumberOfDaysForFirstWeek()", bOK) + + Test.StartMethod("setMinimumNumberOfDaysForFirstWeek()") + bOK = true + oObj.setMinimumNumberOfDaysForFirstWeek(211) + aValue = oObj.getMinimumNumberOfDaysForFirstWeek() + Out.Log("MinimumNumberOfDaysForFirstWeek = " + aValue) + bOK = bOK AND aValue > 0 AND aValue < 8 + Test.MethodTested("setMinimumNumberOfDaysForFirstWeek()", bOK) + + Test.StartMethod("getMonths()") + bOK = true + Dim allMonths As Variant + Dim cAllMonths As String + allMonths = oObj.getMonths() + Out.Log("Returned " + ubound(allMonths) + 1 + " months.") + bOK = bOK AND ubound(allMonths) + 1= oObj.getNumberOfMonthsInYear() + if (bOK) then + cAllMonths = "" + for i = 0 to ubound(allMonths) + cAllMonths = cAllMonths + allMonths(i).FullName + ", " + next i + Out.Log("Months: " + cAllMonths) + end if + + Test.MethodTested("getMonths()", bOK) + + Test.StartMethod("getDays()") + bOK = true + Dim allDays As Variant + Dim cAllDays As String + allDays = oObj.getDays() + Out.Log("Returned " + ubound(allMonths) + 1 + " days.") + bOK = bOK AND ubound(allDays) + 1= oObj.getNumberOfDaysInWeek() + if (bOK) then + cAllDays = "" + for i = 0 to ubound(allDays) + cAllDays = cAllDays + allDays(i).FullName + ", " + next i + Out.Log("Days: " + cAllDays) + end if + Test.MethodTested("getDays()", bOK) + + Test.StartMethod("getDisplayName()") + bOK = true + Dim cDisplayName As String + cDisplayName = oObj.getDisplayName(com.sun.star.i18n.CalendarDisplayIndex.MONTH, com.sun.star.i18n.Months.JANUARY, 1) + Out.Log("Full name for JANUARY is: " + cDisplayName) + bOK = bOK AND cDisplayName <> "" + Test.MethodTested("getDisplayName()", bOK) + + Test.StartMethod("isValid()") + bOK = true + + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 30) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, com.sun.star.i18n.Months.FEBURARY) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, 2001) + Out.Log("isValid() = " + oObj.isValid()) + bOK = bOK AND NOT oObj.isValid() + + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 27) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, com.sun.star.i18n.Months.FEBURARY) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, 2001) + Out.Log("isValid() = " + oObj.isValid()) + bOK = bOK AND oObj.isValid() + + Test.MethodTested("isValid()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub + +Function TestValue(_Day As Integer, _Month As Integer, _Year As Integer, _ + _Day_of_week As Integer, _Week_of_month As Integer, _Week_of_year As Integer) As Boolean + + Dim bOK As Boolean + Dim aDay As Integer, aMonth As Integer, aYear As Integer + Dim aDay_of_week As Integer, aWeek_of_Month As Integer, aWeek_of_year As Integer + + bOK = true + + Out.Log("Set date to " + _Day + "." + _Month + "." + _Year + ";") + + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, _Day) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, _Month) + oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, _Year) + + aDay = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH) + aMonth = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.MONTH) + aYear = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.YEAR) + + Out.Log("Now date is " + aDay + "." + aMonth + "." + aYear + ";") + + bOK = (aDay = _Day) AND (aMonth = _Month) AND (aYear = _Year) + + if (bOK) then + aDay_of_week = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_WEEK) + aWeek_of_month = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.WEEK_OF_MONTH) + aWeek_of_year = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.WEEK_OF_YEAR) + Out.Log("aDay_of_week: Expected: " + _Day_of_week + ", Actual: " + aDay_of_week) + Out.Log("aWeek_of_month: Expected: " + _Week_of_month + ", Actual: " + aWeek_of_month) + Out.Log("aWeek_of_year: Expected: " + _Week_of_year + ", Actual: " + aWeek_of_year) + bOK = (aDay_of_week = _Day_of_week) AND (aWeek_of_month = _Week_of_month) AND (aWeek_of_year = _Week_of_year) + end if + + TestValue() = bOK + +Exit Function +ErrHndl: + Test.Exception() + TestValue() = false +End Function + +Function TestAddValue(valname As String, Idx As Integer, incValue As Integer, valModule As Integer) As Boolean + Dim aValue As Integer + Dim newValue As Integer + Dim bOK As Boolean + + aValue = oObj.getValue(idx) + oObj.addValue(idx, incValue) + newValue = oObj.getValue(idx) + if (valModule = 0) then + bOK = (newValue = (aValue + incValue)) + Out.Log(valname + ": Expected: " + (aValue + incValue) + ", Actual: " + newValue) + else + bOK = (newValue = (aValue + incValue) mod valModule) + Out.Log(valname + ": Expected: " + (aValue + incValue) mod valModule + ", Actual: " + newValue) + end if + TestAddValue() = bOK +Exit Function +ErrHndl: + Test.Exception() + TestAddValue() = false +End Function +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCalendar/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XCalendar/script.xlb new file mode 100644 index 000000000000..2eedd64721be --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCalendar/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XCalendar" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XCalendar"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba new file mode 100644 index 000000000000..d31b612cab49 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba @@ -0,0 +1,223 @@ +<?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_XCharacterClassification" 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.XCharacterClassification +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim sType As Variant + Dim cString1 As String, cString2 As String + Dim cRes As Variant, sDir As Variant + + Const cString = "TestString1" + + Dim Locale As New com.sun.star.lang.Locale + + Locale.Language = "DE" + Locale.Country = "GERMANY" + Locale.Variant = "" + + Test.StartMethod("toUpper()") + bOK = true + cRes = oObj.toUpper(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "STS") + Test.MethodTested("toUpper()", bOK) + + Test.StartMethod("toLower()") + bOK = true + cRes = oObj.toLower(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "sts") + Test.MethodTested("toLower()", bOK) + + Test.StartMethod("toTitle()") + bOK = true + cRes = oObj.toTitle(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "STS") + Test.MethodTested("toTitle()", bOK) + + Test.StartMethod("getType()") + bOK = true + bOK = bOK AND oObj.getType(cString, 0) <> oObj.getType(cString, 2) + Test.MethodTested("getType()", bOK) + + Test.StartMethod("getCharacterDirection()") + bOK = true + sDir = oObj.getCharacterDirection(cString, 1) + bOK = bOK AND isNumeric(sDir) + Test.MethodTested("getCharacterDirection()", bOK) + + Test.StartMethod("getScript()") + bOK = true + bOK = bOK AND isNUmeric(oObj.getScript(cString, 0)) + Test.MethodTested("getScript()", bOK) + + Test.StartMethod("getCharacterType()") + bOK = true + sType = oObj.getCharacterType(cString, 0, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + sType = oObj.getCharacterType(cString, 1, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + sType = oObj.getCharacterType(cString, 10, Locale) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + Test.MethodTested("getCharacterType()", bOK) + + Test.StartMethod("getStringType()") + bOK = true + sType = oObj.getStringType(cString, 0, 10, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + sType = oObj.getStringType(cString, 0, 11, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + Test.MethodTested("getStringType()", bOK) + + Test.StartMethod("parseAnyToken()") + bOK = true + + cString1 = "int _ind1 = 1234;" + Out.Log ("Parsing string: " + cString1) + Dim tTypes(10) As Integer + Dim tVals(10) As String + Dim nStartChartFlags As Variant, userDefinedCharactersStart As Variant + Dim nContCharFlags As Variant, userDefinedCharactersCont As Variant, nTokenType As Variant + + with com.sun.star.i18n.KParseType + tTypes(0) = .IDENTNAME: tVals(0) = "int" + tTypes(1) = .IDENTNAME: tVals(1) = "_ind1" + tTypes(2) = .ONE_SINGLE_CHAR: tVals(2) = "=" + tTypes(3) = .ANY_NUMBER: tVals(3) = "1234" + end with + + with com.sun.star.i18n.KParseTokens + nStartChartFlags = .ANY_ALPHA OR .IGNORE_LEADING_WS + userDefinedCharactersStart = "_" + nContCharFlags = nStartChartFlags OR .ANY_ALNUM + userDefinedCharactersCont = "" + end with + + Dim nStart As Integer, idx As Integer, nPos As Integer + Dim pRes As Variant + Dim cActStr As String + + nStart = 1 + idx = 0 + + while nStart < Len(cString1) + pRes = oObj.parseAnyToken(cString1, nStart - 1, Locale, nStartChartFlags, userDefinedCharactersStart, _ + nContCharFlags, userDefinedCharactersCont) + + Out.Log("Type is " + pRes.TokenType) + if (pRes.TokenType = 0) then + nStart = nStart + 1 + else + Out.Log("Type is as expexted - " + ((pRes.TokenType AND tTypes(idx)) > 0)) + bOK = bOK AND (pRes.TokenType AND tTypes(idx)) + cActStr = mid(cString1, (nStart + pRes.LeadingWhiteSpace), pRes.EndPos - (nStart + pRes.LeadingWhiteSpace) + 1) + Out.Log("Expected: '" + tVals(idx) + "'; actual is: '" + cActStr + "'") + bOK = bOK AND (cActStr = tVals(idx)) + nStart = pRes.EndPos + 1 + end if + idx = idx + 1 + wend + Test.MethodTested("parseAnyToken()", bOK) + + Test.StartMethod("parsePredefinedToken()") + bOK = true + + cString2 = "1a, _a1$5" + with com.sun.star.i18n.KParseType + nTokenType = .IDENTNAME + end with + with com.sun.star.i18n.KParseTokens + nStartChartFlags = .ANY_ALPHA OR .IGNORE_LEADING_WS + userDefinedCharactersStart = "_" + nContCharFlags = nStartChartFlags OR .ANY_ALNUM + userDefinedCharactersCont = "" + end with + + tVals(0) = "a" + tVals(1) = "_a1" + + nPos = 1 + idx = 0 + while nPos < Len(cString2) + pRes = oObj.parsePredefinedToken(nTokenType, cString2, nPos - 1, Locale, nStartChartFlags, userDefinedCharactersStart, _ + nContCharFlags, userDefinedCharactersCont) + + Out.Log("Type is " + pRes.TokenType) + if (pRes.TokenType = 0) then + nPos = nPos + 1 + else + bOK = bOK AND (pRes.TokenType AND tTypes(idx)) + cActStr = mid(cString2, (nPos + pRes.LeadingWhiteSpace), pRes.EndPos - (nPos + pRes.LeadingWhiteSpace) + 1) + bOK = bOK AND Comp(cActStr, tVals(idx)) + nPos = pRes.EndPos + 1 + idx = idx + 1 + end if + wend + + bOK = bOK AND true + Test.MethodTested("parsePredefinedToken()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +Function Comp(cS1 As String, cS2 As String) As Boolean + Out.Log("Expected : '" + cS2 + "', actual : '" + cS1 + "'") + Comp = cS1 = cS2 +End Function +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/script.xlb new file mode 100644 index 000000000000..730b504c245b --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XCharacterClassification" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XCharacterClassification"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCollator/i18n_XCollator.xba b/qadevOOo/tests/basic/ifc/i18n/XCollator/i18n_XCollator.xba new file mode 100644 index 000000000000..4a4f7cc02bac --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCollator/i18n_XCollator.xba @@ -0,0 +1,133 @@ +<?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_XCollator" 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 + +'************************************************************************* +' This Interface/Service test depends on the following GLOBAL variables, +' which must be specified in the object creation: + +' - Global oLocal As Object + +'************************************************************************* + + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XCollator +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim Algorithms As Variant + Dim options As Variant + + Test.StartMethod("listCollatorAlgorithms()") + bOK = true + Algorithms = oObj.listCollatorAlgorithms(oLocale) + Out.Log("Found " + (ubound(Algorithms) + 1) + " algorithms.") + bOK = bOK AND ubound(Algorithms) >= 0 + Test.MethodTested("listCollatorAlgorithms()", bOK) + + Test.StartMethod("loadCollatorAlgorithm()") + bOK = true + options = com.sun.star.i18n.CollatorOptions.CollatorOptions_IGNORE_CASE + oObj.loadCollatorAlgorithm(Algorithms(0), oLocale, options) + bOK = bOK AND oObj.compareString("A", "a") = 0 + oObj.loadCollatorAlgorithm(Algorithms(0), oLocale, 0) + bOK = bOK AND oObj.compareString("A", "a") <> 0 + Test.MethodTested("loadCollatorAlgorithm()", bOK) + + Test.StartMethod("loadDefaultCollator()") + bOK = true + oObj.loadDefaultCollator(oLocale, 0) + bOK = bOK AND oObj.compareString("A", "a") <> 0 + oObj.loadDefaultCollator(oLocale, options) + bOK = bOK AND oObj.compareString("A", "a") = 0 + Test.MethodTested("loadDefaultCollator()", bOK) + + Test.StartMethod("listCollatorOptions()") + bOK = true + options = oObj.listCollatorOptions(Algorithms(0)) + Out.Log("Found " + (ubound(options) + 1) + " options.") + bOK = bOK AND ubound(options) >= 0 + Test.MethodTested("listCollatorOptions()", bOK) + + Test.StartMethod("compareSubstring()") + bOK = true + bOK = bOK AND oObj.compareSubstring("a", 0, 1, "B", 0, 1) = -1 + bOK = bOK AND oObj.compareSubstring("A", 0, 1, "b", 0, 1) = -1 + bOK = bOK AND oObj.compareSubstring("A", 0, 1, "a", 0, 1) = 0 + Test.MethodTested("compareSubstring()", bOK) + + Test.StartMethod("compareString()") + bOK = true + bOK = bOK AND oObj.compareString("a", "B") = -1 + bOK = bOK AND oObj.compareString("A", "b") = -1 + bOK = bOK AND oObj.compareString("A", "a") = 0 + Test.MethodTested("compareString()", bOK) + + Test.StartMethod("loadCollatorAlgorithmWithEndUserOption()") + bOK = true + Dim noOptions() As Integer + Dim optionsArray(0) As Integer + Dim ColAlgorithm As String + + colAlgorithm = "alphanumeric" + Out.Log("Used collation algorithm: "+colAlgorithm) + optionsArray(0) = com.sun.star.i18n.CollatorOptions.CollatorOptions_IGNORE_CASE + oObj.loadCollatorAlgorithmWithEndUserOption(colAlgorithm, oLocale, noOptions()) + bOK = bOK AND oObj.compareString("A", "a") = 1 + bOK = bOK AND oObj.compareString("a", "A") = -1 + bOK = bOK AND oObj.compareString("a", "a") = 0 + oObj.loadCollatorAlgorithmWithEndUserOption(colAlgorithm, oLocale, optionsArray()) + bOK = bOK AND oObj.compareString("A", "a") = 0 + bOK = bOK AND oObj.compareString("a", "A") = 0 + bOK = bOK AND oObj.compareString("a", "a") = 0 + Test.MethodTested("loadCollatorAlgorithmWithEndUserOption()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XCollator/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XCollator/script.xlb new file mode 100644 index 000000000000..0a2236d45ade --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCollator/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XCollator" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XCollator"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/i18n_XIndexEntrySupplier.xba b/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/i18n_XIndexEntrySupplier.xba new file mode 100644 index 000000000000..f1798683fd02 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/i18n_XIndexEntrySupplier.xba @@ -0,0 +1,84 @@ +<?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_XIndexEntrySupplier" 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 + +'************************************************************************* +' This Interface/Service test depends on the following GLOBAL variables, +' which must be specified in the object creation: + +' - Global oLocale As Object + +'************************************************************************* + + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XIndexEntrySupplier +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim entry As String, index As String + + Test.StartMethod("getIndexCharacter()") + bOK = true + entry = "abc" + index = oObj.getIndexCharacter("abc", oLocale, "") + Out.Log("Index key for entry '" + entry + "' is '" + index + "'") + bOK = bOK AND index = "A" OR index = "a" + Test.MethodTested("getIndexCharacter()", bOK) + + Test.StartMethod("getIndexFollowPageWord()") + bOK = true + Out.Log("getIndexFollowPageWord(true, oLocale) returned " + oObj.getIndexFollowPageWord(true, oLocale)) + bOK = bOK AND oObj.getIndexFollowPageWord(true, oLocale) <> "" + Out.Log("getIndexFollowPageWord(false, oLocale) returned " + oObj.getIndexFollowPageWord(false, oLocale)) + bOK = bOK AND oObj.getIndexFollowPageWord(true, oLocale) <> "" + Test.MethodTested("getIndexFollowPageWord()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/script.xlb new file mode 100644 index 000000000000..33a460d62c30 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XIndexEntrySupplier/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XIndexEntrySupplier" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XIndexEntrySupplier"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XLocaleData/i18n_XLocaleData.xba b/qadevOOo/tests/basic/ifc/i18n/XLocaleData/i18n_XLocaleData.xba new file mode 100644 index 000000000000..88c9952fb920 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XLocaleData/i18n_XLocaleData.xba @@ -0,0 +1,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> diff --git a/qadevOOo/tests/basic/ifc/i18n/XLocaleData/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XLocaleData/script.xlb new file mode 100644 index 000000000000..fb7472a9c4ab --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XLocaleData/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XLocaleData" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XLocaleData"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/i18n_XNumberFormatCode.xba b/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/i18n_XNumberFormatCode.xba new file mode 100644 index 000000000000..752e20ab38ae --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/i18n_XNumberFormatCode.xba @@ -0,0 +1,78 @@ +<?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_XNumberFormatCode" 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. +' +'************************************************************************* +'************************************************************************* + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XNumberFormatCode +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + + Dim vLocale As new com.sun.star.lang.Locale + Dim vDefault As Variant + Dim vFormatCode As Variant + + + Test.StartMethod("getDefault()") + vDefault = oObj.getDefault(1, 1, vLocale) + bOK = isNumeric(vDefault.Type) + Test.MethodTested("getDefault()", bOK) + + Test.StartMethod("getFormatCode()") + vFormatCode = oObj.getFormatCode(1, vLocale) + bOK = isNumeric(vFormatCode.Usage) + Test.MethodTested("getFormatCode()", bOK) + + Test.StartMethod("getAllFormatCode()") + vGetAllFormatCode = oObj.getAllFormatCode(1, vLocale) + bOK = uBound(vGetAllFormatCode) + Test.MethodTested("getAllFormatCode()", bOK) + + Test.StartMethod("getAllFormatCodes()") + vGetAllFormatCodes = oObj.getAllFormatCodes(vLocale) + bOK = uBound(vGetAllFormatCodes) + Test.MethodTested("getAllFormatCodes()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/script.xlb new file mode 100644 index 000000000000..3d354daa63ea --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XNumberFormatCode/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XNumberFormatCode" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XNumberFormatCode"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba b/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba new file mode 100644 index 000000000000..faaf0bab69f4 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba @@ -0,0 +1,282 @@ +<?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_XTransliteration" 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. +' +'************************************************************************* +'************************************************************************* + + + +'************************************************************************* +' This Interface/Service test depends on the following GLOBAL variables, +' which must be specified in the object creation: + +' - Global oLocale As Object + +'************************************************************************* + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XTransliteration +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim availableModules As Variant + Dim _string As String + Dim i As Integer + + + Test.StartMethod("getAvailableModules()") + bOK = true + availableModules = oObj.getAvailableModules(oLocale, com.sun.star.i18n.TransliterationModules.UPPERCASE_LOWERCASE) + _string = "" + for i = 0 to ubound(availableModules) + _string = _string + availableModules(i) + "; " + next i + Out.Log("AvailableModules: " + _string) + bOK = bOK AND _string <> "" + Test.MethodTested("getAvailableModules()", bOK) + + Test.StartMethod("loadModuleByImplName()") + bOK = true + oObj.loadModuleByImplName("LOWERCASE_UPPERCASE", oLocale) + Dim module_name As String + module_name = oObj.getName() + out.log("getName return: " + module_name) + bOK = module_name = "lower_to_upper(generic)" + Test.MethodTested("loadModuleByImplName()", bOK) + + Test.StartMethod("getName()") + bOK = true + Out.Log("Module name is " + oObj.getName()) + bOK = bOK AND oObj.getName() <> "" + Test.MethodTested("getName()", bOK) + + Test.StartMethod("getType()") + bOK = true + Out.Log("Type is " + oObj.getType()) + bOK = bOK AND oObj.getType() = 1 ' for UPPERCASE_LOWERCASE it is ONE_TO_ONE + Test.MethodTested("getType()", bOK) + + Test.StartMethod("loadModule()") + bOK = true + oObj.loadModule(com.sun.star.i18n.TransliterationModules.LOWERCASE_UPPERCASE, oLocale) + bOK = bOK AND oObj.getType = com.sun.star.i18n.TransliterationType.ONE_TO_ONE + Test.MethodTested("loadModule()", bOK) + + Test.StartMethod("loadModulesByImplNames()") + bOK = true + Dim Names(0) As String + Names(0) = "UPPERCASE_LOWERCASE" + oObj.loadModulesByImplNames(Names(), oLocale) + module_name = oObj.getName() + out.log("getName return: " + module_name) + bOK = module_name = "upper_to_lower(generic)" + Test.MethodTested("loadModulesByImplNames()", bOK) + + Test.StartMethod("loadModuleNew()") + bOK = true + Dim ModulesNew(0) As Variant + ModulesNew(0) = com.sun.star.i18n.TransliterationModulesNew.LOWERCASE_UPPERCASE + oObj.loadModuleNew(ModulesNew(), oLocale) + bOK = bOK AND oObj.getType = com.sun.star.i18n.TransliterationType.ONE_TO_ONE + Test.MethodTested("loadModuleNew()", bOK) + + Test.StartMethod("transliterate()") + Dim offset() As Variant + bOK = true + Out.Log("LOWERCASE_UPPERCASE-transliterate part of string 'AaBbCc'") + _string = oObj.transliterate("AaBbCc", 1, 4, offset()) + Out.Log("Result of transliteration: " + _string) + bOK = bOK AND "ABBC" = _string + bOK = bOK AND ubound(offset()) = 3 + for i = 0 to ubound(offset()) + bOK = bOK AND offset(i) = i + 1 + next i + Test.MethodTested("transliterate()", bOK) + + Test.StartMethod("equals()") + bOK = true + Dim Match1 As Variant, Match2 As Variant + bOK = bOK AND oObj.equals("This is an example string to be transliterate", 2, 20, Match1, _ + "IS IS AN EXAMPLE STR", 0, 20, Match2) + Test.MethodTested("equals()", bOK) + + Test.StartMethod("folding()") + bOK = true + _string = oObj.folding("AaBbCc", 1, 4, offset()) + Out.Log("Result of folding: " + _string) + bOK = bOK AND "ABBC" = _string + bOK = bOK AND ubound(offset()) = 3 + for i = 0 to ubound(offset()) + bOK = bOK AND offset(i) = i + 1 + next i + Test.MethodTested("folding()", bOK) + + Test.StartMethod("transliterateRange()") + Dim Result As Variant + bOK = true + oObj.loadModule(com.sun.star.i18n.TransliterationModules.IGNORE_CASE, _Locale) + Result = oObj.transliterateRange("a", "c") + for i = 0 to ubound(Result) + Out.Log(Result(i)) + next i + bOK = bOK AND ubound(Result()) = 3 AND _ + ((Result(0) = "a" AND Result(1) = "c" AND Result(2) = "A" AND Result(3) = "C" ) OR _ + (Result(0) = "A" AND Result(1) = "C" AND Result(2) = "a" AND Result(3) = "c" )) + Test.MethodTested("transliterateRange()", bOK) + + Test.StartMethod("compareString()") + oObj.loadModule(com.sun.star.i18n.TransliterationModules.LOWERCASE_UPPERCASE, _Locale) + bOK = true + bOK = bOK AND testString("", "", 0) + bOK = bOK AND testString("a", "", 1) + bOK = bOK AND testString("a", "a", 0) + bOK = bOK AND testString("A", "a", 1) + bOK = bOK AND testString("b", "a", 1) + bOK = bOK AND testString(chr(10), chr(10), 0) + bOK = bOK AND testString(chr(10), chr(9), 1) + bOK = bOK AND testString("aaa", "aaa", 0) + bOK = bOK AND testString("aaA", "aaa", 1) + bOK = bOK AND testString("aaa", "aa", 1) + bOK = bOK AND testString("ab", "aaa", 1) + bOK = bOK AND testString("aba", "aa", 1) + bOK = bOK AND testString("aaa" + chr(10) + chr(9) + "a", "aaa" + chr(10) + chr(9) + "a", 0) + bOK = bOK AND testString("aaa" + chr(9) + chr(10) + "b", "aaa" + chr(9) + chr(10) + "a", 1) + Test.MethodTested("compareString()", bOK) + + Test.StartMethod("compareSubstring()") + bOK = true + ' substrings below must be equal + bOK = bOK AND testSubstring("", 0, 0, "", 0, 0, 0) + bOK = bOK AND testSubstring("aa", 1, 0, "", 0, 0, 0) + bOK = bOK AND testSubstring("aa", 1, 0, "aa", 2, 0, 0) + bOK = bOK AND testSubstring("a", 0, 1, "a", 0, 1, 0) + bOK = bOK AND testSubstring("ab", 0, 2, "ab", 0, 2, 0) + bOK = bOK AND testSubstring("abc", 1, 2, "abc", 1, 2, 0) + bOK = bOK AND testSubstring("abcdef", 0, 3, "123abc", 3, 3, 0) + bOK = bOK AND testSubstring("abcdef", 1, 1, "123abc", 4, 1, 0) + + ' substrings below must NOT be equal + bOK = bOK AND testSubstring("a", 0, 1, "a", 0, 0, 1) + bOK = bOK AND testSubstring("aaa", 1, 1, "", 0, 0, 1) + bOK = bOK AND testSubstring("bbb", 2, 1, "aaa", 2, 1, 1) + bOK = bOK AND testSubstring("abc", 0, 3, "abc", 0, 2, 1) + bOK = bOK AND testSubstring("bbc", 1, 2, "bbc", 0, 2, 1) + + Test.MethodTested("compareSubstring()", bOK) +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub + +Function testString(str1 As String, str2 As String, expRes As Integer) As Boolean + if expRes = 0 then + testString = testStringCommon(str1, str2, expRes, false) + else + testString = testStringCommon(str1, str2, expRes, true) + end if +End Function + +Function testStringCommon(str1 As String, str2 As String, expRes As Integer, testReverse As Boolean) As Boolean + Dim res As Integer + + testStringCommon = true + + res = -666 + + res = oObj.compareString(str1, str2) + + if res = expRes then + Out.Log("Comparing of '" + str1 + "' and '" + str2 + "' OK" ) + else + Out.Log("Comparing of '" + str1 + "' and '" + str2 + _ + "' FAILED; return: " + res + ", expected: " + expRes) + testStringCommon = false + end if + + if NOT testReverse then + Exit Function + end if + + res = -666 + + res = oObj.compareString(str2, str1) + + if res = -expRes then + Out.Log("Comparing of '" + str2 + "' and '" + str1 + "' OK" ) + else + Out.Log("Comparing of '" + str2 + "' and '" + str1 + _ + "' FAILED; return: " + res + ", expected: " + -expRes) + testStringCommon = false + end if +End Function + +Function testSubstring(str1 As String, p1 As Integer, len1 As Integer, _ + str2 As String, p2 As Integer, len2 As Integer, expRes As Integer) As Boolean + + testSubstring = true + + Dim res As Integer + res = -666 + + res = oObj.compareSubstring(str1, p1, len1, str2, p2, len2) + + if res <> expRes then + Out.Log("Comparing FAILED; return: " + res + ", expected: " + expRes + " ") + testSubstring = false + else + Out.Log("Comparing OK : ") + end if + Out.Log("('" + str1 + "', " + p1 + ", " + len1 + ", '" + _ + str2 + "', " + p2 + ", " + len2 + ")") + + res = -666 + + res = oObj.compareSubstring(str2, p2, len2, str1, p1, len1) + + if res <> -expRes then + Out.Log("Comparing FAILED; return: " + res + ", expected: " + _ + -expRes + " ") + testSubstring = false + else + Out.Log("Comparing OK :") + end if + Out.Log("('" + str2 + "', " + p2 + ", " + len2 + ", '" + _ + str1 + "', " + p1 + ", " + len1 + ")") +End Function +</script:module> diff --git a/qadevOOo/tests/basic/ifc/i18n/XTransliteration/script.xlb b/qadevOOo/tests/basic/ifc/i18n/XTransliteration/script.xlb new file mode 100644 index 000000000000..ea5ecbba7158 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XTransliteration/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="i18n_XTransliteration" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="i18n_XTransliteration"/> +"</library:library> |