1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXTableRows.java,v $
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 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
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
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.table.TableRows</code>. <p>
51 * Object implements the following interfaces :
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>
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
;
70 * Creates text document.
72 protected void initialize( TestParameters tParam
, PrintWriter log
) {
73 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
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
);
84 * Disposes text document.
86 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
87 log
.println( " disposing xTextDoc " );
88 util
.DesktopTools
.closeDoc(xTextDoc
);
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
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() );
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: "
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: "
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
));
128 } // finish method getTestEnvironment
130 } // finish class SwXTableRows