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