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.container.XEnumerationAccess;
35 import com.sun.star.lang.XComponent;
36 import com.sun.star.lang.XMultiServiceFactory;
37 import com.sun.star.sheet.XSpreadsheetDocument;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
40 
41 public class ScIndexEnumeration_TableAutoFormatEnumeration extends TestCase{
42     static XSpreadsheetDocument xSheetDoc = null;
43     static SOfficeFactory SOF = null;
44 
45     /**
46     * Creates Spreadsheet document.
47     */
initialize( TestParameters tParam, PrintWriter log )48     protected void initialize( TestParameters tParam, PrintWriter log ) {
49         SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
50 
51         try {
52             log.println( "creating a Spreadsheet document" );
53             xSheetDoc = SOF.createCalcDoc(null);
54         } catch ( com.sun.star.uno.Exception e ) {
55             // Some exception occures.FAILED
56             e.printStackTrace( log );
57             throw new StatusException( "Couldn't create document", e );
58         }
59     }
60 
61     /**
62     * Disposes Spreadsheet document.
63     */
cleanup( TestParameters tParam, PrintWriter log )64     protected void cleanup( TestParameters tParam, PrintWriter log ) {
65         log.println( "    disposing xSheetDoc " );
66         XComponent oComp = (XComponent) UnoRuntime.queryInterface
67             (XComponent.class, xSheetDoc) ;
68         util.DesktopTools.closeDoc(oComp);
69     }
70 
createTestEnvironment(TestParameters Param, PrintWriter log)71     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
72 
73         XInterface oObj = null;
74 
75         try {
76             // creation of testobject here
77             // get AutoFormats
78             oObj = (XInterface)((XMultiServiceFactory)Param.getMSF()).createInstance
79                 ("com.sun.star.sheet.TableAutoFormats");
80 
81             XEnumerationAccess ea = (XEnumerationAccess)
82                         UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
83 
84             oObj = ea.createEnumeration();
85 
86             log.println("ImplementationName: "+util.utils.getImplName(oObj));
87             // creating test environment
88             TestEnvironment tEnv = new TestEnvironment( oObj );
89 
90             tEnv.addObjRelation("ENUM",ea);
91 
92             return tEnv;
93         } catch (com.sun.star.uno.Exception e) {
94             log.println ("Exception occured while creating test Object.");
95             e.printStackTrace(log);
96             throw new StatusException("Couldn't create test object", e);
97         }
98     }
99 
100 }    // finish class ScAutoFormatsObj
101 
102