1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="util_XFlushable" script:language="StarBasic"> 4 5 6 '************************************************************************* 7 ' 8 ' Licensed to the Apache Software Foundation (ASF) under one 9 ' or more contributor license agreements. See the NOTICE file 10 ' distributed with this work for additional information 11 ' regarding copyright ownership. The ASF licenses this file 12 ' to you under the Apache License, Version 2.0 (the 13 ' "License"); you may not use this file except in compliance 14 ' with the License. You may obtain a copy of the License at 15 ' 16 ' http://www.apache.org/licenses/LICENSE-2.0 17 ' 18 ' Unless required by applicable law or agreed to in writing, 19 ' software distributed under the License is distributed on an 20 ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21 ' KIND, either express or implied. See the License for the 22 ' specific language governing permissions and limitations 23 ' under the License. 24 ' 25 '************************************************************************* 26 27 28 29 30 31 32 Dim iCB1_flushed As Integer 33 Dim iCB2_flushed As Integer 34 35 36 Sub RunTest() 37 38 '************************************************************************* 39 ' INTERFACE: 40 ' com.sun.star.util.XFlushable 41 '************************************************************************* 42 On Error Goto ErrHndl 43 Dim bOK As Boolean 44 45 Dim oListener1 As Object 46 Dim oListener2 As Object 47 48 oListener1 = createUnoListener("CB1_", "com.sun.star.util.XFlushListener") 49 oListener2 = createUnoListener("CB2_", "com.sun.star.util.XFlushListener") 50 51 Test.StartMethod("addFlushListener()") 52 bOK = true 53 iCB1_flushed = 0 : iCB2_flushed = 0 54 Out.Log("Adding two listeners...") 55 oObj.addFlushListener(oListener1) 56 oObj.addFlushListener(oListener2) 57 oObj.flush() 58 bOK = bOK AND iCB1_flushed = 1 AND iCB2_flushed = 1 59 Test.MethodTested("addFlushListener()", bOK) 60 61 Test.StartMethod("flush()") 62 bOK = true 63 oObj.flush() 64 Test.MethodTested("flush()", bOK) 65 66 Test.StartMethod("removeFlushListener()") 67 bOK = true 68 iCB1_flushed = 0 : iCB2_flushed = 0 69 Out.Log("Removing first listener") 70 oObj.removeFlushListener(oListener1) 71 oObj.flush() 72 bOK = bOK AND iCB1_flushed = 0 AND iCB2_flushed = 1 73 Test.MethodTested("removeFlushListener()", bOK) 74 75 Out.Log("Removing second listener") 76 oObj.removeFlushListener(oListener2) 77 78 Exit Sub 79 ErrHndl: 80 Test.Exception() 81 bOK = false 82 resume next 83 End Sub 84 Sub CB1_flushed(oEvent As Object) 85 iCB1_flushed = iCB1_flushed + 1 86 Out.Log("CallBack function for the first listener was called.") 87 End Sub 88 89 Sub CB2_flushed(oEvent As Object) 90 iCB2_flushed = iCB2_flushed + 1 91 Out.Log("CallBack function for the second listener was called.") 92 End Sub 93 </script:module> 94