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