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