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