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="svx_SvxDrawPage" 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 38' REQUIRED VARIABLES for interface/service tests: 39 40' Requiered for com.sun.star.container.XNamed 41 Global cNameToSet As String ' "fixed" if name is fixed 42 43' Requiered for com.sun.star.drawing.XShapeGrouper 44 Global oGrouperCollection As Object 'groupable objects 45' Requiered for com.sun.star.drawing.XShapes 46 Global oXShapeInstance As Object 'to add/remove 47' Requiered for com.sun.star.drawing.XShapeCombiner 48 Global oCombinerCollection As Object 49' Requiered for com.sun.star.drawing.XShapeBinder 50 Global oBinderCollection As Object 51 52 53Sub CreateObj() 54 55'************************************************************************* 56' COMPONENT: 57' svx.SvxDrawPage 58'************************************************************************* 59On Error Goto ErrHndl 60 61 Dim bOK As Boolean 62 bOK = true 63 64 oDoc = utils.createDocument("sdraw", cObjectName) 65 66 Dim aPoint As New com.sun.star.awt.Point 67 Dim aSize As New com.sun.star.awt.Size 68 aPoint.x = 100 69 aPoint.y = 200 70 aSize.Width = 3000 71 aSize.Height = 4000 72 oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 73 oXShapeInstance.Size = aSize 74 oXShapeInstance.Position = aPoint 75 oXShapeInstance.FillColor = RGB(255, 0, 0) 76 77 oDrawPage = oDoc.DrawPages(0) 78 oObj = oDrawPage 79 80 oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 81 oCombinerCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 82 oBinderCollection = createUNOService("com.sun.star.drawing.ShapeCollection") 83 84 AddShape(oObj, 100, 200, "com.sun.star.drawing.LineShape") 85 AddShape(oObj, 200, 200, "com.sun.star.drawing.EllipseShape") 86 87 oShape = oObj.getByIndex(0) 88 oGrouperCollection.Add(oShape) 89 oShape = oObj.getByIndex(1) 90 oGrouperCollection.Add(oShape) 91 92 AddShape(oObj, 300, 200, "com.sun.star.drawing.LineShape") 93 AddShape(oObj, 400, 200, "com.sun.star.drawing.EllipseShape") 94 oShape = oObj.getByIndex(2) 95 oCombinerCollection.Add(oShape) 96 oShape = oObj.getByIndex(3) 97 oCombinerCollection.Add(oShape) 98 99 AddShape(oObj, 500, 200, "com.sun.star.drawing.LineShape") 100 AddShape(oObj, 600, 200, "com.sun.star.drawing.EllipseShape") 101 oShape = oObj.getByIndex(4) 102 oBinderCollection.Add(oShape) 103 oShape = oObj.getByIndex(5) 104 oBinderCollection.Add(oShape) 105 106Exit Sub 107ErrHndl: 108 Test.Exception() 109End Sub 110 111sub AddShape(oPage as Object, nPosX, nPosY as Integer, shapeService As String) 112 Dim aPoint As New com.sun.star.awt.Point 113 Dim aSize As New com.sun.star.awt.Size 114 Dim oShape As Object 115 116 aPoint.x = nPosX 117 aPoint.y = nPosY 118 aSize.Width = 10000 119 aSize.Height = 10000 120 oShape = oDoc.createInstance(shapeService) 121 oShape.Size = aSize 122 oShape.Position = aPoint 123 oShape.FillColor = RGB(255, 0, 0) 124 oPage.add(oShape) 125End Sub 126</script:module> 127