summaryrefslogtreecommitdiff
path: root/qadevOOo/tests/basic/ifc/text/TextGraphicObject/text_TextGraphicObject.xba
blob: 1fc6fe310302782b3fe88989d23f73d452143490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="text_TextGraphicObject" script:language="StarBasic">


'*************************************************************************
'*
'*  $RCSfile: text_TextGraphicObject.xba,v $ 
'*
'*  $Revision: 1.1 $ 
'*
'*  last change:$Date: 2003-01-27 17:54:04 $ 
'*
'*  The Contents of this file are made available subject to the terms of
'*  either of the following licenses
'*
'*         - GNU Lesser General Public License Version 2.1
'*         - Sun Industry Standards Source License Version 1.1
'*
'*  Sun Microsystems Inc., October, 2000
'*
'*  GNU Lesser General Public License Version 2.1
'*  =============================================
'*  Copyright 2000 by Sun Microsystems, Inc.
'*  901 San Antonio Road, Palo Alto, CA 94303, USA
'*
'*  This library is free software; you can redistribute it and/or
'*  modify it under the terms of the GNU Lesser General Public
'*  License version 2.1, as published by the Free Software Foundation.
'*
'*  This library is distributed in the hope that it will be useful,
'*  but WITHOUT ANY WARRANTY; without even the implied warranty of
'*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
'*  Lesser General Public License for more details.
'*
'*  You should have received a copy of the GNU Lesser General Public
'*  License along with this library; if not, write to the Free Software
'*  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
'*  MA  02111-1307  USA
'*
'*
'*  Sun Industry Standards Source License Version 1.1
'*  =================================================
'*  The contents of this file are subject to the Sun Industry Standards
'*  Source License Version 1.1 (the "License"); You may not use this file
'*  except in compliance with the License. You may obtain a copy of the
'*  License at http://www.openoffice.org/license.html.
'*
'*  Software provided under this License is provided on an "AS IS" basis,
'*  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
'*  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
'*  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
'*  See the License for the specific provisions governing your rights and
'*  obligations concerning the Software.
'*
'*  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
'*
'*  Copyright: 2000 by Sun Microsystems, Inc.
'*
'*  All Rights Reserved.
'*
'*  Contributor(s): _______________________________________
'*
'*
'*************************************************************************
'*************************************************************************



' Be sure that all variables are dimensioned:
option explicit



Sub RunTest()

'*************************************************************************
' SERVICE: 
' com.sun.star.text.TextGraphicObject
'*************************************************************************
On Error Goto ErrHndl
    Dim bOK As Boolean


    PropertyTester.TestProperty("ContentProtected")

    PropertyTester.TestProperty("SurroundContour")

    PropertyTester.TestProperty("ContourOutside")

    Test.StartMethod("ContourPolyPolygon")
    ' Because in additional parameters we must to
    ' pass an array of values, we need such array.
    Dim aPParr1(1) As Variant
    Dim aPol1(3) As new com.sun.star.awt.Point
    Dim gArr As Variant
    
    bOK = true
    aPol1(0).x = 0   : aPol1(0).y = 0
    aPol1(1).x = 101 : aPol1(1).y = 0
    aPol1(2).x = 101 : aPol1(2).y = 101
    aPol1(3).x = 0   : aPol1(3).y = 101
    Dim aPol2(3) As new com.sun.star.awt.Point
    aPol2(0).x = 11 : aPol2(0).y = 11
    aPol2(1).x = 90 : aPol2(1).y = 11
    aPol2(2).x = 90 : aPol2(2).y = 90
    aPol2(3).x = 11 : aPol2(3).y = 90
    aPParr1(0) = aPol1() : aPParr1(1) = aPol2()
    oObj.setPropertyValue("ContourPolyPolygon", aPParr1())
    gArr = oObj.getPropertyValue("ContourPolyPolygon")
    
    if isArray(gArr) AND ubound(gArr) &gt;= 1 then
        Dim aP1 As Variant, aP2 As Variant
        
        aP1 = gArr(0)
        aP2 = gArr(1)
        bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 0, 4)
        bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 0, 4)

        ' One more point must be added to close the polygon
        bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 4, 1)
        bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 4, 1)
    else
        Out.Log("Returned value is invalid")
        Out.Log = false
    endif
    
    Test.MethodTested("ContourPolyPolygon", bOK)
        
