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