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'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35
36' REQUIRED VARIABLES for interface/service tests:
37Global oGrouperCollection AS Object
38Global oCombinerCollection As Object
39Global oBinderCollection As Object
40
41'Required for com.sun.star.drawing.XShapes
42Global oXShapeInstance As Object 'to add/remove
43
44
45Sub CreateObj()
46
47'*************************************************************************
48' COMPONENT:
49' sd.SdMasterPage
50'*************************************************************************
51On Error Goto ErrHndl
52    Dim oMasterPages As Object
53
54    oDoc = utils.createDocument("sdraw", cObjectName)
55
56    oXShapeInstance =  oDoc.createInstance("com.sun.star.drawing.RectangleShape")
57    oGrouperCollection = createUNOService("com.sun.star.drawing.ShapeCollection")
58    oCombinerCollection = createUNOService("com.sun.star.drawing.ShapeCollection")
59    oBinderCollection = createUNOService("com.sun.star.drawing.ShapeCollection")
60
61    oMasterPages = oDoc.MasterPages
62    oObj = oMasterPages(0)
63
64    addShape(oObj, 1000, 1000)
65    addShape(oObj, 5000, 5000)
66    addShape(oObj, 2000, 2000)
67    addShape(oObj, 3000, 3000)
68    addShape(oObj, 4000, 4000)
69    addShape(oObj, 5000, 5000)
70    addShape(oObj, 6000, 6000)
71    addShape(oObj, 7000, 7000)
72
73    oGrouperCollection.Add(oObj.getByIndex(0))
74    oGrouperCollection.Add(oObj.getByIndex(1))
75    oCombinerCollection.Add(oObj.getByIndex(2))
76    oCombinerCollection.Add(oObj.getByIndex(3))
77    oBinderCollection.Add(oObj.getByIndex(4))
78    oBinderCollection.Add(oObj.getByIndex(5))
79Exit Sub
80ErrHndl:
81    Test.Exception()
82End Sub
83
84Sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer)
85    Dim aPoint As New com.sun.star.awt.Point
86    Dim aSize As New com.sun.star.awt.Size
87    Dim oRectangleShape As Object
88
89    aPoint.x = nPosX
90    aPoint.y = nPosY
91    aSize.Width = 10000
92    aSize.Height = 10000
93    oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
94    oRectangleShape.Size = aSize
95    oRectangleShape.Position = aPoint
96    oRectangleShape.FillColor = RGB(255, 0, 0)
97    oPage.add(oRectangleShape)
98End Sub
99
100Sub DisposeObj()
101    if hasUnoInterfaces(oDoc, "com.sun.star.lang.XComponent") then
102        oDoc.dispose()
103    end if
104End Sub
105</script:module>
106