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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9' 10' Copyright 2000, 2010 Oracle and/or its affiliates. 11' 12' OpenOffice.org - a multi-platform office productivity suite 13' 14' This file is part of OpenOffice.org. 15' 16' OpenOffice.org is free software: you can redistribute it and/or modify 17' it under the terms of the GNU Lesser General Public License version 3 18' only, as published by the Free Software Foundation. 19' 20' OpenOffice.org is distributed in the hope that it will be useful, 21' but WITHOUT ANY WARRANTY; without even the implied warranty of 22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23' GNU Lesser General Public License version 3 for more details 24' (a copy is included in the LICENSE file that accompanied this code). 25' 26' You should have received a copy of the GNU Lesser General Public License 27' version 3 along with OpenOffice.org. If not, see 28' <http://www.openoffice.org/license.html> 29' for a copy of the LGPLv3 License. 30' 31'************************************************************************* 32'************************************************************************* 33 34 35 36' Be sure that all variables are dimensioned: 37option explicit 38 39 40' REQUIRED VARIABLES for interface/service tests: 41Global oGrouperCollection AS Object 42Global oCombinerCollection As Object 43Global oBinderCollection As Object 44 45'Required for com.sun.star.drawing.XShapes 46Global oXShapeInstance As Object 'to add/remove 47 48 49Sub CreateObj() 50 51'************************************************************************* 52' COMPONENT: 53' sd.SdGenericDrawPage 54'************************************************************************* 55On Error Goto ErrHndl 56 Dim oDrawPage As Object 57 58 oDoc = utils.createDocument("sdraw", cObjectName) 59 60 oDrawPage = oDoc.DrawPages(0) 61 oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 62 oCombinerCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 63 oBinderCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 64 65 oObj = oDrawPage 66 67 addShape(oObj, 1000, 1000) 68 addShape(oObj, 5000, 5000) 69 addShape(oObj, 2000, 2000) 70 addShape(oObj, 3000, 3000) 71 addShape(oObj, 4000, 4000) 72 addShape(oObj, 5000, 5000) 73 addShape(oObj, 6000, 6000) 74 addShape(oObj, 7000, 7000) 75 76 oGrouperCollection.Add(oObj.getByIndex(0)) 77 oGrouperCollection.Add(oObj.getByIndex(1)) 78 oCombinerCollection.Add(oObj.getByIndex(2)) 79 oCombinerCollection.Add(oObj.getByIndex(3)) 80 oBinderCollection.Add(oObj.getByIndex(4)) 81 oBinderCollection.Add(oObj.getByIndex(5)) 82 83 oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 84Exit Sub 85ErrHndl: 86 Test.Exception() 87End Sub 88 89Sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer) 90 Dim aPoint As New com.sun.star.awt.Point 91 Dim aSize As New com.sun.star.awt.Size 92 Dim oRectangleShape As Object 93 aPoint.x = nPosX 94 aPoint.y = nPosY 95 aSize.Width = 10000 96 aSize.Height = 10000 97 oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 98 oRectangleShape.Size = aSize 99 oRectangleShape.Position = aPoint 100 oRectangleShape.FillColor = RGB(255,0,0) 101 oPage.add(oRectangleShape) 102End Sub 103 104Sub DisposeObj() 105 if hasUnoInterfaces(oDoc, "com.sun.star.lang.XComponent") then 106 oDoc.dispose() 107 end if 108End Sub 109</script:module> 110