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.beans.XPropertySet; 34 import com.sun.star.style.XStyle; 35 import com.sun.star.uno.UnoRuntime; 36 37 38 public class _ShapeDescriptor extends MultiMethodTest { 39 40 public XPropertySet oObj = null; // oObj filled by MultiMethodTest 41 public boolean ro = false; 42 43 public void _LayerID() { 44 com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo) 45 UnoRuntime.queryInterface 46 (com.sun.star.lang.XServiceInfo.class, oObj); 47 if ( ! xInfo.supportsService("com.sun.star.drawing.ShapeDescriptor")) { 48 log.println("Service not available !!!!!!!!!!!!!"); 49 tRes.tested("Supported", false); 50 } 51 ro = true; 52 changeProp("LayerID"); 53 ro = false; 54 } 55 public void _LayerName() { 56 ro = true; 57 changeProp("LayerName"); 58 ro = false; 59 } 60 public void _MoveProtect() { 61 changeProp("MoveProtect"); 62 } 63 public void _Name() { 64 changeProp("Name"); 65 } 66 public void _Printable() { 67 changeProp("Printable"); 68 } 69 public void _SizeProtect() { 70 changeProp("SizeProtect"); 71 } 72 public void _Style() { 73 changeProp("Style"); 74 } 75 76 public void _Transformation() { 77 changeProp("Transformation"); 78 } 79 80 public void changeProp(String name) { 81 82 Object gValue = null; 83 Object sValue = null; 84 Object ValueToSet = null; 85 86 87 try { 88 //waitForAllThreads(); 89 gValue = oObj.getPropertyValue(name); 90 //waitForAllThreads(); 91 if (!ro) { 92 ValueToSet = ValueChanger.changePValue(gValue); 93 if ( name.equals("Style") ) { 94 ValueToSet = newStyle(gValue); 95 } 96 //waitForAllThreads(); 97 oObj.setPropertyValue(name,ValueToSet); 98 sValue = oObj.getPropertyValue(name); 99 } 100 101 //check get-set methods 102 if (gValue.equals(sValue)) { 103 log.println("Value for '"+name+"' hasn't changed"); 104 tRes.tested(name, false); 105 } else { 106 log.println("Property '"+name+"' OK"); 107 tRes.tested(name, true); 108 } 109 } catch (com.sun.star.beans.UnknownPropertyException ex) { 110 if (isOptional(name)) { 111 log.println("Property '"+name+ 112 "' is optional and not supported"); 113 tRes.tested(name,true); 114 } else { 115 log.println("Exception occured while testing property '" + 116 name + "'"); 117 ex.printStackTrace(log); 118 tRes.tested(name, false); 119 } 120 } 121 catch (Exception e) { 122 log.println("Exception occured while testing property '" + 123 name + "'"); 124 e.printStackTrace(log); 125 tRes.tested(name, false); 126 } 127 128 129 }// end of changeProp 130 131 public XStyle newStyle(Object oldStyle) { 132 XStyle Style1 = (XStyle) tEnv.getObjRelation("Style1"); 133 XStyle Style2 = (XStyle) tEnv.getObjRelation("Style2"); 134 XStyle back = null; 135 if ( (Style1!=null) && (Style2!=null) ) { 136 if ( ((XStyle) oldStyle).equals(Style1) ) { 137 back = Style2; 138 } else { 139 back = Style1; 140 } 141 } 142 return back; 143 } 144 145 } 146 147 148