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: SwXTableColumns.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.TableColumns</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::container::XNameAccess</code></li>
56 * <li> <code>com::sun::star::table::XTableColumns</code></li>
58 * This object test <b> is NOT </b> designed to be run in several
59 * threads concurently.
60 * @see com.sun.star.container.XIndexAccess
61 * @see com.sun.star.container.XElementAccess
62 * @see com.sun.star.container.XNameAccess
63 * @see com.sun.star.table.XTableColumns
64 * @see com.sun.star.table.TableColumns
65 * @see ifc.container._XIndexAccess
66 * @see ifc.container._XElementAccess
67 * @see ifc.container._XNameAccess
68 * @see ifc.table._XTableColumns
70 public class SwXTableColumns
extends TestCase
{
71 XTextDocument xTextDoc
;
75 * Creates text document.
77 protected void initialize( TestParameters tParam
, PrintWriter log
) {
78 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
80 log
.println( "creating a textdocument" );
81 xTextDoc
= SOF
.createTextDoc( null );
82 } catch ( com
.sun
.star
.uno
.Exception e
) {
83 e
.printStackTrace( log
);
84 throw new StatusException( "Couldn't create document", e
);
89 * Disposes text document.
91 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
92 log
.println( " disposing xTextDoc " );
93 util
.DesktopTools
.closeDoc(xTextDoc
);
97 * Creating a Testenvironment for the interfaces to be tested. After creation
98 * of text table, it is inserted to text document, then columns are gotten
101 public synchronized TestEnvironment
createTestEnvironment(
102 TestParameters tParam
, PrintWriter log
) throws StatusException
{
103 XInterface oObj
= null;
104 XTextTable oTable
= null;
106 log
.println( "creating a test environment" );
109 oTable
= SOF
.createTextTable( xTextDoc
);
110 } catch ( com
.sun
.star
.uno
.Exception e
) {
111 e
.printStackTrace( log
);
112 throw new StatusException("Couldn't create TextTable: "
117 SOF
.insertTextContent(xTextDoc
, oTable
);
118 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
119 e
.printStackTrace( log
);
120 throw new StatusException("Couldn't insert text content: "
124 oObj
= oTable
.getColumns();
126 log
.println( "creating a new environment for TableColumns object" );
127 TestEnvironment tEnv
= new TestEnvironment( oObj
);
129 // adding relation for XTableColumns
130 tEnv
.addObjRelation("XTableColumns.XCellRange",
131 UnoRuntime
.queryInterface(XCellRange
.class, oTable
));
133 tEnv
.addObjRelation("XIndexAccess.getByIndex.mustBeNull", new Boolean(true));
136 } // finish method getTestEnvironment
138 } // finish class SwXTableColumns