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