'    PropertyTester.TestProperty("ContourPolyPolygon",testArr())

    Dim aCropArr(1) As Variant
    Dim Crop1 As Object
    Dim Crop2 As Object

    Crop1 = createUnoStruct("com.sun.star.text.GraphicCrop")
    Crop2 = createUnoStruct("com.sun.star.text.GraphicCrop")

    Crop1.Top = 11 : Crop1.Bottom = 11 : Crop1.Left = 11 : Crop1.Right = 11
    Crop2.Top = -11 : Crop2.Bottom = 11 : Crop2.Left = -11 : Crop2.Right = 11

    aCropArr(0) = Crop1 : aCropArr(1) = Crop2
    PropertyTester.TestProperty("GraphicCrop",aCropArr())

    PropertyTester.TestProperty("HoriMirroredOnEvenPages")

    PropertyTester.TestProperty("HoriMirroredOnOddPages")

    PropertyTester.TestProperty("VertMirrored")

    PropertyTester.TestProperty("GraphicURL")

    PropertyTester.TestProperty("GraphicFilter")

    PropertyTester.TestProperty("ActualSize")

    Dim oAdjustArr(4) As Integer
    oAdjustArr(0) = -100
    oAdjustArr(1) = -50
    oAdjustArr(2) = 0
    oAdjustArr(3) = 50
    oAdjustArr(4) = 100

    PropertyTester.TestProperty("AdjustLuminance",oAdjustArr())

    PropertyTester.TestProperty("AdjustContrast",oAdjustArr())

    PropertyTester.TestProperty("AdjustRed",oAdjustArr())

    PropertyTester.TestProperty("AdjustGreen",oAdjustArr())

    PropertyTester.TestProperty("AdjustBlue",oAdjustArr())

    PropertyTester.TestProperty("Gamma",oAdjustArr())

    PropertyTester.TestProperty("GraphicIsInverted")

    PropertyTester.TestProperty("Transparency",oAdjustArr())

    PropertyTester.TestProperty("GraphicColorMode")

    PropertyTester.TestProperty("ImageMap")

    PropertyTester.TestProperty("ActualSize")

Exit Sub
ErrHndl:
    Test.Exception()
    bOK = false
    resume next
End Sub

Function comparePointArrays(arr1 As Variant, arr2 As Variant, fromIdx1 As Integer, fromIdx2 As Integer, count As Integer) As Boolean
On Error Goto ErrHndl
    Dim bOK As Boolean   
    Dim i As Integer 
    
    if NOT isArray(arr1) then
        Out.Log("First parameter is not Array.")
        comparePointArrays() = false
        exit Function
    endif

    if NOT isArray(arr2) then
        Out.Log("Second parameter is not Array.")
        comparePointArrays() = false
        exit Function
    endif

    if (lbound(arr1) &gt; fromIdx1 OR ubound(arr1) &lt; (fromIdx1 + count - 1)) then
        Out.Log("Invalid bounds of the first array")
        comparePointArrays() = false
        exit Function
    endif
    if (lbound(arr2) &gt; fromIdx2 OR ubound(arr2) &lt; (fromIdx2 + count - 1)) then
        Out.Log("Invalid bounds of the second array")
        comparePointArrays() = false
        exit Function
    endif

    bOK = true
    for i = 0 to count - 1
        if arr1(fromIdx1 + i).x &lt;&gt; arr2(fromIdx2 + i).x OR _
           arr1(fromIdx1 + i).y &lt;&gt; arr2(fromIdx2 + i).y then

            Out.Log("Points #" + i + " are different : (" + _
                arr1(fromIdx1 + i).x + "," + arr1(fromIdx1 + i).y + "), (" + _
                arr2(fromIdx2 + i).x + "," + arr2(fromIdx2 + i).y + ")."
                
            bOK = false
        end if
    next i

    comparePointArrays() = bOK
    
    exit Function
ErrHndl:
    Test.Exception()
    comparePointArrays() = false
End Function
</script:module>