xref: /AOO41X/main/qadevOOo/tests/java/mod/_sc/ScConsolidationDescriptor.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.lang.XComponent;
39 import com.sun.star.lang.XMultiServiceFactory;
40 import com.sun.star.sheet.XConsolidatable;
41 import com.sun.star.sheet.XSpreadsheetDocument;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
44 
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.sheet.ConsolidationDescriptor</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 *  <li> <code>com::sun::star::sheet::XConsolidationDescriptor</code></li>
51 * </ul>
52 * @see com.sun.star.sheet.ConsolidationDescriptor
53 * @see com.sun.star.sheet.XConsolidationDescriptor
54 * @see ifc.sheet._XConsolidationDescriptor
55 */
56 public class ScConsolidationDescriptor extends TestCase {
57     static XSpreadsheetDocument xSheetDoc = null;
58 
59     /**
60     * Creates Spreadsheet document.
61     */
62     protected void initialize( TestParameters tParam, PrintWriter log ) {
63         // get a soffice factory object
64         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
65 
66         try {
67             log.println( "creating a sheetdocument" );
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     * Disposes Spreadsheet document.
78     */
79     protected void cleanup( TestParameters tParam, PrintWriter log ) {
80         log.println( "    disposing xSheetDoc " );
81         XComponent oComp = (XComponent)
82             UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
83         util.DesktopTools.closeDoc(oComp);
84     }
85 
86     /**
87     * Creating a Testenvironment for the interfaces to be tested.
88     * Retrieves a collection of spreadsheets from a document
89     * and takes one of them. Creates consolidation description using
90     * the interface <code>XConsolidatable</code>.
91     * This description is the instance of the service
92     * <code>com.sun.star.sheet.ConsolidationDescriptor</code>.
93     * @see com.sun.star.sheet.ConsolidationDescriptor
94     * @see com.sun.star.sheet.XConsolidatable
95     */
96     protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
97 
98         XInterface oObj = null;
99 
100         // creation of testobject here
101         // first we write what we are intend to do to log file
102         log.println( "creating a test environment" );
103 
104         XConsolidatable xConsolidate = (XConsolidatable)
105             UnoRuntime.queryInterface(XConsolidatable.class, xSheetDoc);
106 
107         oObj = xConsolidate.createConsolidationDescriptor(true);
108         // create testobject here
109         log.println("creating a new environment for object");
110         TestEnvironment tEnv = new TestEnvironment(oObj);
111 
112         return tEnv;
113     } // finish method getTestEnvironment
114 
115 }    // finish class ScConsolidationDescriptor
116 
117