bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScTableRowObj.java
blob0a4fe2dd5ccc2a7b9032c77cbf001ecb1fbd50ec
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._sc;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.container.XIndexAccess;
30 import com.sun.star.container.XNameAccess;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.sheet.XSpreadsheet;
33 import com.sun.star.sheet.XSpreadsheetDocument;
34 import com.sun.star.sheet.XSpreadsheets;
35 import com.sun.star.table.XColumnRowRange;
36 import com.sun.star.table.XTableRows;
37 import com.sun.star.uno.AnyConverter;
38 import com.sun.star.uno.Type;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.table.TableRow</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 * <li> <code>com::sun::star::table::TableRow</code></li>
48 * <li> <code>com::sun::star::table::XCellRange</code></li>
49 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
50 * </ul>
51 * @see com.sun.star.table.TableRow
52 * @see com.sun.star.table.XCellRange
53 * @see com.sun.star.beans.XPropertySet
54 * @see ifc.table._TableRow
55 * @see ifc.table._XCellRange
56 * @see ifc.beans._XPropertySet
58 public class ScTableRowObj extends TestCase {
59 private XSpreadsheetDocument xSheetDoc = null;
61 /**
62 * Creates Spreadsheet document.
64 @Override
65 protected void initialize( TestParameters tParam, PrintWriter log ) {
66 // get a soffice factory object
67 SOfficeFactory SOF = SOfficeFactory.getFactory( 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 occurs.FAILED
74 e.printStackTrace( log );
75 throw new StatusException( "Couldn't create document", e );
79 /**
80 * Disposes Spreadsheet document.
82 @Override
83 protected void cleanup( TestParameters tParam, PrintWriter log ) {
84 log.println( " disposing xSheetDoc " );
85 XComponent oComp = 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 the document and takes one of
92 * them. Obtains the collection of rows using the interface
93 * <code>XColumnRowRange</code>. Obtains the row with index 6 from the
94 * collection and this is the instance of the service
95 * <code>com.sun.star.table.TableRow</code>.
96 * Object relations created :
97 * <ul>
98 * <li> <code>'ValidRange'</code> for
99 * {@link ifc.table._XCellRange} </li>
100 * </ul>
101 * @see com.sun.star.table.XColumnRowRange
102 * @see com.sun.star.table.TableRow
104 @Override
105 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
107 XInterface oObj = null;
109 // creation of the testobject here
110 // first we write what we are intend to do to log file
111 log.println("creating a test environment");
113 XSpreadsheet xSpreadsheet = null;
114 XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
115 XNameAccess oNames = UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets );
116 try {
117 xSpreadsheet = (XSpreadsheet) AnyConverter.toObject(
118 new Type(XSpreadsheet.class),
119 oNames.getByName(oNames.getElementNames()[0]));
121 XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);
122 XTableRows oRows = oColumnRowRange.getRows();
123 XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, oRows);
124 oObj = (XInterface) AnyConverter.toObject(
125 new Type(XInterface.class),oIndexAccess.getByIndex(6));
126 } catch(com.sun.star.lang.WrappedTargetException e) {
127 e.printStackTrace(log);
128 throw new StatusException(
129 "Exception during creating Testenvironment", e);
130 } catch(com.sun.star.container.NoSuchElementException e) {
131 e.printStackTrace(log);
132 throw new StatusException(
133 "Exception during creating Testenvironment", e);
134 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
135 e.printStackTrace(log);
136 throw new StatusException(
137 "Exception during creating Testenvironment", e);
138 } catch(com.sun.star.lang.IllegalArgumentException e) {
139 e.printStackTrace(log);
140 throw new StatusException(
141 "Exception during creating Testenvironment", e);
144 log.println("creating a new environment for object");
145 TestEnvironment tEnv = new TestEnvironment(oObj);
146 tEnv.addObjRelation("ValidRange","A7:A7");
147 return tEnv;