1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScFunctionListObj.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
41 import com
.sun
.star
.lang
.XComponent
;
42 import com
.sun
.star
.lang
.XMultiServiceFactory
;
43 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
48 * Test for object which is represented by service
49 * <code>com.sun.star.sheet.FunctionDescriptions</code>. <p>
50 * Object implements the following interfaces :
52 * <li> <code>com::sun::star::container::XNameAccess</code></li>
53 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
54 * <li> <code>com::sun::star::sheet::XFunctionDescriptions</code></li>
55 * <li> <code>com::sun::star::container::XElementAccess</code></li>
57 * @see com.sun.star.sheet.FunctionDescriptions
58 * @see com.sun.star.container.XNameAccess
59 * @see com.sun.star.container.XIndexAccess
60 * @see com.sun.star.sheet.XFunctionDescriptions
61 * @see com.sun.star.container.XElementAccess
62 * @see ifc.container._XNameAccess
63 * @see ifc.container._XIndexAccess
64 * @see ifc.sheet._XFunctionDescriptions
65 * @see ifc.container._XElementAccess
67 public class ScFunctionListObj
extends TestCase
{
68 static XSpreadsheetDocument xSheetDoc
= null;
71 * Creates Spreadsheet document.
73 protected void initialize( TestParameters tParam
, PrintWriter log
) {
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
77 log
.println( "creating a Spreadsheet document" );
78 xSheetDoc
= SOF
.createCalcDoc(null);
79 } catch (com
.sun
.star
.uno
.Exception e
) {
80 // Some exception occures.FAILED
81 e
.printStackTrace( log
);
82 throw new StatusException( "Couldn't create document", e
);
88 * Disposes Spreadsheet document.
90 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
91 log
.println( " disposing xSheetDoc " );
92 XComponent oComp
= (XComponent
)
93 UnoRuntime
.queryInterface (XComponent
.class, xSheetDoc
) ;
94 util
.DesktopTools
.closeDoc(oComp
);
98 * Creating a Testenvironment for the interfaces to be tested.
99 * Creates an instance of the service
100 * <code>com.sun.star.sheet.FunctionDescriptions</code>.
101 * @see com.sun.star.sheet.FunctionDescriptions
103 public synchronized TestEnvironment
createTestEnvironment(
104 TestParameters Param
, PrintWriter log
) throws StatusException
{
106 XInterface oObj
= null;
108 // creation of testobject here
109 // first we write what we are intend to do to log file
110 log
.println( "Creating a test environment" );
112 log
.println("Getting test object ") ;
114 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
)Param
.getMSF();
116 oObj
= (XInterface
)oDocMSF
.createInstance(
117 "com.sun.star.sheet.FunctionDescriptions");
118 log
.println("Creating object - " +
119 ((oObj
== null) ?
"FAILED" : "OK"));
120 } catch (com
.sun
.star
.uno
.Exception e
) {
121 e
.printStackTrace(log
) ;
122 throw new StatusException(
123 "Error getting test object from spreadsheet document", e
);
126 TestEnvironment tEnv
= new TestEnvironment( oObj
);