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'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31
32Dim nCB1Val As Long, nCB2Val As Long
33
34
35Sub RunTest()
36
37'*************************************************************************
38' INTERFACE:
39' com.sun.star.linguistic2.XLinguServiceManager
40'*************************************************************************
41On Error Goto ErrHndl
42    Dim bOK As Boolean
43
44    Dim oListener1 As Object
45    Dim oListener2 As Object
46    Dim vLocale As new com.sun.star.lang.Locale
47    Dim aServices As Variant
48    Dim vGetServices As Variant
49
50    vLocale.Language = "en"
51    vLocale.Country = "US"
52    vLocale.Variant = ""
53
54    oListener1 = createUNOListener("CB1_", "com.sun.star.linguistic2.XLinguServiceEventListener")
55    oListener2 = createUNOListener("CB2_", "com.sun.star.linguistic2.XLinguServiceEventListener")
56    nCB1Val = 0
57    nCB2Val = 0
58
59    Test.StartMethod("getSpellChecker()")
60    bOK = true
61    bOK = bOK AND hasUnoInterfaces(oObj.getSpellChecker(), "com.sun.star.linguistic2.XSpellChecker")
62    Test.MethodTested("getSpellChecker()", bOK)
63
64    Test.StartMethod("getHyphenator()")
65    bOK = true
66    bOK = bOK AND hasUnoInterfaces(oObj.getHyphenator(), "com.sun.star.linguistic2.XHyphenator")
67    Test.MethodTested("getHyphenator()", bOK)
68
69    Test.StartMethod("getThesaurus()")
70    bOK = true
71    bOK = bOK AND hasUnoInterfaces(oObj.getThesaurus(), "com.sun.star.linguistic2.XThesaurus")
72    Test.MethodTested("getThesaurus()", bOK)
73
74    Test.StartMethod("addLinguServiceManagerListener()")
75    bOK = true
76    bOK = bOK AND oObj.addLinguServiceManagerListener(oListener1)
77    bOK = bOK AND oObj.addLinguServiceManagerListener(oListener2)
78    Out.Log("oListener1 and oListener2 added =&gt; " + bOK )
79    Test.MethodTested("addLinguServiceManagerListener()", bOK)
80
81    Test.StartMethod("removeLinguServiceManagerListener()")
82    bOK = true
83    bOK = bOK AND oObj.removeLinguServiceManagerListener(oListener2)
84    Out.Log("oListener2 removed =&gt; " +bOK)
85    Test.MethodTested("removeLinguServiceManagerListener()", bOK)
86
87    Test.StartMethod("getAvailableServices()")
88    bOK = true
89    aServices = oObj.getAvailableServices("com.sun.star.linguistic2.Thesaurus", vLocale)
90    bOK = bOK AND (uBound(aServices()) &gt; -1)
91    Test.MethodTested("getAvailableServices()", bOK)
92
93    Test.StartMethod("getConfiguredServices()")
94    bOK = true
95    vGetServices = oObj.getConfiguredServices("com.sun.star.linguistic2.Thesaurus", vLocale)
96    bOK = bOK AND (uBound(vGetServices()) &gt; -1)
97    Test.MethodTested("getConfiguredServices()", bOK)
98
99    Test.StartMethod("setConfiguredServices()")
100    Dim vSetServices(0) As String
101    Dim vSetGetServices As Variant
102    bOK = true
103    oObj.setConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale, vSetServices())
104    vSetGetServices = oObj.getConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale)
105    bOK = bOK AND (uBound(vSetGetServices()) = -1)
106    oObj.setConfiguredServices("com.sun.star.linguistic2.Hyphenator", vLocale, vGetServices())
107    Test.MethodTested("setConfiguredServices()", bOK)
108
109Exit Sub
110ErrHndl:
111    Test.Exception()
112    bOK = false
113    resume next
114End Sub
115Sub CB1_processLinguServiceEvent
116    Out.Log("CallBack for Listener1 processLinguServiceEvent was called.")
117    nCB1Val = nCB1Val + 1
118End Sub
119
120Sub CB2_processLinguServiceEvent
121    Out.Log("CallBack for Listener2 processLinguServiceEvent was called.")
122    nCB2Val = nCB2Val + 1
123End Sub
124Sub CB1_
125    Out.Log("CallBack for Listener1 disposing was called.")
126    nCB1Val = nCB1Val + 1
127End Sub
128
129Sub CB2_disposing
130    Out.Log("CallBack for Listener2 disposing was called.")
131    nCB2Val = nCB2Val + 1
132End Sub
133</script:module>
134