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