1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="drawing_XShape" script:language="StarBasic"> 4*b1cdbd2cSJim Jagielski 5*b1cdbd2cSJim Jagielski 6*b1cdbd2cSJim Jagielski'************************************************************************* 7*b1cdbd2cSJim Jagielski' 8*b1cdbd2cSJim Jagielski' Licensed to the Apache Software Foundation (ASF) under one 9*b1cdbd2cSJim Jagielski' or more contributor license agreements. See the NOTICE file 10*b1cdbd2cSJim Jagielski' distributed with this work for additional information 11*b1cdbd2cSJim Jagielski' regarding copyright ownership. The ASF licenses this file 12*b1cdbd2cSJim Jagielski' to you under the Apache License, Version 2.0 (the 13*b1cdbd2cSJim Jagielski' "License"); you may not use this file except in compliance 14*b1cdbd2cSJim Jagielski' with the License. You may obtain a copy of the License at 15*b1cdbd2cSJim Jagielski' 16*b1cdbd2cSJim Jagielski' http://www.apache.org/licenses/LICENSE-2.0 17*b1cdbd2cSJim Jagielski' 18*b1cdbd2cSJim Jagielski' Unless required by applicable law or agreed to in writing, 19*b1cdbd2cSJim Jagielski' software distributed under the License is distributed on an 20*b1cdbd2cSJim Jagielski' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*b1cdbd2cSJim Jagielski' KIND, either express or implied. See the License for the 22*b1cdbd2cSJim Jagielski' specific language governing permissions and limitations 23*b1cdbd2cSJim Jagielski' under the License. 24*b1cdbd2cSJim Jagielski' 25*b1cdbd2cSJim Jagielski'************************************************************************* 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski' Be sure that all variables are dimensioned: 32*b1cdbd2cSJim Jagielskioption explicit 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim JagielskiSub RunTest() 37*b1cdbd2cSJim Jagielski 38*b1cdbd2cSJim Jagielski'************************************************************************* 39*b1cdbd2cSJim Jagielski' INTERFACE: 40*b1cdbd2cSJim Jagielski' com.sun.star.drawing.XShape 41*b1cdbd2cSJim Jagielski'************************************************************************* 42*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl 43*b1cdbd2cSJim Jagielski Dim bOK As Boolean 44*b1cdbd2cSJim Jagielski Dim oPosition As Object 45*b1cdbd2cSJim Jagielski Dim oSetPos As New com.sun.star.awt.Point 46*b1cdbd2cSJim Jagielski Dim objPosition As Object 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski Dim oSize As Object 49*b1cdbd2cSJim Jagielski Dim oSetSize As New com.sun.star.awt.Size 50*b1cdbd2cSJim Jagielski Dim objSize As Object 51*b1cdbd2cSJim Jagielski Dim bRO As Boolean 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski Test.StartMethod("setPosition()") 55*b1cdbd2cSJim Jagielski Test.StartMethod("getPosition()") 56*b1cdbd2cSJim Jagielski 57*b1cdbd2cSJim Jagielski bOK = true 58*b1cdbd2cSJim Jagielski 59*b1cdbd2cSJim Jagielski if (cObjectName = "sw.SwXTextEmbeddedObject") OR _ 60*b1cdbd2cSJim Jagielski (cObjectName = "sw.SwXTextGraphicObject") OR _ 61*b1cdbd2cSJim Jagielski (cObjectName = "sw.SwXTextFrame") OR _ 62*b1cdbd2cSJim Jagielski (cObjectName = "svx.SvxShapeConnector") then 63*b1cdbd2cSJim Jagielski Out.Log("Methods get/setPosition doesn't work with this object.") 64*b1cdbd2cSJim Jagielski else 65*b1cdbd2cSJim Jagielski oPosition = oObj.getPosition() 66*b1cdbd2cSJim Jagielski Out.Log("Current object's position (" + oPosition.X + ", " + oPosition.Y + ")") 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski oSetPos.X = 1234 69*b1cdbd2cSJim Jagielski oSetPos.Y = 4321 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielski Out.Log("Trying to set object's position to (" + oSetPos.X + ", " + oSetPos.Y + ")") 72*b1cdbd2cSJim Jagielski oObj.setPosition(oSetPos) 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski objPosition = oObj.getPosition() 75*b1cdbd2cSJim Jagielski Out.Log("Actual position is (" + objPosition.X + ", " + objPosition.Y + ")") 76*b1cdbd2cSJim Jagielski 77*b1cdbd2cSJim Jagielski 78*b1cdbd2cSJim Jagielski bOK = bOK AND ((abs(objPosition.X - oSetPos.X) <= 1) AND (abs(objPosition.Y - oSetPos.Y) <= 1)) 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski Out.Log("Return previous position...") 81*b1cdbd2cSJim Jagielski oObj.setPosition(oPosition) 82*b1cdbd2cSJim Jagielski end if 83*b1cdbd2cSJim Jagielski 84*b1cdbd2cSJim Jagielski Test.MethodTested("getPosition()", bOK) 85*b1cdbd2cSJim Jagielski Test.MethodTested("setPosition()", bOK) 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski Test.StartMethod("setSize()") 89*b1cdbd2cSJim Jagielski Test.StartMethod("getSize()") 90*b1cdbd2cSJim Jagielski bOK = true 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski bRO = (cObjectName = "sch.ChartLegend") OR _ 93*b1cdbd2cSJim Jagielski (cObjectName = "sch.ChartTitle") OR _ 94*b1cdbd2cSJim Jagielski (cObjectName = "svx.SvxShapeConnector") 95*b1cdbd2cSJim Jagielski if (bRO) then 96*b1cdbd2cSJim Jagielski Out.Log("Size cannot be changed for this object.") 97*b1cdbd2cSJim Jagielski end if 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski oSize = oObj.getSize() 100*b1cdbd2cSJim Jagielski Out.Log("Current object's size (" + oSize.Width + " x " + oSize.Height + ")") 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski oSetSize.Width = 1235 103*b1cdbd2cSJim Jagielski oSetSize.Height = 4322 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski Out.Log("Trying to set object's size to (" + oSetSize.Width + " x " + oSetSize.Height + ")") 106*b1cdbd2cSJim Jagielski oObj.setSize(oSetSize) 107*b1cdbd2cSJim Jagielski objSize = oObj.getSize() 108*b1cdbd2cSJim Jagielski Out.Log("Actual size is (" + objSize.Width + " x " + objSize.Height + ")") 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski if (bRO) then 111*b1cdbd2cSJim Jagielski bOK = bOK AND ((abs(objSize.Width - oSize.Width) <= 1) AND (abs(objSize.Height - oSize.Height) <= 1)) 112*b1cdbd2cSJim Jagielski else 113*b1cdbd2cSJim Jagielski bOK = bOK AND ((abs(objSize.Width - oSetSize.Width) <= 1) AND (abs(objSize.Height - oSetSize.Height) <= 1)) 114*b1cdbd2cSJim Jagielski end if 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski Out.Log("Return previous size...") 117*b1cdbd2cSJim Jagielski oObj.setSize(oSize) 118*b1cdbd2cSJim Jagielski 119*b1cdbd2cSJim Jagielski Test.MethodTested("getSize()", bOK) 120*b1cdbd2cSJim Jagielski Test.MethodTested("setSize()", bOK) 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim JagielskiExit Sub 123*b1cdbd2cSJim JagielskiErrHndl: 124*b1cdbd2cSJim Jagielski Test.Exception() 125*b1cdbd2cSJim Jagielski bOK = false 126*b1cdbd2cSJim Jagielski resume next 127*b1cdbd2cSJim JagielskiEnd Sub 128*b1cdbd2cSJim Jagielski</script:module> 129