1<?xml version="1.0" encoding="UTF-8"?>
2<script:module xmlns:script="http://openoffice.org/2000/script" script:name="text_XMailMergeBroadcaster" script:language="StarBasic">
3
4'*************************************************************************
5'
6'  Licensed to the Apache Software Foundation (ASF) under one
7'  or more contributor license agreements.  See the NOTICE file
8'  distributed with this work for additional information
9'  regarding copyright ownership.  The ASF licenses this file
10'  to you under the Apache License, Version 2.0 (the
11'  "License"); you may not use this file except in compliance
12'  with the License.  You may obtain a copy of the License at
13'
14'    http://www.apache.org/licenses/LICENSE-2.0
15'
16'  Unless required by applicable law or agreed to in writing,
17'  software distributed under the License is distributed on an
18'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19'  KIND, either express or implied.  See the License for the
20'  specific language governing permissions and limitations
21'  under the License.
22'
23'*************************************************************************
24
25
26
27'*************************************************************************
28' This Interface/Service test depends on the following GLOBAL variables,
29' which must be specified in the object creation:
30
31'	Global FUNCTION XMailMergeEvent()
32'   This function fires an event which causes a listner call
33
34
35'*************************************************************************
36
37' Be sure that all variables are dimensioned:
38option explicit
39
40	Dim bCB1 as Boolean
41	Dim bCB2 as Boolean
42
43
44Sub RunTest()
45
46'*************************************************************************
47' INTERFACE:
48' com.sun.star.text.XMailMergeBroadcaster
49'*************************************************************************
50On Error Goto ErrHndl
51    Dim bOK As Boolean
52	Dim oListener1 as Object
53	Dim oListener2 as Object
54
55    Out.Log("create two listeners")
56    oListener1 = createUNOListener("CB1_", "com.sun.star.text.XMailMergeListener")
57    oListener2 = createUNOListener("CB2_", "com.sun.star.text.XMailMergeListener")
58
59    Test.StartMethod("addMailMergeEventListener()")
60	bCB1 = FALSE
61	bCB2 = FALSE
62	bOK = TRUE
63	oObj.addMailMergeEventListener(oListener1)
64	oObj.addMailMergeEventListener(oListener2)
65    XMailMergeEvent()
66	out.dbg("call oObj.execute()")
67	out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2)
68	bOK = bOK AND bCB1 AND bCB2
69    Test.MethodTested("addMailMergeEventListener()", bOK)
70
71    Test.StartMethod("removeMailMergeEventListener()")
72	bCB1 = FALSE
73	bCB2 = FALSE
74	bOK = TRUE
75	out.dbg("remove Listener1")
76	oObj.removeMailMergeEventListener(oListener1)
77	out.dbg("call oObj.execute()")
78    XMailMergeEvent()
79	out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2)
80	bOK = bOK AND NOT bCB1 AND bCB2
81    Test.MethodTested("removeMailMergeEventListener()", bOK)
82
83
84Exit Sub
85ErrHndl:
86    Test.Exception()
87    bOK = false
88    resume next
89End Sub
90
91Sub CB1_notifyMailMergeEvent()
92	out.dbg("CB1_notifyMailMergeEvent() was clled.")
93	bCB1 = TRUE
94end Sub
95
96Sub CB2_notifyMailMergeEvent()
97	out.dbg("CB2_notifyMailMergeEvent() was clled.")
98	bCB2 = TRUE
99end Sub
100
101</script:module>
102