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