1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._sc;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 import util.SOfficeFactory;
33 
34 import com.sun.star.lang.XComponent;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.sheet.XSpreadsheetDocument;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
39 
40 /**
41 * Test for object which is represented by service
42 * <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>. <p>
43 * Object implements the following interfaces :
44 * <ul>
45 *  <li> <code>com::sun::star::sheet::SpreadsheetDocumentSettings</code></li>
46 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * </ul>
48 * @see com.sun.star.sheet.SpreadsheetDocumentSettings
49 * @see com.sun.star.beans.XPropertySet
50 * @see ifc.sheet._SpreadsheetDocumentSettings
51 * @see ifc.beans._XPropertySet
52 */
53 public class ScSpreadsheetSettingsObj extends TestCase {
54     static XSpreadsheetDocument xSheetDoc = null;
55 
56     /**
57     * Creates Spreadsheet document.
58     */
initialize( TestParameters tParam, PrintWriter log )59     protected void initialize( TestParameters tParam, PrintWriter log ) {
60         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
61 
62         try {
63             log.println( "creating a Spreadsheet document" );
64             xSheetDoc = SOF.createCalcDoc(null);
65         } catch ( com.sun.star.uno.Exception e ) {
66             // Some exception occures.FAILED
67             e.printStackTrace( log );
68             throw new StatusException( "Couldn't create document", e );
69         }
70 
71     }
72 
73     /**
74     * Disposes Spreadsheet document.
75     */
cleanup( TestParameters tParam, PrintWriter log )76     protected void cleanup( TestParameters tParam, PrintWriter log ) {
77         log.println( "    disposing xSheetDoc " );
78         XComponent oComp = (XComponent)
79             UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
80         util.DesktopTools.closeDoc(oComp);
81     }
82 
83     /**
84     * Creating a Testenvironment for the interfaces to be tested.
85     * The spreadsheet document is the instance of the service
86     * <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>.
87     */
createTestEnvironment( TestParameters Param, PrintWriter log)88     public synchronized TestEnvironment createTestEnvironment(
89         TestParameters Param, PrintWriter log) throws StatusException {
90 
91         XInterface oObj = null;
92 
93         // creation of testobject here
94         // first we write what we are intend to do to log file
95         log.println( "Creating a test environment" );
96 
97         oObj = xSheetDoc;
98 
99         TestEnvironment tEnv = new TestEnvironment( oObj );
100 
101         return tEnv;
102     }
103 
104 }
105 
106 
107