bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTableRows.java
blob6bc0375576336c2e3eee3c9e99122480ee8c1b94
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._sw;
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.lang.XMultiServiceFactory;
30 import com.sun.star.table.XCellRange;
31 import com.sun.star.text.XTextDocument;
32 import com.sun.star.text.XTextTable;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.table.TableRows</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::container::XElementAccess</code></li>
43 * <li> <code>com::sun::star::table::XTableRows</code></li>
44 * </ul> <p>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurently.
47 * @see com.sun.star.container.XIndexAccess
48 * @see com.sun.star.container.XElementAccess
49 * @see com.sun.star.table.XTableRows
50 * @see ifc.container._XIndexAccess
51 * @see ifc.container._XElementAccess
52 * @see ifc.table._XTableRows
54 public class SwXTableRows extends TestCase {
55 XTextDocument xTextDoc;
57 /**
58 * Creates text document.
60 protected void initialize( TestParameters tParam, PrintWriter log ) {
61 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
62 try {
63 log.println( "creating a textdocument" );
64 xTextDoc = SOF.createTextDoc( null );
65 } catch ( com.sun.star.uno.Exception e ) {
66 e.printStackTrace( log );
67 throw new StatusException( "Couldn't create document", e );
71 /**
72 * Disposes text document.
74 protected void cleanup( TestParameters tParam, PrintWriter log ) {
75 log.println( " disposing xTextDoc " );
76 util.DesktopTools.closeDoc(xTextDoc);
79 /**
80 * Creating a Testenvironment for the interfaces to be tested. After creation
81 * of text table, it is inserted to text document, then rows are gotten
82 * from table.
84 public synchronized TestEnvironment createTestEnvironment(
85 TestParameters tParam, PrintWriter log ) throws StatusException {
86 XInterface oObj = null;
87 XTextTable oTable = null;
89 log.println( "creating a test environment" );
90 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
91 try {
92 oTable = SOfficeFactory.createTextTable( xTextDoc );
93 } catch ( com.sun.star.uno.Exception e ) {
94 e.printStackTrace( log );
95 throw new StatusException("Couldn't create TextTable: "
96 +e.getMessage(),e);
99 try {
100 SOfficeFactory.insertTextContent(xTextDoc, oTable );
101 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
102 e.printStackTrace( log );
103 throw new StatusException("Couldn't insert text content: "
104 +e.getMessage(),e);
106 oObj = oTable.getRows();
108 log.println( "creating a new environment for TableColumns object" );
109 TestEnvironment tEnv = new TestEnvironment( oObj );
111 // adding relation for XTableColumns
112 tEnv.addObjRelation("XTableRows.XCellRange",
113 UnoRuntime.queryInterface(XCellRange.class, oTable));
115 return tEnv;
116 } // finish method getTestEnvironment
118 } // finish class SwXTableRows