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_ScDrawPageObj" 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 36Global oXShapeInstance As Object 37 38Global oGrouperCollection As Object 39 40Sub CreateObj() 41 42'************************************************************************* 43' COMPONENT: 44' sc.ScDrawPageObj 45'************************************************************************* 46On Error Goto ErrHndl 47 48 Dim bOK As Boolean 49 Dim oDP as Object 50 bOK = true 51 52 oDoc = utils.createDocument("scalc", cObjectName) 53 oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 54 55 oDP = oDoc.getDrawPages() 56 57 oDP.insertNewByIndex(0) 58 oDP.insertNewByIndex(1) 59 60 oObj = oDP.getByIndex(0) 61 addShape(oObj,1) 62 addShape(oObj,2) 63 addShape(oObj,3) 64 addShape(oObj,4) 65 66 oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 67 oGrouperCollection.Add(oObj.getByIndex(2)) 68 oGrouperCollection.Add(oObj.getByIndex(3)) 69 70Exit Sub 71ErrHndl: 72 Test.Exception() 73End Sub 74 75Function addShape(oPage as Object, no as Integer) As Object 76On Error Goto ErrHndl 77 Dim aPoint As New com.sun.star.awt.Point 78 Dim aSize As New com.sun.star.awt.Size 79 Dim oShape As Object 80 Dim servNames As Variant 81 82 aPoint.x = 1000 * no 83 aPoint.y = 1000 * no 84 aSize.Width = 2000 85 aSize.Height = 1000 86 oShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 87 oShape.Size = aSize 88 oShape.Position = aPoint 89 90 oPage.add(oShape) 91 92 addShapeToDrawDoc() = oShape 93Exit Function 94ErrHndl: 95 Test.Exception() 96End Function 97 98</script:module> 99