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.
10 ' Copyright
2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: text_TextGraphicObject.xba,v $
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:
47 '*************************************************************************
49 ' com.sun.star.text.TextGraphicObject
50 '*************************************************************************
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
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)
>=
1 then
83 Dim aP1 As Variant, aP2 As Variant
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)
94 Out.Log(
"Returned value is invalid")
98 Test.MethodTested(
"ContourPolyPolygon", bOK)
100 ' PropertyTester.TestProperty(
"ContourPolyPolygon",testArr())
102 Dim aCropArr(
1) As Variant
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
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")
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
168 if NOT isArray(arr1) then
169 Out.Log(
"First parameter is not Array.")
170 comparePointArrays() = false
174 if NOT isArray(arr2) then
175 Out.Log(
"Second parameter is not Array.")
176 comparePointArrays() = false
180 if (lbound(arr1)
> fromIdx1 OR ubound(arr1)
< (fromIdx1 + count -
1)) then
181 Out.Log(
"Invalid bounds of the first array")
182 comparePointArrays() = false
185 if (lbound(arr2)
> fromIdx2 OR ubound(arr2)
< (fromIdx2 + count -
1)) then
186 Out.Log(
"Invalid bounds of the second array")
187 comparePointArrays() = false
192 for i =
0 to count -
1
193 if arr1(fromIdx1 + i).x
<> arr2(fromIdx2 + i).x OR _
194 arr1(fromIdx1 + i).y
<> 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 +
")."
204 comparePointArrays() = bOK
209 comparePointArrays() = false