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