1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.drawing; 25 26 import lib.MultiMethodTest; 27 import util.ValueChanger; 28 29 import com.sun.star.beans.XPropertySet; 30 import com.sun.star.style.XStyle; 31 import com.sun.star.uno.UnoRuntime; 32 33 34 public class _ShapeDescriptor extends MultiMethodTest { 35 36 public XPropertySet oObj = null; // oObj filled by MultiMethodTest 37 public boolean ro = false; 38 _LayerID()39 public void _LayerID() { 40 com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo) 41 UnoRuntime.queryInterface 42 (com.sun.star.lang.XServiceInfo.class, oObj); 43 if ( ! xInfo.supportsService("com.sun.star.drawing.ShapeDescriptor")) { 44 log.println("Service not available !!!!!!!!!!!!!"); 45 tRes.tested("Supported", false); 46 } 47 ro = true; 48 changeProp("LayerID"); 49 ro = false; 50 } _LayerName()51 public void _LayerName() { 52 ro = true; 53 changeProp("LayerName"); 54 ro = false; 55 } _MoveProtect()56 public void _MoveProtect() { 57 changeProp("MoveProtect"); 58 } _Name()59 public void _Name() { 60 changeProp("Name"); 61 } _Printable()62 public void _Printable() { 63 changeProp("Printable"); 64 } _SizeProtect()65 public void _SizeProtect() { 66 changeProp("SizeProtect"); 67 } _Style()68 public void _Style() { 69 changeProp("Style"); 70 } 71 _Transformation()72 public void _Transformation() { 73 changeProp("Transformation"); 74 } 75 changeProp(String name)76 public void changeProp(String name) { 77 78 Object gValue = null; 79 Object sValue = null; 80 Object ValueToSet = null; 81 82 83 try { 84 //waitForAllThreads(); 85 gValue = oObj.getPropertyValue(name); 86 //waitForAllThreads(); 87 if (!ro) { 88 ValueToSet = ValueChanger.changePValue(gValue); 89 if ( name.equals("Style") ) { 90 ValueToSet = newStyle(gValue); 91 } 92 //waitForAllThreads(); 93 oObj.setPropertyValue(name,ValueToSet); 94 sValue = oObj.getPropertyValue(name); 95 } 96 97 //check get-set methods 98 if (gValue.equals(sValue)) { 99 log.println("Value for '"+name+"' hasn't changed"); 100 tRes.tested(name, false); 101 } else { 102 log.println("Property '"+name+"' OK"); 103 tRes.tested(name, true); 104 } 105 } catch (com.sun.star.beans.UnknownPropertyException ex) { 106 if (isOptional(name)) { 107 log.println("Property '"+name+ 108 "' is optional and not supported"); 109 tRes.tested(name,true); 110 } else { 111 log.println("Exception occured while testing property '" + 112 name + "'"); 113 ex.printStackTrace(log); 114 tRes.tested(name, false); 115 } 116 } 117 catch (Exception e) { 118 log.println("Exception occured while testing property '" + 119 name + "'"); 120 e.printStackTrace(log); 121 tRes.tested(name, false); 122 } 123 124 125 }// end of changeProp 126 newStyle(Object oldStyle)127 public XStyle newStyle(Object oldStyle) { 128 XStyle Style1 = (XStyle) tEnv.getObjRelation("Style1"); 129 XStyle Style2 = (XStyle) tEnv.getObjRelation("Style2"); 130 XStyle back = null; 131 if ( (Style1!=null) && (Style2!=null) ) { 132 if ( ((XStyle) oldStyle).equals(Style1) ) { 133 back = Style2; 134 } else { 135 back = Style1; 136 } 137 } 138 return back; 139 } 140 141 } 142 143 144