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