Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / mod / _sw / SwXTableRows.java
blob644ea9a4d637dae6c9dc96fcc0085d34db7f15fb
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: SwXTableRows.java,v $
10 * $Revision: 1.7 $
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._sw;
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.XMultiServiceFactory;
42 import com.sun.star.table.XCellRange;
43 import com.sun.star.text.XTextDocument;
44 import com.sun.star.text.XTextTable;
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.table.TableRows</code>. <p>
51 * Object implements the following interfaces :
52 * <ul>
53 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
54 * <li> <code>com::sun::star::container::XElementAccess</code></li>
55 * <li> <code>com::sun::star::table::XTableRows</code></li>
56 * </ul> <p>
57 * This object test <b> is NOT </b> designed to be run in several
58 * threads concurently.
59 * @see com.sun.star.container.XIndexAccess
60 * @see com.sun.star.container.XElementAccess
61 * @see com.sun.star.table.XTableRows
62 * @see ifc.container._XIndexAccess
63 * @see ifc.container._XElementAccess
64 * @see ifc.table._XTableRows
66 public class SwXTableRows extends TestCase {
67 XTextDocument xTextDoc;
69 /**
70 * Creates text document.
72 protected void initialize( TestParameters tParam, PrintWriter log ) {
73 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
74 try {
75 log.println( "creating a textdocument" );
76 xTextDoc = SOF.createTextDoc( null );
77 } catch ( com.sun.star.uno.Exception e ) {
78 e.printStackTrace( log );
79 throw new StatusException( "Couldn't create document", e );
83 /**
84 * Disposes text document.
86 protected void cleanup( TestParameters tParam, PrintWriter log ) {
87 log.println( " disposing xTextDoc " );
88 util.DesktopTools.closeDoc(xTextDoc);
91 /**
92 * Creating a Testenvironment for the interfaces to be tested. After creation
93 * of text table, it is inserted to text document, then rows are gotten
94 * from table.
96 public synchronized TestEnvironment createTestEnvironment(
97 TestParameters tParam, PrintWriter log ) throws StatusException {
98 XInterface oObj = null;
99 XTextTable oTable = null;
101 log.println( "creating a test environment" );
102 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
103 try {
104 oTable = SOF.createTextTable( xTextDoc );
105 } catch ( com.sun.star.uno.Exception e ) {
106 e.printStackTrace( log );
107 throw new StatusException("Couldn't create TextTable: "
108 +e.getMessage(),e);
111 try {
112 SOF.insertTextContent(xTextDoc, oTable );
113 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
114 e.printStackTrace( log );
115 throw new StatusException("Couldn't insert text content: "
116 +e.getMessage(),e);
118 oObj = oTable.getRows();
120 log.println( "creating a new environment for TableColumns object" );
121 TestEnvironment tEnv = new TestEnvironment( oObj );
123 // adding relation for XTableColumns
124 tEnv.addObjRelation("XTableRows.XCellRange",
125 UnoRuntime.queryInterface(XCellRange.class, oTable));
127 return tEnv;
128 } // finish method getTestEnvironment
130 } // finish class SwXTableRows