1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.drawing; 29 30 import lib.MultiMethodTest; 31 import util.ValueChanger; 32 33 import com.sun.star.awt.Point; 34 import com.sun.star.beans.XPropertySet; 35 import com.sun.star.lang.XServiceInfo; 36 import com.sun.star.uno.UnoRuntime; 37 38 39 public class _LineShapeDescriptor extends MultiMethodTest { 40 41 public XPropertySet oObj = null; // oObj filled by MultiMethodTest 42 43 44 public void _LineColor() { 45 XServiceInfo xInfo = (XServiceInfo) 46 UnoRuntime.queryInterface(XServiceInfo.class, oObj); 47 if ( ! xInfo.supportsService 48 ("com.sun.star.drawing.LineShapeDescriptor")) { 49 log.println("Service not available !!!!!!!!!!!!!"); 50 tRes.tested("Supported", false); 51 } 52 changeProp("LineColor"); 53 } 54 55 public void _LineDash() { 56 changeProp("LineDash"); 57 } 58 public void _LineEnd() { 59 changeProp("LineEnd"); 60 } 61 public void _LineEndCenter() { 62 changeProp("LineEndCenter"); 63 } 64 public void _LineEndWidth() { 65 changeProp("LineEndWidth"); 66 } 67 public void _LineJoint() { 68 changeProp("LineJoint"); 69 } 70 public void _LineStart() { 71 changeProp("LineStart"); 72 } 73 public void _LineStartCenter() { 74 changeProp("LineStartCenter"); 75 } 76 public void _LineStartWidth() { 77 changeProp("LineStartWidth"); 78 } 79 public void _LineStyle() { 80 changeProp("LineStyle"); 81 } 82 public void _LineTransparence() { 83 changeProp("LineTransparence"); 84 } 85 public void _LineWidth() { 86 changeProp("LineWidth"); 87 } 88 89 public void changeProp(String name) { 90 91 Object gValue = null; 92 Object sValue = null; 93 Object ValueToSet = null; 94 95 try { 96 //waitForAllThreads(); 97 gValue = oObj.getPropertyValue(name); 98 //waitForAllThreads(); 99 if ( (name.equals("LineEnd")) || (name.equals("LineStart")) ) { 100 if (gValue == null) gValue = newPoints(null); 101 ValueToSet = newPoints( (Point[]) gValue); 102 } 103 else { 104 ValueToSet = ValueChanger.changePValue(gValue); 105 } 106 //waitForAllThreads(); 107 oObj.setPropertyValue(name,ValueToSet); 108 sValue = oObj.getPropertyValue(name); 109 110 111 //check get-set methods 112 if (gValue.equals(sValue)) { 113 log.println("Value for '"+name+"' hasn't changed"); 114 tRes.tested(name, false); 115 } 116 else { 117 log.println("Property '"+name+"' OK"); 118 tRes.tested(name, true); 119 } 120 } catch (Exception e) { 121 log.println("Exception occured while testing property '" + 122 name + "'"); 123 e.printStackTrace(log); 124 tRes.tested(name, false); 125 } 126 127 128 } // end of ChangeProp 129 130 public Point[] newPoints(Point[] old) { 131 132 Point [] newP = new Point[3]; 133 134 if (old == null) { 135 newP[0] = new Point(0, 2); 136 newP[1] = new Point(2, 0); 137 newP[2] = new Point(0, -2); 138 } 139 else { 140 newP = old; 141 newP[0].X += 1; 142 newP[1].X += 1; 143 newP[2].X += 1; 144 } 145 return newP; 146 } 147 148 } 149 150 151