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="forms_OButtonControl" 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
32' REQUIRED VARIABLES for interface/service tests:
33
34' Required for  com.sun.star.awt.XView:
35  Global oGraphics as Object
36
37' Required for  com.sun.star.lang.XComponent:
38  Global oComponentInstance As Object ' it will be disposed
39
40' Required for  com.sun.star.awt.XControl:
41  Global oContext As Object
42  Global oWinpeer As Object
43  Global oToolkit As Object
44  Global oModel As Object
45
46' Required for  com.sun.star.awt.XWindow:
47  Global oXWindow as Object
48  Global oCtrlShape As Variant
49
50
51Sub CreateObj()
52
53'*************************************************************************
54' COMPONENT:
55' forms.OButtonControl
56'*************************************************************************
57On Error Goto ErrHndl
58
59    Dim bOK As Boolean
60    Dim oShape1 As Object
61    Dim oShape2 As Object
62    Dim oShape3 As Object
63    Dim oCurrCtrl As Object
64    Dim oWin As Object
65    Dim oKit As Object
66    Dim oDevice As Object
67    Dim oDoc2 As Object
68
69    bOK = true
70
71    oDoc = utils.createDocument("swriter", cObjectName)
72
73    Out.Log("try to insert some shapes...")
74    oShape1 = toolkittools.addControlToDefaultForm("CommandButton", 1000, 1000, 2000, 1000)
75    oShape2 = toolkittools.addControlToDefaultForm("CommandButton", 1000, 3000, 2000, 1000)
76    oShape3 = toolkittools.addControlToDefaultForm("TextField", 1000, 5000, 2000, 1000)
77
78    oModel = oShape1.getControl()
79    oCurrCtrl = oDoc.getCurrentController()
80    oWin = oCurrCtrl.getControl(oModel).getPeer()
81    oKit = oWin.getToolkit()
82    oDevice = oKit.createScreenCompatibleDevice(200,200)
83    oGraphics = oDevice.createGraphics()
84
85    oObj = oCurrCtrl.getControl(oModel)
86    oComponentInstance = oCurrCtrl.getControl(oShape2.getControl())
87    oContext = oDoc
88    oWinpeer = oWin
89    oToolkit = oKit
90    oXWindow =  oCurrCtrl.getControl(oShape3.getControl())
91    oCtrlShape = oShape1
92
93Exit Sub
94ErrHndl:
95    Test.Exception()
96End Sub
97'Sub DisposeObj()
98'    'Re-open this document to close it successfully
99'    oDoc2 = utils.createDocument("swriter", cObjectName + "2")
100'    oDoc2.Dispose()
101'End Sub
102</script:module>
103