merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / basic / ifc / text / TextGraphicObject / text_TextGraphicObject.xba
blobeb085fa2034b595d548499cfbfdc9c9a4f06433f
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="text_TextGraphicObject" script:language="StarBasic">
6 '*************************************************************************
8 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 '
10 ' Copyright 2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: text_TextGraphicObject.xba,v $
16 ' $Revision: 1.3 $
18 ' This file is part of OpenOffice.org.
20 ' OpenOffice.org is free software: you can redistribute it and/or modify
21 ' it under the terms of the GNU Lesser General Public License version 3
22 ' only, as published by the Free Software Foundation.
24 ' OpenOffice.org is distributed in the hope that it will be useful,
25 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ' GNU Lesser General Public License version 3 for more details
28 ' (a copy is included in the LICENSE file that accompanied this code).
30 ' You should have received a copy of the GNU Lesser General Public License
31 ' version 3 along with OpenOffice.org. If not, see
32 ' <http://www.openoffice.org/license.html>
33 ' for a copy of the LGPLv3 License.
35 '*************************************************************************
36 '*************************************************************************
40 ' Be sure that all variables are dimensioned:
41 option explicit
45 Sub RunTest()
47 '*************************************************************************
48 ' SERVICE:
49 ' com.sun.star.text.TextGraphicObject
50 '*************************************************************************
51 On Error Goto ErrHndl
52 Dim bOK As Boolean
55 PropertyTester.TestProperty("ContentProtected")
57 PropertyTester.TestProperty("SurroundContour")
59 PropertyTester.TestProperty("ContourOutside")
61 Test.StartMethod("ContourPolyPolygon")
62 ' Because in additional parameters we must to
63 ' pass an array of values, we need such array.
64 Dim aPParr1(1) As Variant
65 Dim aPol1(3) As new com.sun.star.awt.Point
66 Dim gArr As Variant
68 bOK = true
69 aPol1(0).x = 0 : aPol1(0).y = 0
70 aPol1(1).x = 101 : aPol1(1).y = 0
71 aPol1(2).x = 101 : aPol1(2).y = 101
72 aPol1(3).x = 0 : aPol1(3).y = 101
73 Dim aPol2(3) As new com.sun.star.awt.Point
74 aPol2(0).x = 11 : aPol2(0).y = 11
75 aPol2(1).x = 90 : aPol2(1).y = 11
76 aPol2(2).x = 90 : aPol2(2).y = 90
77 aPol2(3).x = 11 : aPol2(3).y = 90
78 aPParr1(0) = aPol1() : aPParr1(1) = aPol2()
79 oObj.setPropertyValue("ContourPolyPolygon", aPParr1())
80 gArr = oObj.getPropertyValue("ContourPolyPolygon")
82 if isArray(gArr) AND ubound(gArr) &gt;= 1 then
83 Dim aP1 As Variant, aP2 As Variant
85 aP1 = gArr(0)
86 aP2 = gArr(1)
87 bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 0, 4)
88 bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 0, 4)
90 ' One more point must be added to close the polygon
91 bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 4, 1)
92 bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 4, 1)
93 else
94 Out.Log("Returned value is invalid")
95 Out.Log = false
96 endif
98 Test.MethodTested("ContourPolyPolygon", bOK)
100 ' PropertyTester.TestProperty("ContourPolyPolygon",testArr())
102 Dim aCropArr(1) As Variant
103 Dim Crop1 As Object
104 Dim Crop2 As Object
106 Crop1 = createUnoStruct("com.sun.star.text.GraphicCrop")
107 Crop2 = createUnoStruct("com.sun.star.text.GraphicCrop")
109 Crop1.Top = 11 : Crop1.Bottom = 11 : Crop1.Left = 11 : Crop1.Right = 11
110 Crop2.Top = -11 : Crop2.Bottom = 11 : Crop2.Left = -11 : Crop2.Right = 11
112 aCropArr(0) = Crop1 : aCropArr(1) = Crop2
113 PropertyTester.TestProperty("GraphicCrop",aCropArr())
115 PropertyTester.TestProperty("HoriMirroredOnEvenPages")
117 PropertyTester.TestProperty("HoriMirroredOnOddPages")
119 PropertyTester.TestProperty("VertMirrored")
121 PropertyTester.TestProperty("GraphicURL")
123 PropertyTester.TestProperty("GraphicFilter")
125 PropertyTester.TestProperty("ActualSize")
127 Dim oAdjustArr(4) As Integer
128 oAdjustArr(0) = -100
129 oAdjustArr(1) = -50
130 oAdjustArr(2) = 0
131 oAdjustArr(3) = 50
132 oAdjustArr(4) = 100
134 PropertyTester.TestProperty("AdjustLuminance",oAdjustArr())
136 PropertyTester.TestProperty("AdjustContrast",oAdjustArr())
138 PropertyTester.TestProperty("AdjustRed",oAdjustArr())
140 PropertyTester.TestProperty("AdjustGreen",oAdjustArr())
142 PropertyTester.TestProperty("AdjustBlue",oAdjustArr())
144 PropertyTester.TestProperty("Gamma",oAdjustArr())
146 PropertyTester.TestProperty("GraphicIsInverted")
148 PropertyTester.TestProperty("Transparency",oAdjustArr())
150 PropertyTester.TestProperty("GraphicColorMode")
152 PropertyTester.TestProperty("ImageMap")
154 PropertyTester.TestProperty("ActualSize")
156 Exit Sub
157 ErrHndl:
158 Test.Exception()
159 bOK = false
160 resume next
161 End Sub
163 Function comparePointArrays(arr1 As Variant, arr2 As Variant, fromIdx1 As Integer, fromIdx2 As Integer, count As Integer) As Boolean
164 On Error Goto ErrHndl
165 Dim bOK As Boolean
166 Dim i As Integer
168 if NOT isArray(arr1) then
169 Out.Log("First parameter is not Array.")
170 comparePointArrays() = false
171 exit Function
172 endif
174 if NOT isArray(arr2) then
175 Out.Log("Second parameter is not Array.")
176 comparePointArrays() = false
177 exit Function
178 endif
180 if (lbound(arr1) &gt; fromIdx1 OR ubound(arr1) &lt; (fromIdx1 + count - 1)) then
181 Out.Log("Invalid bounds of the first array")
182 comparePointArrays() = false
183 exit Function
184 endif
185 if (lbound(arr2) &gt; fromIdx2 OR ubound(arr2) &lt; (fromIdx2 + count - 1)) then
186 Out.Log("Invalid bounds of the second array")
187 comparePointArrays() = false
188 exit Function
189 endif
191 bOK = true
192 for i = 0 to count - 1
193 if arr1(fromIdx1 + i).x &lt;&gt; arr2(fromIdx2 + i).x OR _
194 arr1(fromIdx1 + i).y &lt;&gt; arr2(fromIdx2 + i).y then
196 Out.Log("Points #" + i + " are different : (" + _
197 arr1(fromIdx1 + i).x + "," + arr1(fromIdx1 + i).y + "), (" + _
198 arr2(fromIdx2 + i).x + "," + arr2(fromIdx2 + i).y + ")."
200 bOK = false
201 end if
202 next i
204 comparePointArrays() = bOK
206 exit Function
207 ErrHndl:
208 Test.Exception()
209 comparePointArrays() = false
210 End Function
211 </script:module>