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_SdMasterPage" 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 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.SdMasterPage 55'************************************************************************* 56On Error Goto ErrHndl 57 Dim oMasterPages As Object 58 59 oDoc = utils.createDocument("sdraw", cObjectName) 60 61 oXShapeInstance = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 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 oMasterPages = oDoc.MasterPages 67 oObj = oMasterPages(0) 68 69 addShape(oObj, 1000, 1000) 70 addShape(oObj, 5000, 5000) 71 addShape(oObj, 2000, 2000) 72 addShape(oObj, 3000, 3000) 73 addShape(oObj, 4000, 4000) 74 addShape(oObj, 5000, 5000) 75 addShape(oObj, 6000, 6000) 76 addShape(oObj, 7000, 7000) 77 78 oGrouperCollection.Add(oObj.getByIndex(0)) 79 oGrouperCollection.Add(oObj.getByIndex(1)) 80 oCombinerCollection.Add(oObj.getByIndex(2)) 81 oCombinerCollection.Add(oObj.getByIndex(3)) 82 oBinderCollection.Add(oObj.getByIndex(4)) 83 oBinderCollection.Add(oObj.getByIndex(5)) 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 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