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.sheet; 25 26 import lib.MultiMethodTest; 27 import util.ValueChanger; 28 29 import com.sun.star.beans.XPropertySet; 30 import com.sun.star.lang.XMultiServiceFactory; 31 import com.sun.star.lang.XServiceInfo; 32 import com.sun.star.sheet.FunctionArgument; 33 import com.sun.star.uno.AnyConverter; 34 import com.sun.star.uno.UnoRuntime; 35 import com.sun.star.uno.XInterface; 36 37 /** 38 * Testing <code>com.sun.star.sheet.FunctionDescription</code> 39 * service properties: 40 * <ul> 41 * <li><code>Arguments</code></li> 42 * <li><code>Category</code></li> 43 * <li><code>Description</code></li> 44 * <li><code>Id</code></li> 45 * <li><code>Name</code></li> 46 * </ul> <p> 47 * @see com.sun.star.sheet.FunctionDescription 48 */ 49 public class _FunctionDescription extends MultiMethodTest { 50 51 public XPropertySet oObj = null; // oObj filled by MultiMethodTest 52 _FunctionDescription()53 public _FunctionDescription() { 54 } 55 _Arguments()56 public void _Arguments() { 57 // check if Service is available 58 XServiceInfo xInfo = (XServiceInfo) 59 UnoRuntime.queryInterface(XServiceInfo.class, oObj ); 60 61 if ( ! xInfo.supportsService 62 ( "com.sun.star.sheet.FunctionDescription" ) ) { 63 log.println( "Service not available !" ); 64 tRes.tested( "Supported", false ); 65 } 66 67 try { 68 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)tParam.getMSF(); 69 70 XInterface FA = (XInterface)oDocMSF. 71 createInstance("com.sun.star.sheet.FunctionArgument"); 72 FunctionArgument arg = (FunctionArgument)AnyConverter.toObject 73 (FunctionArgument.class, FA); 74 75 arg.Description = "FunctionDescription argument description" ; 76 arg.Name = "FunctionDescriptiuon argument name" ; 77 arg.IsOptional = true ; 78 79 Object sValue = oObj.getPropertyValue("Arguments") ; 80 oObj.setPropertyValue("Arguments", new FunctionArgument[] {arg}) ; 81 Object nValue = oObj.getPropertyValue("Arguments") ; 82 83 if (sValue.equals(nValue)) { 84 log.println("Property 'Arguments' didn't change: OK") ; 85 tRes.tested("Arguments", true) ; 86 } else { 87 log.println("Readonly property 'Arguments' changed: Failed") ; 88 tRes.tested("Arguments", false) ; 89 } 90 } catch (Exception e) { 91 log.println( 92 "Exception occured while testing property 'Arguments'" ); 93 e.printStackTrace( log ); 94 tRes.tested( "Arguments", false ); 95 } 96 } 97 _Category()98 public void _Category() { 99 tryChangeProp("Category") ; 100 } 101 _Description()102 public void _Description() { 103 tryChangeProp( "Category" ); 104 } 105 _Id()106 public void _Id() { 107 tryChangeProp( "Id" ); 108 } 109 _Name()110 public void _Name() { 111 tryChangeProp( "Name" ); 112 } 113 tryChangeProp( String name )114 public void tryChangeProp( String name ) { 115 116 Object gValue = null; 117 Object sValue = null; 118 Object ValueToSet = null; 119 120 121 try { 122 //waitForAllThreads(); 123 gValue = oObj.getPropertyValue( name ); 124 125 //waitForAllThreads(); 126 ValueToSet = ValueChanger.changePValue( gValue ); 127 //waitForAllThreads(); 128 oObj.setPropertyValue( name, ValueToSet ); 129 sValue = oObj.getPropertyValue( name ); 130 131 //check get-set methods 132 if( gValue.equals( sValue ) ) { 133 log.println( "Value for '"+name+"' hasn't changed. OK." ); 134 tRes.tested( name, true ); 135 } 136 else { 137 log.println( "Property '" + name + 138 "' changes it's value : Failed !" ); 139 tRes.tested( name, false ); 140 } 141 } 142 catch ( Exception e ) { 143 log.println( 144 "Exception occured while testing property '" + name + "'" ); 145 e.printStackTrace( log ); 146 tRes.tested( name, false ); 147 } 148 } // end of changeProp 149 150 } //finish class _TextContent 151 152 153