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