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