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: ScRecentFunctionsObj.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
.container
.XNameAccess
;
42 import com
.sun
.star
.lang
.XComponent
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
46 import com
.sun
.star
.uno
.XInterface
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.sheet.RecentFunctions</code>. <p>
51 * Object implements the following interfaces :
53 * <li> <code>com::sun::star::sheet::XRecentFunctions</code></li>
55 * @see com.sun.star.sheet.RecentFunctions
56 * @see com.sun.star.sheet.XRecentFunctions
57 * @see ifc.sheet._XRecentFunctions
59 public class ScRecentFunctionsObj
extends TestCase
{
60 static XSpreadsheetDocument xSheetDoc
= null;
63 * Creates Spreadsheet document.
65 protected void initialize( TestParameters tParam
, PrintWriter log
) {
66 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
69 log
.println( "creating a Spreadsheet document" );
70 xSheetDoc
= SOF
.createCalcDoc(null);
71 } catch ( com
.sun
.star
.uno
.Exception e
) {
72 // Some exception occures.FAILED
73 e
.printStackTrace( log
);
74 throw new StatusException( "Couldn't create document", e
);
79 * Disposes Spreadsheet document.
81 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
82 log
.println( " disposing xSheetDoc " );
83 XComponent oComp
= (XComponent
)
84 UnoRuntime
.queryInterface(XComponent
.class, xSheetDoc
) ;
85 util
.DesktopTools
.closeDoc(oComp
);
89 * Creating a Testenvironment for the interfaces to be tested.
90 * Creates an instance of the service
91 * <code>com.sun.star.sheet.RecentFunctions</code> and an instance of the
92 * service <code>com.sun.star.sheet.FunctionDescriptions</code>.
93 * Object relations created :
95 * <li> <code>'FUNCTIONLIST'</code> for
96 * {@link ifc.sheet._XRecentFunctions}(the second created instance)</li>
99 public synchronized TestEnvironment
createTestEnvironment(
100 TestParameters Param
, PrintWriter log
) throws StatusException
{
102 XInterface oObj
= null;
103 XInterface allFunctions
= null;
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" );
110 log
.println("Getting test object ") ;
111 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
)Param
.getMSF();
112 oObj
= (XInterface
)oDocMSF
.createInstance(
113 "com.sun.star.sheet.RecentFunctions");
114 allFunctions
= (XInterface
)oDocMSF
.createInstance(
115 "com.sun.star.sheet.FunctionDescriptions");
117 log
.println("Creating object - " +
118 ((oObj
== null) ?
"FAILED" : "OK"));
119 } catch (com
.sun
.star
.uno
.Exception e
) {
120 e
.printStackTrace(log
) ;
121 throw new StatusException("Couldn't create instance", e
);
124 TestEnvironment tEnv
= new TestEnvironment( oObj
);
126 // Other parameters required for interface tests
127 XNameAccess NA
= (XNameAccess
)
128 UnoRuntime
.queryInterface(XNameAccess
.class, allFunctions
);
129 tEnv
.addObjRelation("FUNCTIONLIST", NA
);