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 mod._sc; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 34 import com.sun.star.container.XNameAccess; 35 import com.sun.star.lang.XComponent; 36 import com.sun.star.lang.XMultiServiceFactory; 37 import com.sun.star.sheet.XSpreadsheetDocument; 38 import com.sun.star.uno.UnoRuntime; 39 import com.sun.star.uno.XInterface; 40 41 /** 42 * Test for object which is represented by service 43 * <code>com.sun.star.sheet.RecentFunctions</code>. <p> 44 * Object implements the following interfaces : 45 * <ul> 46 * <li> <code>com::sun::star::sheet::XRecentFunctions</code></li> 47 * </ul> 48 * @see com.sun.star.sheet.RecentFunctions 49 * @see com.sun.star.sheet.XRecentFunctions 50 * @see ifc.sheet._XRecentFunctions 51 */ 52 public class ScRecentFunctionsObj extends TestCase { 53 static XSpreadsheetDocument xSheetDoc = null; 54 55 /** 56 * Creates Spreadsheet document. 57 */ 58 protected void initialize( TestParameters tParam, PrintWriter log ) { 59 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 60 61 try { 62 log.println( "creating a Spreadsheet document" ); 63 xSheetDoc = SOF.createCalcDoc(null); 64 } catch ( com.sun.star.uno.Exception e ) { 65 // Some exception occures.FAILED 66 e.printStackTrace( log ); 67 throw new StatusException( "Couldn't create document", e ); 68 } 69 } 70 71 /** 72 * Disposes Spreadsheet document. 73 */ 74 protected void cleanup( TestParameters tParam, PrintWriter log ) { 75 log.println( " disposing xSheetDoc " ); 76 XComponent oComp = (XComponent) 77 UnoRuntime.queryInterface(XComponent.class, xSheetDoc) ; 78 util.DesktopTools.closeDoc(oComp); 79 } 80 81 /** 82 * Creating a Testenvironment for the interfaces to be tested. 83 * Creates an instance of the service 84 * <code>com.sun.star.sheet.RecentFunctions</code> and an instance of the 85 * service <code>com.sun.star.sheet.FunctionDescriptions</code>. 86 * Object relations created : 87 * <ul> 88 * <li> <code>'FUNCTIONLIST'</code> for 89 * {@link ifc.sheet._XRecentFunctions}(the second created instance)</li> 90 * </ul> 91 */ 92 public synchronized TestEnvironment createTestEnvironment( 93 TestParameters Param, PrintWriter log ) throws StatusException { 94 95 XInterface oObj = null; 96 XInterface allFunctions = null; 97 98 // creation of testobject here 99 // first we write what we are intend to do to log file 100 log.println( "Creating a test environment" ); 101 102 try { 103 log.println("Getting test object ") ; 104 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)Param.getMSF(); 105 oObj = (XInterface)oDocMSF.createInstance( 106 "com.sun.star.sheet.RecentFunctions"); 107 allFunctions = (XInterface)oDocMSF.createInstance( 108 "com.sun.star.sheet.FunctionDescriptions"); 109 110 log.println("Creating object - " + 111 ((oObj == null) ? "FAILED" : "OK")); 112 } catch (com.sun.star.uno.Exception e) { 113 e.printStackTrace(log) ; 114 throw new StatusException("Couldn't create instance", e); 115 } 116 117 TestEnvironment tEnv = new TestEnvironment( oObj ); 118 119 // Other parameters required for interface tests 120 XNameAccess NA = (XNameAccess) 121 UnoRuntime.queryInterface(XNameAccess.class, allFunctions); 122 tEnv.addObjRelation("FUNCTIONLIST", NA); 123 124 return tEnv; 125 } 126 127 } 128 129 130