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_SdGenericDrawPage" 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 oGrouperCollection AS Object 37Global oCombinerCollection As Object 38Global oBinderCollection As Object 39 40'Required for com.sun.star.drawing.XShapes 41Global oXShapeInstance As Object 'to add/remove 42 43 44Sub CreateObj() 45 46'************************************************************************* 47' COMPONENT: 48' sd.SdGenericDrawPage 49'************************************************************************* 50On Error Goto ErrHndl 51 Dim oDrawPage As Object 52 53 oDoc = utils.createDocument("sdraw", cObjectName) 54 55 oDrawPage = oDoc.DrawPages(0) 56 oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 57 oCombinerCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 58 oBinderCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 59 60 oObj = oDrawPage 61 62 addShape(oObj, 1000, 1000) 63 addShape(oObj, 5000, 5000) 64 addShape(oObj, 2000, 2000) 65 addShape(oObj, 3000, 3000) 66 addShape(oObj, 4000, 4000) 67 addShape(oObj, 5000, 5000) 68 addShape(oObj, 6000, 6000) 69 addShape(oObj, 7000, 7000) 70 71 oGrouperCollection.Add(oObj.getByIndex(0)) 72 oGrouperCollection.Add(oObj.getByIndex(1)) 73 oCombinerCollection.Add(oObj.getByIndex(2)) 74 oCombinerCollection.Add(oObj.getByIndex(3)) 75 oBinderCollection.Add(oObj.getByIndex(4)) 76 oBinderCollection.Add(oObj.getByIndex(5)) 77 78 oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 79Exit Sub 80ErrHndl: 81 Test.Exception() 82End Sub 83 84Sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer) 85 Dim aPoint As New com.sun.star.awt.Point 86 Dim aSize As New com.sun.star.awt.Size 87 Dim oRectangleShape As Object 88 aPoint.x = nPosX 89 aPoint.y = nPosY 90 aSize.Width = 10000 91 aSize.Height = 10000 92 oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 93 oRectangleShape.Size = aSize 94 oRectangleShape.Position = aPoint 95 oRectangleShape.FillColor = RGB(255,0,0) 96 oPage.add(oRectangleShape) 97End Sub 98 99Sub DisposeObj() 100 if hasUnoInterfaces(oDoc, "com.sun.star.lang.XComponent") then 101 oDoc.dispose() 102 end if 103End Sub 104</script:module> 105