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
.text
.XTextContent
;
31 import com
.sun
.star
.text
.XTextDocument
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XInterface
;
36 * Test for object which is a cell of the table in a text document, and
37 * represented by service <code>com.sun.star.table.Cell</code><p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::text::CellProperties</code></li>
41 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
43 * This object test <b> is NOT </b> designed to be run in several
44 * threads concurently.
45 * @see com.sun.star.table.Cell
46 * @see com.sun.star.text.CellProperties
47 * @see com.sun.star.beans.XPropertySet
48 * @see ifc.text._CellProperties
49 * @see ifc.beans._XPropertySet
51 public class SwXCell
extends TestCase
{
52 XTextDocument xTextDoc
;
55 * Creates text document.
58 protected void initialize( TestParameters tParam
, PrintWriter log
) {
59 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
61 log
.println( "creating a textdocument" );
62 xTextDoc
= SOF
.createTextDoc( null );
63 } catch ( com
.sun
.star
.uno
.Exception e
) {
64 e
.printStackTrace( log
);
65 throw new StatusException( "Couldn't create document", e
);
70 * Disposes text document.
73 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
74 log
.println( " disposing xTextDoc " );
75 util
.DesktopTools
.closeDoc(xTextDoc
);
79 * Creating a Testenvironment for the interfaces to be tested. After creating
80 * a text table, it is inserted to the text document. Finally, first cell of
81 * this table is gotten.
82 * Object relations created :
84 * <li> <code>'CellProperties.TextSection'</code> for
85 * {@link ifc.text._CellProperties} : range of complete paragraphs
90 public TestEnvironment
createTestEnvironment(
91 TestParameters tParam
, PrintWriter log
) throws StatusException
{
92 XInterface oObj
= null;
93 XTextContent oTable
= null;
95 SOfficeFactory
.getFactory( tParam
.getMSF() );
96 log
.println( "creating a test environment" );
97 oTable
= SOfficeFactory
.createTextTable(xTextDoc
, 3, 4);
99 SOfficeFactory
.insertTextContent( xTextDoc
, oTable
);
100 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
101 log
.println("Unable to insert TextContent...");
102 e
.printStackTrace(log
);
104 oObj
= SOfficeFactory
.getFirstTableCell( oTable
);
106 log
.println( " creating a new environment for bodytext object" );
107 TestEnvironment tEnv
= new TestEnvironment( oObj
);
109 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
111 XInterface oTS
= (XInterface
) oDocMSF
.createInstance
112 ("com.sun.star.text.TextSection");
113 log
.println(" adding TextSection object");
114 tEnv
.addObjRelation("CellProperties.TextSection", oTS
);
115 } catch (com
.sun
.star
.uno
.Exception e
) {
116 log
.println("Could not get instance of TextSection");
117 e
.printStackTrace(log
);
121 } // finish method getTestEnvironment
122 } // finish class SwXCell