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="frame_XFrameLoader" 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'*************************************************************************
41' This Interface/Service test depends on the following GLOBAL variables,
42' which must be specified in the object creation:
43
44' Global FrameLoaderURL As String
45'Global FrameLoaderFrame As Object ' optional
46'Global FrameLoaderArgs As Variant ' optional
47
48'*************************************************************************
49
50
51
52
53
54Sub RunTest()
55
56'*************************************************************************
57' INTERFACE:
58' com.sun.star.form.XFrameLoader
59'*************************************************************************
60On Error Goto ErrHndl
61    Dim bOK As Boolean
62    Dim frame As Object
63    Dim args As Variant
64    Dim listener As Object
65
66    if IsNULL(FrameLoaderFrame) then
67        Out.log("Frame is NULL")
68        Dim oDsk As Object
69        oDsk = createUnoService("com.sun.star.frame.Desktop")
70        frame = oDsk.getCurrentFrame()
71    else
72        frame = FrameLoaderFrame
73    endif
74
75    if IsArray(FrameLoaderArgs) then
76        Out.log("Args isn't array")
77        Dim emptyAr As Variant
78        args = emptyAr
79    else
80        args = FrameLoaderArgs
81    endif
82
83    listener = createUnoListener("L_", "com.sun.star.frame.XLoadEventListener")
84    initListener()
85
86    Test.StartMethod("cancel()")
87
88    oObj.load(frame, FrameLoaderURL, args, listener)
89    oObj.cancel()
90    wait(200)
91
92    bOK = loadCancelled OR loadFinished
93
94    Test.MethodTested("cancel()", bOK)
95
96    Test.StartMethod("load()")
97
98    initListener()
99    oObj.load(frame, FrameLoaderURL, args, listener)
100    wait(200)
101    bOK = loadFinished AND Not loadCancelled
102
103    Test.MethodTested("load()", bOK)
104Exit Sub
105ErrHndl:
106    Test.Exception()
107    bOK = false
108    resume next
109End Sub
110
111Sub initListener()
112    loadFinished = false
113    loadCancelled = false
114End Sub
115
116Dim loadFinished As Boolean
117Dim loadCancelled As Boolean
118
119Sub L_loadFinished()
120   Out.Log("Listener: loadFinished")
121   loadFinished = true
122End Sub
123
124Sub L_loadCancelled()
125   Out.Log("Listener: loadCancelled")
126   loadCancelled = true
127End Sub
128</script:module>
129