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_XLoadable" 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
40
41Sub RunTest()
42
43'*************************************************************************
44' INTERFACE:
45' com.sun.star.form.XLoadable
46'*************************************************************************
47On Error Goto ErrHndl
48    Dim bOK As Boolean
49    Dim bLoaded As Boolean
50    Dim list As Object
51
52    list = createUnoListener("L_", "com.sun.star.form.XLoadListener")
53    initListener()
54
55    Test.StartMethod("isLoaded()")
56    bOK = true
57    bLoaded = oObj.isLoaded()
58    if bLoaded then  oObj.unload()
59    bLoaded = oObj.isLoaded()
60    bOK = bOK AND NOT bLoaded
61    Test.MethodTested("isLoaded()", bOK)
62
63    Test.StartMethod("addLoadListener()")
64    oObj.addLoadListener(list)
65
66    Test.StartMethod("load()")
67    bOK = true
68    oObj.load()
69    bOK = bOK AND oObj.isLoaded()
70    bOK = bOK AND loaded
71    Test.MethodTested("load()", bOK)
72
73    Test.StartMethod("reload()")
74    bOK = true
75    oObj.reload()
76    bOK = bOK AND oObj.isLoaded()
77    bOK = bOK AND reloaded
78    Test.MethodTested("reload()", bOK)
79
80    Test.StartMethod("unload()")
81    bOK = true
82    oObj.unload()
83    bOK = bOK AND NOT oObj.isLoaded()
84    bOK = bOK AND unloaded
85    Test.MethodTested("unload()", bOK)
86
87    bOK = loaded AND reloaded AND reloading AND unloaded AND unloading
88    Test.MethodTested("addLoadListener()", bOK)
89
90    Test.StartMethod("removeLoadListener()")
91    bOK = true
92    oObj.removeLoadListener(list)
93    initListener()
94    oObj.load()
95    bOK = bOK AND NOT loaded
96    Test.MethodTested("removeLoadListener()", bOK)
97
98Exit Sub
99ErrHndl:
100    Test.Exception()
101    bOK = false
102    resume next
103End Sub
104
105Sub initListener()
106    loaded = false
107    reloaded = false
108    reloading = false
109    unloaded = false
110    unloading = false
111End Sub
112
113Dim loaded As Boolean
114Dim reloaded As Boolean
115Dim reloading As Boolean
116Dim unloaded As Boolean
117Dim unloading As Boolean
118
119Sub L_loaded()
120   Out.Log("Listener: loaded")
121   loaded = true
122End Sub
123Sub L_reloaded()
124   Out.Log("Listener: reloaded")
125   reloaded = true
126End Sub
127Sub L_reloading()
128   Out.Log("Listener: reloading")
129   reloading = true
130End Sub
131Sub L_unloaded()
132   Out.Log("Listener: unloaded")
133   unloaded = true
134End Sub
135Sub L_unloading()
136   Out.Log("Listener: unloading")
137   unloading = true
138End Sub
139</script:module>
140