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_XToolkit" 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.awt.XToolkit 46'************************************************************************* 47On Error Goto ErrHndl 48 Dim bOK As Boolean 49 50 Test.StartMethod("getDesktopWindow()") 51 bOK = true 52 Dim oWindow As Object 53 oWindow = oObj.getDesktopWindow() 54 Out.Log("Desktop window is NULL : " & isNULL(oWindow)) 55 ' Has "OK" status always, because Desktop component 56 ' currently is not supported as visible. 57 Test.MethodTested("getDesktopWindow()", bOK) 58 59 Test.StartMethod("getWorkArea()") 60 bOK = true 61 Dim oRect As Object 62 oRect = oObj.getWorkArea() 63 Out.Log("WorkArea is NULL : " & isNULL(oRect)) 64 if (NOT isNULL(oRect)) then 65 Out.Log("Returned rectangle is: (" & oRect.X & ", " & oRect.Y & ", " & oRect.Width & ", " & oRect.Height & ")") 66 end if 67 Test.MethodTested("getWorkArea()", bOK) 68 69 Test.StartMethod("createWindow()") 70 bOK = true 71 Dim oWndDescr As new com.sun.star.awt.WindowDescriptor 72 Dim oBounds As new com.sun.star.awt.Rectangle 73 oWndDescr.Type = com.sun.star.awt.WindowClass.TOP 74 oWndDescr.WindowServiceName = "" 75 oWndDescr.ParentIndex = -1 76 oBounds.X = 10 : oBounds.Y = 20 77 oBounds.Width = 110 : oBounds.Height = 120 78 oWndDescr.Bounds = oBounds 79 with com.sun.star.awt.WindowAttribute 80 oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 81 end with 82 83 Dim oWnd As Object 84 oWnd = oObj.createWindow(oWndDescr) 85 Out.Log("Window is NULL : " & isNULL(oWnd)) 86 bOK = bOK AND NOT isNULL(oWnd) 87 if (bOK) then 88 bOK = bOK AND hasUnoInterfaces(oWnd, "com.sun.star.awt.XWindowPeer") 89 if (NOT bOK) then Out.Log("Returned object doesn't support XWindowPeer interface.") 90 end if 91 Test.MethodTested("createWindow()", bOK) 92 93 Test.StartMethod("createWindows()") 94 bOK = true 95 Dim oWndDescrs(1) As Object 96 Dim oWndDescr1 As new com.sun.star.awt.WindowDescriptor 97 Dim oBounds1 As new com.sun.star.awt.Rectangle 98 oWndDescr1.Type = com.sun.star.awt.WindowClass.TOP 99 oWndDescr1.WindowServiceName = "" 100 'oWndDescr1.Parent = 0 101 oWndDescr1.ParentIndex = -1 102 oBounds1.X = 10 : oBounds1.Y = 20 103 oBounds1.Width = 110 : oBounds1.Height = 120 104 oWndDescr1.Bounds = oBounds1 105 with com.sun.star.awt.WindowAttribute 106 oWndDescr1.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 107 end with 108 Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor 109 Dim oBounds2 As new com.sun.star.awt.Rectangle 110 oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP 111 oWndDescr2.WindowServiceName = "" 112 'oWndDescr2.Parent = 0 113 oWndDescr2.ParentIndex = -1 114 oBounds2.X = 10 : oBounds2.Y = 20 115 oBounds2.Width = 110 : oBounds2.Height = 120 116 oWndDescr2.Bounds = oBounds2 117 with com.sun.star.awt.WindowAttribute 118 oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 119 end with 120 121 oWndDescrs(0) = oWndDescr1 122 oWndDescrs(1) = oWndDescr2 123 124 Dim oWindows As Object 125 126 oWindows = oObj.createWindows(oWndDescrs()) 127 bOK = bOK AND ubound(oWindows) = 1 128 bOK = bOK AND hasUnoInterfaces(oWindows(0), "com.sun.star.awt.XWindowPeer") 129 bOK = bOK AND hasUnoInterfaces(oWindows(1), "com.sun.star.awt.XWindowPeer") 130 131 Test.MethodTested("createWindows()", bOK) 132 133 Test.StartMethod("createScreenCompatibleDevice()") 134 bOK = true 135 Dim oDevice As Object 136 oDevice = oObj.createScreenCompatibleDevice(123, 456) 137 Out.Log("Device is NULL : " & isNULL(oDevice)) 138 bOK = bOK AND NOT isNULL(oDevice) 139 if (bOK) then 140 bOK = bOK AND hasUnoInterfaces(oDevice, "com.sun.star.awt.XDevice") 141 if (NOT bOK) then Out.Log("Returned object doesn't support XDevice interface.") 142 end if 143 Test.MethodTested("createScreenCompatibleDevice()", bOK) 144 145 Test.StartMethod("createRegion()") 146 bOK = true 147 Dim oRegion As Object 148 oRegion = oObj.createRegion() 149 Out.Log("Region is NULL : " & isNULL(oRegion)) 150 bOK = bOK AND NOT isNULL(oRegion) 151 if (bOK) then 152 bOK = bOK AND hasUnoInterfaces(oRegion, "com.sun.star.awt.XRegion") 153 if (NOT bOK) then Out.Log("Returned object doesn't support XRegion interface.") 154 if (bOK) then 155 oRect = oRegion.getBounds 156 Out.Log("Returned region's bounds are: (" & oRect.X & ", " & oRect.Y & ", " & oRect.Width & ", " & oRect.Height & ")") 157 end if 158 end if 159 160 Test.MethodTested("createRegion()", bOK) 161 162Exit Sub 163ErrHndl: 164 Test.Exception() 165 bOK = false 166 resume next 167End Sub 168</script:module> 169