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