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