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
37' Be sure that all variables are dimensioned:
38option explicit
39
40
41Dim nCB1Val As Integer
42Dim nCB2Val As Integer
43
44
45Sub RunTest()
46
47'*************************************************************************
48' INTERFACE:
49' com.sun.star.util.XRefreshable
50'*************************************************************************
51On Error Goto ErrHndl
52    Dim bOK As Boolean
53    Dim oListener1, oListener2 As Object
54    Dim nCount As Integer
55
56    bOK = true
57    nCount = 0
58    nCB1Val = 0
59    nCB2Val = 0
60
61    Out.Log("Create two listeners...")
62    oListener1 = createUNOListener("CB1_", "com.sun.star.util.XRefreshListener")
63    oListener2 = createUNOListener("CB2_", "com.sun.star.util.XRefreshListener")
64
65    Out.Log("Adding two refresh listeners")
66    oObj.addRefreshListener(oListener1)
67    oObj.addRefreshListener(oListener2)
68
69    Test.StartMethod("addRefreshListener()")
70    bOK = true
71    oObj.refresh()
72    bOK = bOK AND (nCB1Val = 1) AND (nCB2Val = 1)
73    Test.MethodTested("addRefreshListener()", bOK)
74
75    Test.StartMethod("removeRefreshListener()")
76    bOK = true
77    Out.Log("Removing second refresh listener")
78    oObj.removeRefreshListener(oListener2)
79    oObj.refresh()
80    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
81    Test.MethodTested("removeRefreshListener()", bOK)
82
83    Test.StartMethod("refresh()")
84    bOK = true
85    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
86    Test.MethodTested("refresh()", bOK)
87
88    Out.Log("Removing first refresh listener")
89    oObj.removeRefreshListener(oListener1)
90
91Exit Sub
92ErrHndl:
93    Test.Exception()
94    bOK = false
95    resume next
96End Sub
97
98Sub CB1_refreshed()
99  Out.Log("First listener CallBack called")
100  nCB1Val = nCB1Val + 1
101End Sub
102
103Sub CB2_refreshed()
104  Out.Log("Second listener CallBack called")
105  nCB2Val = nCB2Val + 1
106End Sub
107</script:module>
108