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' This Interface/Service test depends on the following GLOBAL variables, 34' which must be specified in the object creation: 35 36' Global FUNCTION XMailMergeEvent() 37' This function fires an event which causes a listner call 38 39 40'************************************************************************* 41 42' Be sure that all variables are dimensioned: 43option explicit 44 45 Dim bCB1 as Boolean 46 Dim bCB2 as Boolean 47 48 49Sub RunTest() 50 51'************************************************************************* 52' INTERFACE: 53' com.sun.star.text.XMailMergeBroadcaster 54'************************************************************************* 55On Error Goto ErrHndl 56 Dim bOK As Boolean 57 Dim oListener1 as Object 58 Dim oListener2 as Object 59 60 Out.Log("create two listeners") 61 oListener1 = createUNOListener("CB1_", "com.sun.star.text.XMailMergeListener") 62 oListener2 = createUNOListener("CB2_", "com.sun.star.text.XMailMergeListener") 63 64 Test.StartMethod("addMailMergeEventListener()") 65 bCB1 = FALSE 66 bCB2 = FALSE 67 bOK = TRUE 68 oObj.addMailMergeEventListener(oListener1) 69 oObj.addMailMergeEventListener(oListener2) 70 XMailMergeEvent() 71 out.dbg("call oObj.execute()") 72 out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2) 73 bOK = bOK AND bCB1 AND bCB2 74 Test.MethodTested("addMailMergeEventListener()", bOK) 75 76 Test.StartMethod("removeMailMergeEventListener()") 77 bCB1 = FALSE 78 bCB2 = FALSE 79 bOK = TRUE 80 out.dbg("remove Listener1") 81 oObj.removeMailMergeEventListener(oListener1) 82 out.dbg("call oObj.execute()") 83 XMailMergeEvent() 84 out.dbg("Listener1: " + bCB1 + " ; Listener2: " + bCB2) 85 bOK = bOK AND NOT bCB1 AND bCB2 86 Test.MethodTested("removeMailMergeEventListener()", bOK) 87 88 89Exit Sub 90ErrHndl: 91 Test.Exception() 92 bOK = false 93 resume next 94End Sub 95 96Sub CB1_notifyMailMergeEvent() 97 out.dbg("CB1_notifyMailMergeEvent() was clled.") 98 bCB1 = TRUE 99end Sub 100 101Sub CB2_notifyMailMergeEvent() 102 out.dbg("CB2_notifyMailMergeEvent() was clled.") 103 bCB2 = TRUE 104end Sub 105 106</script:module> 107