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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7'
8' Copyright 2000, 2010 Oracle and/or its affiliates.
9'
10' OpenOffice.org - a multi-platform office productivity suite
11'
12' This file is part of OpenOffice.org.
13'
14' OpenOffice.org is free software: you can redistribute it and/or modify
15' it under the terms of the GNU Lesser General Public License version 3
16' only, as published by the Free Software Foundation.
17'
18' OpenOffice.org is distributed in the hope that it will be useful,
19' but WITHOUT ANY WARRANTY; without even the implied warranty of
20' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21' GNU Lesser General Public License version 3 for more details
22' (a copy is included in the LICENSE file that accompanied this code).
23'
24' You should have received a copy of the GNU Lesser General Public License
25' version 3 along with OpenOffice.org.  If not, see
26' <http://www.openoffice.org/license.html>
27' for a copy of the LGPLv3 License.
28'
29'*************************************************************************
30*****
31'*************************************************************************
32
33'*************************************************************************
34' This Interface/Service test depends on the following GLOBAL variables,
35' which must be specified in the object creation:
36
37'	Global FUNCTION XMailMergeEvent()
38'   This function fires an event which causes a listner call
39
40
41'*************************************************************************
42
43' Be sure that all variables are dimensioned:
44option explicit
45
46	Dim bCB1 as Boolean
47	Dim bCB2 as Boolean
48
49
50Sub RunTest()
51
52'*************************************************************************
53' INTERFACE:
54' com.sun.star.text.XMailMergeBroadcaster
55'*************************************************************************
56On Error Goto ErrHndl
57    Dim bOK As Boolean
58	Dim oListener1 as Object
59	Dim oListener2 as Object
60
61    Out.Log("create two listeners")
62    oListener1 = createUNOListener("CB1_", "com.sun.star.text.XMailMergeListener")
63    oListener2 = createUNOListener("CB2_", "com.sun.star.text.XMailMergeListener")
64
65    Test.StartMethod("addMailMergeEventListener()")
66	bCB1 = FALSE
67	bCB2 = FALSE
68	bOK = TRUE
69	oObj.addMailMergeEventListener(oListener1)
70	oObj.addMailMergeEventListener(oListener2)
71    XMailMergeEvent()
72	out.dbg("call oObj.execute()")
73	out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2)
74	bOK = bOK AND bCB1 AND bCB2
75    Test.MethodTested("addMailMergeEventListener()", bOK)
76
77    Test.StartMethod("removeMailMergeEventListener()")
78	bCB1 = FALSE
79	bCB2 = FALSE
80	bOK = TRUE
81	out.dbg("remove Listener1")
82	oObj.removeMailMergeEventListener(oListener1)
83	out.dbg("call oObj.execute()")
84    XMailMergeEvent()
85	out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2)
86	bOK = bOK AND NOT bCB1 AND bCB2
87    Test.MethodTested("removeMailMergeEventListener()", bOK)
88
89
90Exit Sub
91ErrHndl:
92    Test.Exception()
93    bOK = false
94    resume next
95End Sub
96
97Sub CB1_notifyMailMergeEvent()
98	out.dbg("CB1_notifyMailMergeEvent() was clled.")
99	bCB1 = TRUE
100end Sub
101
102Sub CB2_notifyMailMergeEvent()
103	out.dbg("CB2_notifyMailMergeEvent() was clled.")
104	bCB2 = TRUE
105end Sub
106
107</script:module>
108