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