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="sd_SdUnoPresView" 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
36' REQUIRED VARIABLES for interface/service tests:
37
38' Required for frame.XController
39Global oFrameToAttach As Object
40Global oModelToAttach As Object
41Global bHasNoViewData As Boolean
42Global oObjToSuspend As Object
43Global bHasNoModel As Boolean
44
45' Required for lang.XComponent
46Global oComponentInstance As Object
47
48' Required for frame.XDispatchProvider
49Global dispatchUrl As String
50
51' Required for drawing.XDrawView
52Global oPages As Variant
53
54' Required for awt.XWindow
55Global oXWindow As Object
56Global oCtrlShape as Object
57
58Global oSecDoc As Object
59
60
61Sub CreateObj()
62
63'*************************************************************************
64' COMPONENT:
65' sd.SdUnoPresView
66'*************************************************************************
67On Error Goto ErrHndl
68    Dim bOK As Boolean
69    Dim oDP As Object, oDP1 As Object
70    Dim oDPs As Object
71    bOK = true
72
73    oDoc = utils.createImpressDocument(cObjectName)
74    oSecDoc = utils.createImpressDocument(cObjectName+"1")
75    wait(500)
76
77    oDPs = oDoc.getDrawPages()
78    oDP = oDPs.getByIndex(0)
79    oDPs.insertNewByIndex(0)
80    oDP1 = oDPs.getByIndex(1)
81
82    addShape(oDP, 1000, 1000, "Rectangle")
83    addShape(oDP, 5000, 5000, "Ellipse")
84
85    oObj = oDoc.getCurrentController()
86
87    ' For XDrawPages
88    oPages = oDoc.getDrawPages()
89
90    ' For XComponent
91    oComponentInstance = oObj
92
93    ' For XDispatchProvider
94    dispatchUrl = "slot:27009"
95
96    ' For frame.XController
97    oFrameToAttach = StarDesktop.getCurrentFrame()
98    oModelToAttach = oSecDoc
99    bHasNoViewData = false
100    bHasNoModel = false
101    oObjToSuspend = oObj
102
103    ' For awt.XWindow
104    oXWindow = utils.at_getCurrentWindow(oSecDoc)
105
106Exit Sub
107ErrHndl:
108    Test.Exception()
109End Sub
110
111Sub DisposeObj()
112    oDoc.dispose()
113    oSecDoc.dispose()
114End Sub
115
116Sub addShape(oPage as Object, nPosX as Integer, nPosY as Integer, oType As String)
117    Dim aPoint As New com.sun.star.awt.Point
118    Dim aSize As New com.sun.star.awt.Size
119    Dim oRectangleShape As Object
120
121    aPoint.x = nPosX
122    aPoint.y = nPosY
123    aSize.Width = 2000
124    aSize.Height = 1000
125    oRectangleShape = oDoc.createInstance("com.sun.star.drawing."+oType+"Shape")
126    oRectangleShape.Size = aSize
127    oRectangleShape.Position = aPoint
128    oRectangleShape.FillColor = RGB(128, 255, 0)
129    oPage.add(oRectangleShape)
130End Sub
131
132</script:module>
133