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_XRefreshable" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36' Be sure that all variables are dimensioned:
37option explicit
38
39
40Dim nCB1Val As Integer
41Dim nCB2Val As Integer
42
43
44Sub RunTest()
45
46'*************************************************************************
47' INTERFACE:
48' com.sun.star.util.XRefreshable
49'*************************************************************************
50On Error Goto ErrHndl
51    Dim bOK As Boolean
52    Dim oListener1, oListener2 As Object
53    Dim nCount As Integer
54
55    bOK = true
56    nCount = 0
57    nCB1Val = 0
58    nCB2Val = 0
59
60    Out.Log("Create two listeners...")
61    oListener1 = createUNOListener("CB1_", "com.sun.star.util.XRefreshListener")
62    oListener2 = createUNOListener("CB2_", "com.sun.star.util.XRefreshListener")
63
64    Out.Log("Adding two refresh listeners")
65    oObj.addRefreshListener(oListener1)
66    oObj.addRefreshListener(oListener2)
67
68    Test.StartMethod("addRefreshListener()")
69    bOK = true
70    oObj.refresh()
71    bOK = bOK AND (nCB1Val = 1) AND (nCB2Val = 1)
72    Test.MethodTested("addRefreshListener()", bOK)
73
74    Test.StartMethod("removeRefreshListener()")
75    bOK = true
76    Out.Log("Removing second refresh listener")
77    oObj.removeRefreshListener(oListener2)
78    oObj.refresh()
79    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
80    Test.MethodTested("removeRefreshListener()", bOK)
81
82    Test.StartMethod("refresh()")
83    bOK = true
84    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
85    Test.MethodTested("refresh()", bOK)
86
87    Out.Log("Removing first refresh listener")
88    oObj.removeRefreshListener(oListener1)
89
90Exit Sub
91ErrHndl:
92    Test.Exception()
93    bOK = false
94    resume next
95End Sub
96
97Sub CB1_refreshed()
98  Out.Log("First listener CallBack called")
99  nCB1Val = nCB1Val + 1
100End Sub
101
102Sub CB2_refreshed()
103  Out.Log("Second listener CallBack called")
104  nCB2Val = nCB2Val + 1
105End Sub
106</script:module>
107