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="awt_XTopWindow" 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
42Sub RunTest()
43
44'*************************************************************************
45' INTERFACE:
46' com.sun.star.awt.XTopWindow
47'*************************************************************************
48On Error Goto ErrHndl
49    Dim bOK As Boolean
50    Dim list1 As Object, list2 As Object
51    Dim aDoc As Object
52
53    list1 = createUnoListener("L1_", "com.sun.star.awt.XTopWindowListener")
54    list2 = createUnoListener("L2_", "com.sun.star.awt.XTopWindowListener")
55
56    l1Called = false
57    l2Called = false
58
59    Test.StartMethod("addTopWindowListener()")
60    bOK = true
61
62    oObj.addTopWindowListener(list1)
63    oObj.addTopWindowListener(list2)
64
65    Test.StartMethod("removeTopWindowListener()")
66    oObj.removeTopWindowListener(list1)
67
68    Out.Log("Creating a doc ...")
69    aDoc = utils.createDocument("swriter", "Window On Top")
70    Out.Log("Doc created.")
71    wait(1000)
72
73    Test.StartMethod("toFront()")
74    bOK = true
75    activated = false
76    deactivated = false
77    oObj.toFront()
78    wait(1000)
79    bOK = bOK AND activated AND NOT deactivated
80    Test.MethodTested("toFront()", bOK)
81
82    Test.StartMethod("toBack()")
83    bOK = true
84    activated = false
85    deactivated = false
86    oObj.toBack()
87    wait(1000)
88    bOK = bOK AND deactivated AND NOT activated
89    Test.MethodTested("toBack()", bOK)
90
91    Out.Log("Disposing a doc ...")
92    aDoc.dispose()
93    Out.Log("Doc disposed.")
94    wait(1000)
95
96    bOK = L2Called
97    Test.MethodTested("addTopWindowListener()", bOK)
98    bOK = bOK AND NOT L1Called
99    Test.MethodTested("removeTopWindowListener()", bOK)
100
101    Test.StartMethod("setMenuBar()")
102    bOK = true
103    Dim menu As Object
104    menu = createUnoService("com.sun.star.awt.MenuBar")
105    menu.insertItem(1, "MenuItem", com.sun.star.awt.MenuItemStyle.CHECKABLE, 1)
106    oObj.setMenuBar(menu)
107    Test.MethodTested("setMenuBar()", bOK)
108
109Exit Sub
110ErrHndl:
111    Test.Exception()
112    bOK = false
113    resume next
114End Sub
115
116Dim L1Called As Boolean
117Dim L2Called As Boolean
118
119Dim activated As Boolean
120Dim deactivated As Boolean
121
122Sub L1_windowActivated()
123    L1Called = true
124End Sub
125Sub L1_windowDeactivated()
126    L1Called = true
127End Sub
128
129Sub L2_windowActivated()
130    L2Called = true
131    activated = true
132    Out.Log("Activated ...")
133End Sub
134Sub L2_windowDeactivated()
135    L2Called = true
136    deactivated = true
137    Out.Log("Deactivated ...")
138End Sub
139</script:module>
140