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="toolkit_UnoControlContainer" 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' REQUIRED VARIABLES for interface/service tests:
36Global oComponentInstance As Object
37Global oGraphics as Object
38Global oContext as Object
39Global oWinpeer as Object
40Global oToolkit as Object
41Global oModel as Object
42
43Global oXWindow as Object
44Global oCtrlShape as Object
45
46Global oXControl1 as Object
47Global oXControl2 as Object
48
49
50Sub CreateObj()
51
52'*************************************************************************
53' COMPONENT:
54' toolkit.UnoControlContainer
55'*************************************************************************
56On Error Goto ErrHndl
57
58    Dim bOK As Boolean
59    Dim oShape1 As Object
60    Dim oShape2 As Object
61    Dim oShape3 As Object
62    Dim oCurrCtrl As Object
63    Dim oCurrCtrl2 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    oDoc2 = utils.createDocument("swriter", cObjectName &amp; "1")
73
74    oShape1 = createControlShape("CommandButton")
75    oShape2 = createUnoControlShape("CommandButton", "UnoControlButton")
76    oShape3 = createControlShape("TextField")
77
78    ToolkitTools.addShape(oShape1)
79    ToolkitTools.addShape(oShape2)
80    ToolkitTools.addShape(oShape3)
81
82    oObj = createUnoService("com.sun.star.awt.UnoControlContainer")
83    oComponentInstance = createUnoService("com.sun.star.awt.UnoControlContainer")
84
85    oCurrCtrl = oDoc.getCurrentController()
86    oXControl1 = oCurrCtrl.getControl(oShape1.getControl())
87    oXControl2 = oCurrCtrl.getControl(oShape2.getControl())
88
89    oModel = oShape1.getControl()
90    oObj.setModel(oModel)
91    oWin = oCurrCtrl.getControl(oModel).getPeer()
92    oKit = oWin.getToolkit()
93    oContext = oDoc
94    oWinpeer = oWin
95    oToolkit = oKit
96    oXWindow =  oDoc2.getCurrentController().getFrame().getComponentWindow()
97Exit Sub
98ErrHndl:
99    Test.Exception()
100End Sub
101
102Sub DisposeObj()
103    'Re-open this document to close it successfully
104    Dim oDoc2 As Object
105    oDoc2 = utils.createDocument("swriter", cObjectName &amp; "1")
106    oDoc2.Dispose()
107End Sub
108</script:module>
109