merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_TableRowsEnumeration.java
blobcc7c255487d1b1abdb0105b7c68bae1f27c5c147
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: ScIndexEnumeration_TableRowsEnumeration.java,v $
10 * $Revision: 1.9 $
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.container.XEnumerationAccess;
42 import com.sun.star.container.XNameAccess;
43 import com.sun.star.lang.XComponent;
44 import com.sun.star.lang.XMultiServiceFactory;
45 import com.sun.star.sheet.XSpreadsheet;
46 import com.sun.star.sheet.XSpreadsheetDocument;
47 import com.sun.star.sheet.XSpreadsheets;
48 import com.sun.star.table.XColumnRowRange;
49 import com.sun.star.table.XTableRows;
50 import com.sun.star.uno.AnyConverter;
51 import com.sun.star.uno.Type;
52 import com.sun.star.uno.UnoRuntime;
53 import com.sun.star.uno.XInterface;
55 public class ScIndexEnumeration_TableRowsEnumeration extends TestCase {
56 static XSpreadsheetDocument xSheetDoc = null;
58 /**
59 * Creates Spreadsheet document.
61 protected void initialize( TestParameters tParam, PrintWriter log ) {
62 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
64 try {
65 log.println( "creating a Spreadsheet document" );
66 xSheetDoc = SOF.createCalcDoc(null);
67 } catch ( com.sun.star.uno.Exception e ) {
68 // Some exception occures.FAILED
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
74 /**
75 * Disposes Spreadsheet document.
77 protected void cleanup( TestParameters tParam, PrintWriter log ) {
78 log.println( " disposing xSheetDoc " );
79 XComponent oComp = (XComponent)
80 UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
81 util.DesktopTools.closeDoc(oComp);
84 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
86 XInterface oObj = null;
88 log.println("getting row");
89 XSpreadsheet xSpreadsheet = null;
91 XSpreadsheets xSpreadsheets = (XSpreadsheets)xSheetDoc.getSheets();
92 XNameAccess oNames = (XNameAccess)
93 UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets );
94 try {
95 xSpreadsheet = (XSpreadsheet) AnyConverter.toObject(
96 new Type(XSpreadsheet.class),
97 oNames.getByName(oNames.getElementNames()[0]));
98 } catch(com.sun.star.lang.WrappedTargetException e) {
99 e.printStackTrace(log);
100 throw new StatusException("Couldn't get spreadsheet", e);
101 } catch(com.sun.star.container.NoSuchElementException e) {
102 e.printStackTrace(log);
103 throw new StatusException("Couldn't get spreadsheet", e);
104 } catch(com.sun.star.lang.IllegalArgumentException e) {
105 e.printStackTrace(log);
106 throw new StatusException("Couldn't get spreadsheet", e);
109 XColumnRowRange oColumnRowRange = (XColumnRowRange)
110 UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);
112 XTableRows oRows = (XTableRows) oColumnRowRange.getRows();
113 oObj = oRows;
115 log.println("creating a new environment for object");
117 XEnumerationAccess ea = (XEnumerationAccess)
118 UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
120 oObj = ea.createEnumeration();
122 log.println("ImplementationName: "+util.utils.getImplName(oObj));
123 // creating test environment
124 TestEnvironment tEnv = new TestEnvironment( oObj );
126 tEnv.addObjRelation("ENUM",ea);
128 return tEnv;