1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.sheet; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir import util.ValueChanger; 28cdf0e10cSrcweir 29cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 30cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 31cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 32cdf0e10cSrcweir import com.sun.star.sheet.FunctionArgument; 33cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 34cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 35cdf0e10cSrcweir import com.sun.star.uno.XInterface; 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** 38cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.FunctionDescription</code> 39cdf0e10cSrcweir * service properties: 40cdf0e10cSrcweir * <ul> 41cdf0e10cSrcweir * <li><code>Arguments</code></li> 42cdf0e10cSrcweir * <li><code>Category</code></li> 43cdf0e10cSrcweir * <li><code>Description</code></li> 44cdf0e10cSrcweir * <li><code>Id</code></li> 45cdf0e10cSrcweir * <li><code>Name</code></li> 46cdf0e10cSrcweir * </ul> <p> 47cdf0e10cSrcweir * @see com.sun.star.sheet.FunctionDescription 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir public class _FunctionDescription extends MultiMethodTest { 50cdf0e10cSrcweir 51cdf0e10cSrcweir public XPropertySet oObj = null; // oObj filled by MultiMethodTest 52cdf0e10cSrcweir 53cdf0e10cSrcweir public _FunctionDescription() { 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir public void _Arguments() { 57cdf0e10cSrcweir // check if Service is available 58cdf0e10cSrcweir XServiceInfo xInfo = (XServiceInfo) 59cdf0e10cSrcweir UnoRuntime.queryInterface(XServiceInfo.class, oObj ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir if ( ! xInfo.supportsService 62cdf0e10cSrcweir ( "com.sun.star.sheet.FunctionDescription" ) ) { 63cdf0e10cSrcweir log.println( "Service not available !" ); 64cdf0e10cSrcweir tRes.tested( "Supported", false ); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir try { 68cdf0e10cSrcweir XMultiServiceFactory oDocMSF = (XMultiServiceFactory)tParam.getMSF(); 69cdf0e10cSrcweir 70cdf0e10cSrcweir XInterface FA = (XInterface)oDocMSF. 71cdf0e10cSrcweir createInstance("com.sun.star.sheet.FunctionArgument"); 72cdf0e10cSrcweir FunctionArgument arg = (FunctionArgument)AnyConverter.toObject 73cdf0e10cSrcweir (FunctionArgument.class, FA); 74cdf0e10cSrcweir 75cdf0e10cSrcweir arg.Description = "FunctionDescription argument description" ; 76cdf0e10cSrcweir arg.Name = "FunctionDescriptiuon argument name" ; 77cdf0e10cSrcweir arg.IsOptional = true ; 78cdf0e10cSrcweir 79cdf0e10cSrcweir Object sValue = oObj.getPropertyValue("Arguments") ; 80cdf0e10cSrcweir oObj.setPropertyValue("Arguments", new FunctionArgument[] {arg}) ; 81cdf0e10cSrcweir Object nValue = oObj.getPropertyValue("Arguments") ; 82cdf0e10cSrcweir 83cdf0e10cSrcweir if (sValue.equals(nValue)) { 84cdf0e10cSrcweir log.println("Property 'Arguments' didn't change: OK") ; 85cdf0e10cSrcweir tRes.tested("Arguments", true) ; 86cdf0e10cSrcweir } else { 87cdf0e10cSrcweir log.println("Readonly property 'Arguments' changed: Failed") ; 88cdf0e10cSrcweir tRes.tested("Arguments", false) ; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir } catch (Exception e) { 91cdf0e10cSrcweir log.println( 92cdf0e10cSrcweir "Exception occured while testing property 'Arguments'" ); 93cdf0e10cSrcweir e.printStackTrace( log ); 94cdf0e10cSrcweir tRes.tested( "Arguments", false ); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir public void _Category() { 99cdf0e10cSrcweir tryChangeProp("Category") ; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir public void _Description() { 103cdf0e10cSrcweir tryChangeProp( "Category" ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir public void _Id() { 107cdf0e10cSrcweir tryChangeProp( "Id" ); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir public void _Name() { 111cdf0e10cSrcweir tryChangeProp( "Name" ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir public void tryChangeProp( String name ) { 115cdf0e10cSrcweir 116cdf0e10cSrcweir Object gValue = null; 117cdf0e10cSrcweir Object sValue = null; 118cdf0e10cSrcweir Object ValueToSet = null; 119cdf0e10cSrcweir 120cdf0e10cSrcweir 121cdf0e10cSrcweir try { 122cdf0e10cSrcweir //waitForAllThreads(); 123cdf0e10cSrcweir gValue = oObj.getPropertyValue( name ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir //waitForAllThreads(); 126cdf0e10cSrcweir ValueToSet = ValueChanger.changePValue( gValue ); 127cdf0e10cSrcweir //waitForAllThreads(); 128cdf0e10cSrcweir oObj.setPropertyValue( name, ValueToSet ); 129cdf0e10cSrcweir sValue = oObj.getPropertyValue( name ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir //check get-set methods 132cdf0e10cSrcweir if( gValue.equals( sValue ) ) { 133cdf0e10cSrcweir log.println( "Value for '"+name+"' hasn't changed. OK." ); 134cdf0e10cSrcweir tRes.tested( name, true ); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir else { 137cdf0e10cSrcweir log.println( "Property '" + name + 138cdf0e10cSrcweir "' changes it's value : Failed !" ); 139cdf0e10cSrcweir tRes.tested( name, false ); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir catch ( Exception e ) { 143cdf0e10cSrcweir log.println( 144cdf0e10cSrcweir "Exception occured while testing property '" + name + "'" ); 145cdf0e10cSrcweir e.printStackTrace( log ); 146cdf0e10cSrcweir tRes.tested( name, false ); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir } // end of changeProp 149cdf0e10cSrcweir 150cdf0e10cSrcweir } //finish class _TextContent 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153