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' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34 35 36Sub RunTest() 37 38'************************************************************************* 39' SERVICE: 40' com.sun.star.text.TextGraphicObject 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 45 46 PropertyTester.TestProperty("ContentProtected") 47 48 PropertyTester.TestProperty("SurroundContour") 49 50 PropertyTester.TestProperty("ContourOutside") 51 52 Test.StartMethod("ContourPolyPolygon") 53 ' Because in additional parameters we must to 54 ' pass an array of values, we need such array. 55 Dim aPParr1(1) As Variant 56 Dim aPol1(3) As new com.sun.star.awt.Point 57 Dim gArr As Variant 58 59 bOK = true 60 aPol1(0).x = 0 : aPol1(0).y = 0 61 aPol1(1).x = 101 : aPol1(1).y = 0 62 aPol1(2).x = 101 : aPol1(2).y = 101 63 aPol1(3).x = 0 : aPol1(3).y = 101 64 Dim aPol2(3) As new com.sun.star.awt.Point 65 aPol2(0).x = 11 : aPol2(0).y = 11 66 aPol2(1).x = 90 : aPol2(1).y = 11 67 aPol2(2).x = 90 : aPol2(2).y = 90 68 aPol2(3).x = 11 : aPol2(3).y = 90 69 aPParr1(0) = aPol1() : aPParr1(1) = aPol2() 70 oObj.setPropertyValue("ContourPolyPolygon", aPParr1()) 71 gArr = oObj.getPropertyValue("ContourPolyPolygon") 72 73 if isArray(gArr) AND ubound(gArr) >= 1 then 74 Dim aP1 As Variant, aP2 As Variant 75 76 aP1 = gArr(0) 77 aP2 = gArr(1) 78 bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 0, 4) 79 bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 0, 4) 80 81 ' One more point must be added to close the polygon 82 bOK = bOK AND comparePointArrays(aPol1(), aP1, 0, 4, 1) 83 bOK = bOK AND comparePointArrays(aPol2(), aP2, 0, 4, 1) 84 else 85 Out.Log("Returned value is invalid") 86 Out.Log = false 87 endif 88 89 Test.MethodTested("ContourPolyPolygon", bOK) 90 91' PropertyTester.TestProperty("ContourPolyPolygon",testArr()) 92 93 Dim aCropArr(1) As Variant 94 Dim Crop1 As Object 95 Dim Crop2 As Object 96 97 Crop1 = createUnoStruct("com.sun.star.text.GraphicCrop") 98 Crop2 = createUnoStruct("com.sun.star.text.GraphicCrop") 99 100 Crop1.Top = 11 : Crop1.Bottom = 11 : Crop1.Left = 11 : Crop1.Right = 11 101 Crop2.Top = -11 : Crop2.Bottom = 11 : Crop2.Left = -11 : Crop2.Right = 11 102 103 aCropArr(0) = Crop1 : aCropArr(1) = Crop2 104 PropertyTester.TestProperty("GraphicCrop",aCropArr()) 105 106 PropertyTester.TestProperty("HoriMirroredOnEvenPages") 107 108 PropertyTester.TestProperty("HoriMirroredOnOddPages") 109 110 PropertyTester.TestProperty("VertMirrored") 111 112 PropertyTester.TestProperty("GraphicURL") 113 114 PropertyTester.TestProperty("GraphicFilter") 115 116 PropertyTester.TestProperty("ActualSize") 117 118 Dim oAdjustArr(4) As Integer 119 oAdjustArr(0) = -100 120 oAdjustArr(1) = -50 121 oAdjustArr(2) = 0 122 oAdjustArr(3) = 50 123 oAdjustArr(4) = 100 124 125 PropertyTester.TestProperty("AdjustLuminance",oAdjustArr()) 126 127 PropertyTester.TestProperty("AdjustContrast",oAdjustArr()) 128 129 PropertyTester.TestProperty("AdjustRed",oAdjustArr()) 130 131 PropertyTester.TestProperty("AdjustGreen",oAdjustArr()) 132 133 PropertyTester.TestProperty("AdjustBlue",oAdjustArr()) 134 135 PropertyTester.TestProperty("Gamma",oAdjustArr()) 136 137 PropertyTester.TestProperty("GraphicIsInverted") 138 139 PropertyTester.TestProperty("Transparency",oAdjustArr()) 140 141 PropertyTester.TestProperty("GraphicColorMode") 142 143 PropertyTester.TestProperty("ImageMap") 144 145 PropertyTester.TestProperty("ActualSize") 146 147Exit Sub 148ErrHndl: 149 Test.Exception() 150 bOK = false 151 resume next 152End Sub 153 154Function comparePointArrays(arr1 As Variant, arr2 As Variant, fromIdx1 As Integer, fromIdx2 As Integer, count As Integer) As Boolean 155On Error Goto ErrHndl 156 Dim bOK As Boolean 157 Dim i As Integer 158 159 if NOT isArray(arr1) then 160 Out.Log("First parameter is not Array.") 161 comparePointArrays() = false 162 exit Function 163 endif 164 165 if NOT isArray(arr2) then 166 Out.Log("Second parameter is not Array.") 167 comparePointArrays() = false 168 exit Function 169 endif 170 171 if (lbound(arr1) > fromIdx1 OR ubound(arr1) < (fromIdx1 + count - 1)) then 172 Out.Log("Invalid bounds of the first array") 173 comparePointArrays() = false 174 exit Function 175 endif 176 if (lbound(arr2) > fromIdx2 OR ubound(arr2) < (fromIdx2 + count - 1)) then 177 Out.Log("Invalid bounds of the second array") 178 comparePointArrays() = false 179 exit Function 180 endif 181 182 bOK = true 183 for i = 0 to count - 1 184 if arr1(fromIdx1 + i).x <> arr2(fromIdx2 + i).x OR _ 185 arr1(fromIdx1 + i).y <> arr2(fromIdx2 + i).y then 186 187 Out.Log("Points #" + i + " are different : (" + _ 188 arr1(fromIdx1 + i).x + "," + arr1(fromIdx1 + i).y + "), (" + _ 189 arr2(fromIdx2 + i).x + "," + arr2(fromIdx2 + i).y + ")." 190 191 bOK = false 192 end if 193 next i 194 195 comparePointArrays() = bOK 196 197 exit Function 198ErrHndl: 199 Test.Exception() 200 comparePointArrays() = false 201End Function 202</script:module> 203