xref: /AOO41X/main/qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_SpreadsheetsEnumeration.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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.container.XEnumerationAccess;
39 import com.sun.star.lang.XComponent;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.sheet.XSpreadsheetDocument;
42 import com.sun.star.sheet.XSpreadsheets;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.uno.XInterface;
45 
46 public class ScIndexEnumeration_SpreadsheetsEnumeration extends TestCase {
47     private static XSpreadsheetDocument xSpreadsheetDoc = null;
48 
49     /**
50     * Creates Spreadsheet document.
51     */
52     public void initialize( TestParameters Param, PrintWriter log ) {
53         // get a soffice factory object
54 
55         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
56         try {
57             log.println("creating a spreadsheetdocument");
58             xSpreadsheetDoc = SOF.createCalcDoc(null);
59         } catch (com.sun.star.uno.Exception e) {
60             e.printStackTrace( log );
61             throw new StatusException( "Couldn't create document ", e );
62         }
63     }
64 
65     /**
66     * Disposes Spreadsheet document.
67     */
68     protected void cleanup( TestParameters tParam, PrintWriter log ) {
69         log.println("disposing xSpreadsheetDocument");
70         XComponent oComp = (XComponent)
71             UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc);
72         util.DesktopTools.closeDoc(oComp);
73     }
74 
75     protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
76 
77         log.println("getting sheets");
78         XSpreadsheets xSpreadsheets = (XSpreadsheets)xSpreadsheetDoc.getSheets();
79 
80         XInterface oObj = (XInterface)
81             UnoRuntime.queryInterface(XInterface.class, xSpreadsheets);
82 
83         log.println("creating a new environment for object");
84         XEnumerationAccess ea = (XEnumerationAccess)
85                     UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
86 
87         oObj = ea.createEnumeration();
88 
89         log.println("ImplementationName: "+util.utils.getImplName(oObj));
90         // creating test environment
91         TestEnvironment tEnv = new TestEnvironment( oObj );
92 
93         tEnv.addObjRelation("ENUM",ea);
94 
95         return tEnv;
96     }
97 }
98