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' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34 35 36Sub RunTest() 37 38'************************************************************************* 39' INTERFACE: 40' com.sun.star.awt.XToolkit 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 45 Test.StartMethod("getDesktopWindow()") 46 bOK = true 47 Dim oWindow As Object 48 oWindow = oObj.getDesktopWindow() 49 Out.Log("Desktop window is NULL : " & isNULL(oWindow)) 50 ' Has "OK" status always, because Desktop component 51 ' currently is not supported as visible. 52 Test.MethodTested("getDesktopWindow()", bOK) 53 54 Test.StartMethod("getWorkArea()") 55 bOK = true 56 Dim oRect As Object 57 oRect = oObj.getWorkArea() 58 Out.Log("WorkArea is NULL : " & isNULL(oRect)) 59 if (NOT isNULL(oRect)) then 60 Out.Log("Returned rectangle is: (" & oRect.X & ", " & oRect.Y & ", " & oRect.Width & ", " & oRect.Height & ")") 61 end if 62 Test.MethodTested("getWorkArea()", bOK) 63 64 Test.StartMethod("createWindow()") 65 bOK = true 66 Dim oWndDescr As new com.sun.star.awt.WindowDescriptor 67 Dim oBounds As new com.sun.star.awt.Rectangle 68 oWndDescr.Type = com.sun.star.awt.WindowClass.TOP 69 oWndDescr.WindowServiceName = "" 70 oWndDescr.ParentIndex = -1 71 oBounds.X = 10 : oBounds.Y = 20 72 oBounds.Width = 110 : oBounds.Height = 120 73 oWndDescr.Bounds = oBounds 74 with com.sun.star.awt.WindowAttribute 75 oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 76 end with 77 78 Dim oWnd As Object 79 oWnd = oObj.createWindow(oWndDescr) 80 Out.Log("Window is NULL : " & isNULL(oWnd)) 81 bOK = bOK AND NOT isNULL(oWnd) 82 if (bOK) then 83 bOK = bOK AND hasUnoInterfaces(oWnd, "com.sun.star.awt.XWindowPeer") 84 if (NOT bOK) then Out.Log("Returned object doesn't support XWindowPeer interface.") 85 end if 86 Test.MethodTested("createWindow()", bOK) 87 88 Test.StartMethod("createWindows()") 89 bOK = true 90 Dim oWndDescrs(1) As Object 91 Dim oWndDescr1 As new com.sun.star.awt.WindowDescriptor 92 Dim oBounds1 As new com.sun.star.awt.Rectangle 93 oWndDescr1.Type = com.sun.star.awt.WindowClass.TOP 94 oWndDescr1.WindowServiceName = "" 95 'oWndDescr1.Parent = 0 96 oWndDescr1.ParentIndex = -1 97 oBounds1.X = 10 : oBounds1.Y = 20 98 oBounds1.Width = 110 : oBounds1.Height = 120 99 oWndDescr1.Bounds = oBounds1 100 with com.sun.star.awt.WindowAttribute 101 oWndDescr1.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 102 end with 103 Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor 104 Dim oBounds2 As new com.sun.star.awt.Rectangle 105 oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP 106 oWndDescr2.WindowServiceName = "" 107 'oWndDescr2.Parent = 0 108 oWndDescr2.ParentIndex = -1 109 oBounds2.X = 10 : oBounds2.Y = 20 110 oBounds2.Width = 110 : oBounds2.Height = 120 111 oWndDescr2.Bounds = oBounds2 112 with com.sun.star.awt.WindowAttribute 113 oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW 114 end with 115 116 oWndDescrs(0) = oWndDescr1 117 oWndDescrs(1) = oWndDescr2 118 119 Dim oWindows As Object 120 121 oWindows = oObj.createWindows(oWndDescrs()) 122 bOK = bOK AND ubound(oWindows) = 1 123 bOK = bOK AND hasUnoInterfaces(oWindows(0), "com.sun.star.awt.XWindowPeer") 124 bOK = bOK AND hasUnoInterfaces(oWindows(1), "com.sun.star.awt.XWindowPeer") 125 126 Test.MethodTested("createWindows()", bOK) 127 128 Test.StartMethod("createScreenCompatibleDevice()") 129 bOK = true 130 Dim oDevice As Object 131 oDevice = oObj.createScreenCompatibleDevice(123, 456) 132 Out.Log("Device is NULL : " & isNULL(oDevice)) 133 bOK = bOK AND NOT isNULL(oDevice) 134 if (bOK) then 135 bOK = bOK AND hasUnoInterfaces(oDevice, "com.sun.star.awt.XDevice") 136 if (NOT bOK) then Out.Log("Returned object doesn't support XDevice interface.") 137 end if 138 Test.MethodTested("createScreenCompatibleDevice()", bOK) 139 140 Test.StartMethod("createRegion()") 141 bOK = true 142 Dim oRegion As Object 143 oRegion = oObj.createRegion() 144 Out.Log("Region is NULL : " & isNULL(oRegion)) 145 bOK = bOK AND NOT isNULL(oRegion) 146 if (bOK) then 147 bOK = bOK AND hasUnoInterfaces(oRegion, "com.sun.star.awt.XRegion") 148 if (NOT bOK) then Out.Log("Returned object doesn't support XRegion interface.") 149 if (bOK) then 150 oRect = oRegion.getBounds 151 Out.Log("Returned region's bounds are: (" & oRect.X & ", " & oRect.Y & ", " & oRect.Width & ", " & oRect.Height & ")") 152 end if 153 end if 154 155 Test.MethodTested("createRegion()", bOK) 156 157Exit Sub 158ErrHndl: 159 Test.Exception() 160 bOK = false 161 resume next 162End Sub 163</script:module> 164