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