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="drawing_XShape" 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
41Sub RunTest()
42
43'*************************************************************************
44' INTERFACE:
45' com.sun.star.drawing.XShape
46'*************************************************************************
47On Error Goto ErrHndl
48    Dim bOK As Boolean
49    Dim oPosition As Object
50    Dim oSetPos As New com.sun.star.awt.Point
51    Dim objPosition As Object
52
53    Dim oSize As Object
54    Dim oSetSize As New com.sun.star.awt.Size
55    Dim objSize As Object
56    Dim bRO As Boolean
57
58
59    Test.StartMethod("setPosition()")
60    Test.StartMethod("getPosition()")
61
62    bOK = true
63
64    if (cObjectName = "sw.SwXTextEmbeddedObject") OR _
65       (cObjectName = "sw.SwXTextGraphicObject") OR _
66       (cObjectName = "sw.SwXTextFrame") OR _
67       (cObjectName = "svx.SvxShapeConnector") then
68        Out.Log("Methods get/setPosition doesn't work with this object.")
69    else
70        oPosition = oObj.getPosition()
71        Out.Log("Current object's position (" + oPosition.X + ", " + oPosition.Y + ")")
72
73        oSetPos.X = 1234
74        oSetPos.Y = 4321
75
76        Out.Log("Trying to set object's position to (" + oSetPos.X + ", " + oSetPos.Y + ")")
77        oObj.setPosition(oSetPos)
78
79        objPosition = oObj.getPosition()
80        Out.Log("Actual position is (" + objPosition.X + ", " + objPosition.Y + ")")
81
82
83        bOK = bOK AND ((abs(objPosition.X - oSetPos.X) &lt;= 1) AND (abs(objPosition.Y - oSetPos.Y) &lt;= 1))
84
85        Out.Log("Return previous position...")
86        oObj.setPosition(oPosition)
87    end if
88
89    Test.MethodTested("getPosition()", bOK)
90    Test.MethodTested("setPosition()", bOK)
91
92
93    Test.StartMethod("setSize()")
94    Test.StartMethod("getSize()")
95    bOK = true
96
97    bRO = (cObjectName = "sch.ChartLegend") OR _
98          (cObjectName = "sch.ChartTitle") OR _
99          (cObjectName = "svx.SvxShapeConnector")
100    if (bRO) then
101        Out.Log("Size cannot be changed for this object.")
102    end if
103
104    oSize = oObj.getSize()
105    Out.Log("Current object's size (" + oSize.Width + " x " + oSize.Height + ")")
106
107    oSetSize.Width = 1235
108    oSetSize.Height = 4322
109
110    Out.Log("Trying to set object's size to (" + oSetSize.Width + " x " + oSetSize.Height + ")")
111    oObj.setSize(oSetSize)
112    objSize = oObj.getSize()
113    Out.Log("Actual size is (" + objSize.Width + " x " + objSize.Height + ")")
114
115    if (bRO) then
116        bOK = bOK AND ((abs(objSize.Width - oSize.Width) &lt;= 1) AND (abs(objSize.Height - oSize.Height) &lt;= 1))
117    else
118        bOK = bOK AND ((abs(objSize.Width - oSetSize.Width) &lt;= 1) AND (abs(objSize.Height - oSetSize.Height) &lt;= 1))
119    end if
120
121    Out.Log("Return previous size...")
122    oObj.setSize(oSize)
123
124    Test.MethodTested("getSize()", bOK)
125    Test.MethodTested("setSize()", bOK)
126
127Exit Sub
128ErrHndl:
129    Test.Exception()
130    bOK = false
131    resume next
132End Sub
133</script:module>
134