merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sc / ScConsolidationDescriptor.java
blob52b4cbbeffdbfbc23da4047efc7cb590ed73435f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScConsolidationDescriptor.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._sc;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.SOfficeFactory;
41 import com.sun.star.lang.XComponent;
42 import com.sun.star.lang.XMultiServiceFactory;
43 import com.sun.star.sheet.XConsolidatable;
44 import com.sun.star.sheet.XSpreadsheetDocument;
45 import com.sun.star.uno.UnoRuntime;
46 import com.sun.star.uno.XInterface;
48 /**
49 * Test for object which is represented by service
50 * <code>com.sun.star.sheet.ConsolidationDescriptor</code>. <p>
51 * Object implements the following interfaces :
52 * <ul>
53 * <li> <code>com::sun::star::sheet::XConsolidationDescriptor</code></li>
54 * </ul>
55 * @see com.sun.star.sheet.ConsolidationDescriptor
56 * @see com.sun.star.sheet.XConsolidationDescriptor
57 * @see ifc.sheet._XConsolidationDescriptor
59 public class ScConsolidationDescriptor extends TestCase {
60 static XSpreadsheetDocument xSheetDoc = null;
62 /**
63 * Creates Spreadsheet document.
65 protected void initialize( TestParameters tParam, PrintWriter log ) {
66 // get a soffice factory object
67 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
69 try {
70 log.println( "creating a sheetdocument" );
71 xSheetDoc = SOF.createCalcDoc(null);;
72 } catch (com.sun.star.uno.Exception e) {
73 // Some exception occures.FAILED
74 e.printStackTrace( log );
75 throw new StatusException( "Couldn't create document", e );
79 /**
80 * Disposes Spreadsheet document.
82 protected void cleanup( TestParameters tParam, PrintWriter log ) {
83 log.println( " disposing xSheetDoc " );
84 XComponent oComp = (XComponent)
85 UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
86 util.DesktopTools.closeDoc(oComp);
89 /**
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Retrieves a collection of spreadsheets from a document
92 * and takes one of them. Creates consolidation description using
93 * the interface <code>XConsolidatable</code>.
94 * This description is the instance of the service
95 * <code>com.sun.star.sheet.ConsolidationDescriptor</code>.
96 * @see com.sun.star.sheet.ConsolidationDescriptor
97 * @see com.sun.star.sheet.XConsolidatable
99 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
101 XInterface oObj = null;
103 // creation of testobject here
104 // first we write what we are intend to do to log file
105 log.println( "creating a test environment" );
107 XConsolidatable xConsolidate = (XConsolidatable)
108 UnoRuntime.queryInterface(XConsolidatable.class, xSheetDoc);
110 oObj = xConsolidate.createConsolidationDescriptor(true);
111 // create testobject here
112 log.println("creating a new environment for object");
113 TestEnvironment tEnv = new TestEnvironment(oObj);
115 return tEnv;
116 } // finish method getTestEnvironment
118 } // finish class ScConsolidationDescriptor