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.XEnumerationAccess; 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 public class ScIndexEnumeration_FunctionDescriptionEnumeration extends TestCase { 42 static XSpreadsheetDocument xSheetDoc = null; 43 44 /** 45 * Creates Spreadsheet document. 46 */ initialize( TestParameters tParam, PrintWriter log )47 protected void initialize( TestParameters tParam, PrintWriter log ) { 48 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 49 50 try { 51 log.println( "creating a Spreadsheet document" ); 52 xSheetDoc = SOF.createCalcDoc(null); 53 } catch (com.sun.star.uno.Exception e) { 54 // Some exception occures.FAILED 55 e.printStackTrace( log ); 56 throw new StatusException( "Couldn't create document", e ); 57 } 58 59 } 60 61 /** 62 * Disposes Spreadsheet document. 63 */ cleanup( TestParameters tParam, PrintWriter log )64 protected void cleanup( TestParameters tParam, PrintWriter log ) { 65 log.println( " disposing xSheetDoc " ); 66 XComponent oComp = (XComponent) 67 UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ; 68 util.DesktopTools.closeDoc(oComp); 69 } 70 createTestEnvironment(TestParameters Param, PrintWriter log)71 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 72 73 XInterface oObj = null; 74 75 // creation of testobject here 76 // first we write what we are intend to do to log file 77 log.println( "Creating a test environment" ); 78 79 log.println("Getting test object ") ; 80 81 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)Param.getMSF(); 82 try { 83 oObj = (XInterface)oDocMSF.createInstance( 84 "com.sun.star.sheet.FunctionDescriptions"); 85 log.println("Creating object - " + 86 ((oObj == null) ? "FAILED" : "OK")); 87 } catch (com.sun.star.uno.Exception e) { 88 e.printStackTrace(log) ; 89 throw new StatusException( 90 "Error getting test object from spreadsheet document", e); 91 } 92 93 XEnumerationAccess ea = (XEnumerationAccess) 94 UnoRuntime.queryInterface(XEnumerationAccess.class,oObj); 95 96 oObj = ea.createEnumeration(); 97 98 log.println("ImplementationName: "+util.utils.getImplName(oObj)); 99 // creating test environment 100 TestEnvironment tEnv = new TestEnvironment( oObj ); 101 102 tEnv.addObjRelation("ENUM",ea); 103 104 return tEnv; 105 } 106 107 } 108 109 110