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.SpreadsheetDocumentSettings</code>. <p>
47 * Object implements the following interfaces :
48 * <ul>
49 *  <li> <code>com::sun::star::sheet::SpreadsheetDocumentSettings</code></li>
50 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * </ul>
52 * @see com.sun.star.sheet.SpreadsheetDocumentSettings
53 * @see com.sun.star.beans.XPropertySet
54 * @see ifc.sheet._SpreadsheetDocumentSettings
55 * @see ifc.beans._XPropertySet
56 */
57 public class ScSpreadsheetSettingsObj extends TestCase {
58     static XSpreadsheetDocument xSheetDoc = null;
59 
60     /**
61     * Creates Spreadsheet document.
62     */
63     protected void initialize( TestParameters tParam, PrintWriter log ) {
64         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
65 
66         try {
67             log.println( "creating a Spreadsheet document" );
68             xSheetDoc = SOF.createCalcDoc(null);
69         } catch ( com.sun.star.uno.Exception e ) {
70             // Some exception occures.FAILED
71             e.printStackTrace( log );
72             throw new StatusException( "Couldn't create document", e );
73         }
74 
75     }
76 
77     /**
78     * Disposes Spreadsheet document.
79     */
80     protected void cleanup( TestParameters tParam, PrintWriter log ) {
81         log.println( "    disposing xSheetDoc " );
82         XComponent oComp = (XComponent)
83             UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
84         util.DesktopTools.closeDoc(oComp);
85     }
86 
87     /**
88     * Creating a Testenvironment for the interfaces to be tested.
89     * The spreadsheet document is the instance of the service
90     * <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>.
91     */
92     public synchronized TestEnvironment createTestEnvironment(
93         TestParameters Param, PrintWriter log) throws StatusException {
94 
95         XInterface oObj = null;
96 
97         // creation of testobject here
98         // first we write what we are intend to do to log file
99         log.println( "Creating a test environment" );
100 
101         oObj = xSheetDoc;
102 
103         TestEnvironment tEnv = new TestEnvironment( oObj );
104 
105         return tEnv;
106     }
107 
108 }
109 
110 
111