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="form_XReset" 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
31Dim nCB1Val as Integer, nCB2Val As Integer
32
33
34Sub RunTest()
35
36'*************************************************************************
37' INTERFACE:
38' com.sun.star.form.XReset
39'*************************************************************************
40On Error Goto ErrHndl
41    Dim bOK As Boolean
42    Dim oListener1 as Object, oListener2 As Object
43    Dim nCount As Integer
44
45    bOK = true
46    nCount = 0  'oCollection.count
47    nCB1Val = 0
48    nCB2Val = 0
49
50    Out.Log("create two listeners...")
51    oListener1 = createUNOListener("CB1_", "com.sun.star.form.XResetListener")
52    oListener2 = createUNOListener("CB2_", "com.sun.star.form.XResetListener")
53
54    ' add listeners to objectif initialized
55    if NOT (isNull(oListener1)) then
56        oObj.addResetListener(oListener1)
57    end if
58    if NOT (isNull(oListener2)) then
59        oObj.addResetListener(oListener2)
60    end if
61
62
63    Test.StartMethod("addResetListener()")
64    oObj.reset()
65    wait(1000)
66    bOK = bOK AND (nCB1Val = 1) AND (nCB2Val = 1)
67    Test.MethodTested("addResetListener()", bOK)
68
69    Test.StartMethod("removeResetListener()")
70    Out.Log("removing Listener 2")
71    oObj.removeResetListener(oListener2)
72    oObj.reset()
73    wait(1000)
74    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
75    Test.MethodTested("removeResetListener()", bOK)
76
77    Test.StartMethod("reset()")
78    bOK = bOK AND (nCB1Val = 2) AND (nCB2Val = 1)
79    Test.MethodTested("reset()", bOK)
80
81    Out.Log("removing Listener 1")
82    oObj.removeResetListener(oListener1)
83
84Exit Sub
85ErrHndl:
86    Test.Exception()
87    bOK = false
88    resume next
89End Sub
90' callback routine called resetting for listener1
91Sub CB1_resetted
92    Out.Log("Callback CB1 resetted")
93    nCB1Val = nCB1Val + 1
94End Sub' callback routine called resetting for listener2
95
96Sub CB2_resetted
97    Out.Log("Callback CB2 resetted")
98    nCB2Val = nCB2Val + 1
99End Sub
100
101' callback routine is invoked before resetting a component.
102Function CB1_approveReset() as Boolean
103    Out.Log("Callback CB1 approve Reset")
104    CB1_approveReset = true
105end Function
106
107Function CB2_approveReset() as Boolean
108    Out.Log("Callback CB2 approve Reset")
109    CB2_approveReset = true
110end Function
111</script:module>
112