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