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="sc_ScPageObj" script:language="StarBasic">
4
5'*************************************************************************
6'
7'  Licensed to the Apache Software Foundation (ASF) under one
8'  or more contributor license agreements.  See the NOTICE file
9'  distributed with this work for additional information
10'  regarding copyright ownership.  The ASF licenses this file
11'  to you under the Apache License, Version 2.0 (the
12'  "License"); you may not use this file except in compliance
13'  with the License.  You may obtain a copy of the License at
14'
15'    http://www.apache.org/licenses/LICENSE-2.0
16'
17'  Unless required by applicable law or agreed to in writing,
18'  software distributed under the License is distributed on an
19'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20'  KIND, either express or implied.  See the License for the
21'  specific language governing permissions and limitations
22'  under the License.
23'
24'*************************************************************************
25
26
27
28
29
30' Be sure that all variables are dimensioned:
31option explicit
32
33
34' REQUIRED VARIABLES for interface/service tests:
35
36' "com::sun::star::drawing::XShapes" needs the following Global variables:
37Global oXShapeInstance As Object
38
39' "com::sun::star::drawing::XShapeGrouper" needs the following Global variables:
40Global oGrouperCollection As Object
41
42
43Sub CreateObj()
44
45'*************************************************************************
46' COMPONENT:
47' sc.ScPageObj
48'*************************************************************************
49On Error Goto ErrHndl
50
51    Dim bOK As Boolean
52	Dim oDP as Object
53    bOK = true
54
55    oDoc = utils.createDocument("scalc", cObjectName)
56    oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection")
57
58    oDP = oDoc.getDrawPages()
59
60	oDP.insertNewByIndex(0)
61	oDP.insertNewByIndex(1)
62
63	oObj = oDP.getByIndex(0)
64	addShape(oObj,1)
65	addShape(oObj,2)
66	addShape(oObj,3)
67	addShape(oObj,4)
68
69    oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
70    oGrouperCollection.Add(oObj.getByIndex(2))
71    oGrouperCollection.Add(oObj.getByIndex(3))
72
73Exit Sub
74ErrHndl:
75    Test.Exception()
76End Sub
77
78Function addShape(oPage as Object, no as Integer) As Object
79On Error Goto ErrHndl
80    Dim aPoint As New com.sun.star.awt.Point
81    Dim aSize As New com.sun.star.awt.Size
82    Dim oShape As Object
83    Dim servNames As Variant
84
85    aPoint.x = 1000 * no
86    aPoint.y = 1000 * no
87    aSize.Width = 2000
88    aSize.Height = 1000
89    oShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
90    oShape.Size = aSize
91    oShape.Position = aPoint
92
93    oPage.add(oShape)
94
95    addShapeToDrawDoc() = oShape
96Exit Function
97ErrHndl:
98	Test.Exception()
99End Function
100
101</script:module>
102