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">
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' SERVICE:
46' com.sun.star.text.TextGraphicObject
47'*************************************************************************
48On Error Goto ErrHndl
49    Dim bOK As Boolean
50
51
52    PropertyTester.TestProperty("ContentProtected")
53
54    PropertyTester.TestProperty("SurroundContour")
55
56    PropertyTester.TestProperty("ContourOutside")
57
58    Test.StartMethod("ContourPolyPolygon")
59    ' Because in additional parameters we must to
60    ' pass an array of values, we need such array.
61    Dim aPParr1(1) As Variant
62    Dim aPol1(3) As new com.sun.star.awt.Point
63    Dim gArr As Variant
64
65    bOK = true
66    aPol1(0).x = 0   : aPol1(0).y = 0
67    aPol1(1).x = 101 : aPol1(1).y = 0
68    aPol1(2).x = 101 : aPol1(2).y = 101
69    aPol1(3).x = 0   : aPol1(3).y = 101
70    Dim aPol2(3) As new com.sun.star.awt.Point
71    aPol2(0).x = 11 : aPol2(0).y = 11
72    aPol2(1).x = 90 : aPol2(1).y = 11
73    aPol2(2).x = 90 : aPol2(2).y = 90
74    aPol2(3).x = 11 : aPol2(3).y = 90
75    aPParr1(0) = aPol1() : aPParr1(1) = aPol2()
76    oObj.setPropertyValue("ContourPolyPolygon", aPParr1())
77    gArr = oObj.getPropertyValue("ContourPolyPolygon")
78
79    if isArray(gArr) AND ubound(gArr) &gt;= 1 then
80        Dim aP1 As Variant, aP2 As Variant
81
82        aP1 = gArr(0)
83        aP2 = gArr(1)
84        bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 0, 4)
85        bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 0, 4)
86
87        ' One more point must be added to close the polygon
88        bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 4, 1)
89        bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 4, 1)
90    else
91        Out.Log("Returned value is invalid")
92        Out.Log = false
93    endif
94
95    Test.MethodTested("ContourPolyPolygon", bOK)
96
97'    PropertyTester.TestProperty("ContourPolyPolygon",testArr())
98
99    Dim aCropArr(1) As Variant
100    Dim Crop1 As Object
101    Dim Crop2 As Object
102
103    Crop1 = createUnoStruct("com.sun.star.text.GraphicCrop")
104    Crop2 = createUnoStruct("com.sun.star.text.GraphicCrop")
105
106    Crop1.Top = 11 : Crop1.Bottom = 11 : Crop1.Left = 11 : Crop1.Right = 11
107    Crop2.Top = -11 : Crop2.Bottom = 11 : Crop2.Left = -11 : Crop2.Right = 11
108
109    aCropArr(0) = Crop1 : aCropArr(1) = Crop2
110    PropertyTester.TestProperty("GraphicCrop",aCropArr())
111
112    PropertyTester.TestProperty("HoriMirroredOnEvenPages")
113
114    PropertyTester.TestProperty("HoriMirroredOnOddPages")
115
116    PropertyTester.TestProperty("VertMirrored")
117
118    PropertyTester.TestProperty("GraphicURL")
119
120    PropertyTester.TestProperty("GraphicFilter")
121
122    PropertyTester.TestProperty("ActualSize")
123
124    Dim oAdjustArr(4) As Integer
125    oAdjustArr(0) = -100
126    oAdjustArr(1) = -50
127    oAdjustArr(2) = 0
128    oAdjustArr(3) = 50
129    oAdjustArr(4) = 100
130
131    PropertyTester.TestProperty("AdjustLuminance",oAdjustArr())
132
133    PropertyTester.TestProperty("AdjustContrast",oAdjustArr())
134
135    PropertyTester.TestProperty("AdjustRed",oAdjustArr())
136
137    PropertyTester.TestProperty("AdjustGreen",oAdjustArr())
138
139    PropertyTester.TestProperty("AdjustBlue",oAdjustArr())
140
141    PropertyTester.TestProperty("Gamma",oAdjustArr())
142
143    PropertyTester.TestProperty("GraphicIsInverted")
144
145    PropertyTester.TestProperty("Transparency",oAdjustArr())
146
147    PropertyTester.TestProperty("GraphicColorMode")
148
149    PropertyTester.TestProperty("ImageMap")
150
151    PropertyTester.TestProperty("ActualSize")
152
153Exit Sub
154ErrHndl:
155    Test.Exception()
156    bOK = false
157    resume next
158End Sub
159
160Function comparePointArrays(arr1 As Variant, arr2 As Variant, fromIdx1 As Integer, fromIdx2 As Integer, count As Integer) As Boolean
161On Error Goto ErrHndl
162    Dim bOK As Boolean
163    Dim i As Integer
164
165    if NOT isArray(arr1) then
166        Out.Log("First parameter is not Array.")
167        comparePointArrays() = false
168        exit Function
169    endif
170
171    if NOT isArray(arr2) then
172        Out.Log("Second parameter is not Array.")
173        comparePointArrays() = false
174        exit Function
175    endif
176
177    if (lbound(arr1) &gt; fromIdx1 OR ubound(arr1) &lt; (fromIdx1 + count - 1)) then
178        Out.Log("Invalid bounds of the first array")
179        comparePointArrays() = false
180        exit Function
181    endif
182    if (lbound(arr2) &gt; fromIdx2 OR ubound(arr2) &lt; (fromIdx2 + count - 1)) then
183        Out.Log("Invalid bounds of the second array")
184        comparePointArrays() = false
185        exit Function
186    endif
187
188    bOK = true
189    for i = 0 to count - 1
190        if arr1(fromIdx1 + i).x &lt;&gt; arr2(fromIdx2 + i).x OR _
191           arr1(fromIdx1 + i).y &lt;&gt; arr2(fromIdx2 + i).y then
192
193            Out.Log("Points #" + i + " are different : (" + _
194                arr1(fromIdx1 + i).x + "," + arr1(fromIdx1 + i).y + "), (" + _
195                arr2(fromIdx2 + i).x + "," + arr2(fromIdx2 + i).y + ")."
196
197            bOK = false
198        end if
199    next i
200
201    comparePointArrays() = bOK
202
203    exit Function
204ErrHndl:
205    Test.Exception()
206    comparePointArrays() = false
207End Function
208</script:module>
209