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