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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
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
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.table.TableColumns</code>. <p>
39 * Object implements the following interfaces :
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::container::XNameAccess</code></li>
44 * <li> <code>com::sun::star::table::XTableColumns</code></li>
46 * This object test <b> is NOT </b> designed to be run in several
47 * threads concurently.
48 * @see com.sun.star.container.XIndexAccess
49 * @see com.sun.star.container.XElementAccess
50 * @see com.sun.star.container.XNameAccess
51 * @see com.sun.star.table.XTableColumns
52 * @see com.sun.star.table.TableColumns
53 * @see ifc.container._XIndexAccess
54 * @see ifc.container._XElementAccess
55 * @see ifc.container._XNameAccess
56 * @see ifc.table._XTableColumns
58 public class SwXTableColumns
extends TestCase
{
59 XTextDocument xTextDoc
;
63 * Creates text document.
65 protected void initialize( TestParameters tParam
, PrintWriter log
) {
66 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
68 log
.println( "creating a textdocument" );
69 xTextDoc
= SOF
.createTextDoc( null );
70 } catch ( com
.sun
.star
.uno
.Exception e
) {
71 e
.printStackTrace( log
);
72 throw new StatusException( "Couldn't create document", e
);
77 * Disposes text document.
79 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
80 log
.println( " disposing xTextDoc " );
81 util
.DesktopTools
.closeDoc(xTextDoc
);
85 * Creating a Testenvironment for the interfaces to be tested. After creation
86 * of text table, it is inserted to text document, then columns are gotten
89 public synchronized TestEnvironment
createTestEnvironment(
90 TestParameters tParam
, PrintWriter log
) throws StatusException
{
91 XInterface oObj
= null;
92 XTextTable oTable
= null;
94 log
.println( "creating a test environment" );
97 oTable
= SOfficeFactory
.createTextTable( xTextDoc
);
98 } catch ( com
.sun
.star
.uno
.Exception e
) {
99 e
.printStackTrace( log
);
100 throw new StatusException("Couldn't create TextTable: "
105 SOfficeFactory
.insertTextContent(xTextDoc
, oTable
);
106 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
107 e
.printStackTrace( log
);
108 throw new StatusException("Couldn't insert text content: "
112 oObj
= oTable
.getColumns();
114 log
.println( "creating a new environment for TableColumns object" );
115 TestEnvironment tEnv
= new TestEnvironment( oObj
);
117 // adding relation for XTableColumns
118 tEnv
.addObjRelation("XTableColumns.XCellRange",
119 UnoRuntime
.queryInterface(XCellRange
.class, oTable
));
121 tEnv
.addObjRelation("XIndexAccess.getByIndex.mustBeNull", new Boolean(true));
124 } // finish method getTestEnvironment
126 } // finish class SwXTableColumns