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="linguistic2_XLinguServiceManager" 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 38Dim nCB1Val As Long, nCB2Val As Long 39 40 41Sub RunTest() 42 43'************************************************************************* 44' INTERFACE: 45' com.sun.star.linguistic2.XLinguServiceManager 46'************************************************************************* 47On Error Goto ErrHndl 48 Dim bOK As Boolean 49 50 Dim oListener1 As Object 51 Dim oListener2 As Object 52 Dim vLocale As new com.sun.star.lang.Locale 53 Dim aServices As Variant 54 Dim vGetServices As Variant 55 56 vLocale.Language = "en" 57 vLocale.Country = "US" 58 vLocale.Variant = "" 59 60 oListener1 = createUNOListener("CB1_", "com.sun.star.linguistic2.XLinguServiceEventListener") 61 oListener2 = createUNOListener("CB2_", "com.sun.star.linguistic2.XLinguServiceEventListener") 62 nCB1Val = 0 63 nCB2Val = 0 64 65 Test.StartMethod("getSpellChecker()") 66 bOK = true 67 bOK = bOK AND hasUnoInterfaces(oObj.getSpellChecker(), "com.sun.star.linguistic2.XSpellChecker") 68 Test.MethodTested("getSpellChecker()", bOK) 69 70 Test.StartMethod("getHyphenator()") 71 bOK = true 72 bOK = bOK AND hasUnoInterfaces(oObj.getHyphenator(), "com.sun.star.linguistic2.XHyphenator") 73 Test.MethodTested("getHyphenator()", bOK) 74 75 Test.StartMethod("getThesaurus()") 76 bOK = true 77 bOK = bOK AND hasUnoInterfaces(oObj.getThesaurus(), "com.sun.star.linguistic2.XThesaurus") 78 Test.MethodTested("getThesaurus()", bOK) 79 80 Test.StartMethod("addLinguServiceManagerListener()") 81 bOK = true 82 bOK = bOK AND oObj.addLinguServiceManagerListener(oListener1) 83 bOK = bOK AND oObj.addLinguServiceManagerListener(oListener2) 84 Out.Log("oListener1 and oListener2 added => " + bOK ) 85 Test.MethodTested("addLinguServiceManagerListener()", bOK) 86 87 Test.StartMethod("removeLinguServiceManagerListener()") 88 bOK = true 89 bOK = bOK AND oObj.removeLinguServiceManagerListener(oListener2) 90 Out.Log("oListener2 removed => " +bOK) 91 Test.MethodTested("removeLinguServiceManagerListener()", bOK) 92 93 Test.StartMethod("getAvailableServices()") 94 bOK = true 95 aServices = oObj.getAvailableServices("com.sun.star.linguistic2.Thesaurus", vLocale) 96 bOK = bOK AND (uBound(aServices()) > -1) 97 Test.MethodTested("getAvailableServices()", bOK) 98 99 Test.StartMethod("getConfiguredServices()") 100 bOK = true 101 vGetServices = oObj.getConfiguredServices("com.sun.star.linguistic2.Thesaurus", vLocale) 102 bOK = bOK AND (uBound(vGetServices()) > -1) 103 Test.MethodTested("getConfiguredServices()", bOK) 104 105 Test.StartMethod("setConfiguredServices()") 106 Dim vSetServices(0) As String 107 Dim vSetGetServices As Variant 108 bOK = true 109 oObj.setConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale, vSetServices()) 110 vSetGetServices = oObj.getConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale) 111 bOK = bOK AND (uBound(vSetGetServices()) = -1) 112 oObj.setConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale, vGetServices()) 113 Test.MethodTested("setConfiguredServices()", bOK) 114 115Exit Sub 116ErrHndl: 117 Test.Exception() 118 bOK = false 119 resume next 120End Sub 121Sub CB1_processLinguServiceEvent 122 Out.Log("CallBack for Listener1 processLinguServiceEvent was called.") 123 nCB1Val = nCB1Val + 1 124End Sub 125 126Sub CB2_processLinguServiceEvent 127 Out.Log("CallBack for Listener2 processLinguServiceEvent was called.") 128 nCB2Val = nCB2Val + 1 129End Sub 130Sub CB1_ 131 Out.Log("CallBack for Listener1 disposing was called.") 132 nCB1Val = nCB1Val + 1 133End Sub 134 135Sub CB2_disposing 136 Out.Log("CallBack for Listener2 disposing was called.") 137 nCB2Val = nCB2Val + 1 138End Sub 139</script:module> 140