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 concurrently.
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
) throws Exception
{
59 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
60 log
.println( "creating a textdocument" );
61 xTextDoc
= SOF
.createTextDoc( null );
65 * Disposes text document.
68 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
69 log
.println( " disposing xTextDoc " );
70 util
.DesktopTools
.closeDoc(xTextDoc
);
74 * Creating a TestEnvironment for the interfaces to be tested. After creating
75 * a text table, it is inserted to the text document. Finally, first cell of
76 * this table is gotten.
77 * Object relations created :
79 * <li> <code>'CellProperties.TextSection'</code> for
80 * {@link ifc.text._CellProperties} : range of complete paragraphs
85 public TestEnvironment
createTestEnvironment(
86 TestParameters tParam
, PrintWriter log
) throws StatusException
{
87 XInterface oObj
= null;
88 XTextContent oTable
= null;
90 SOfficeFactory
.getFactory( tParam
.getMSF() );
91 log
.println( "creating a test environment" );
92 oTable
= SOfficeFactory
.createTextTable(xTextDoc
, 3, 4);
94 SOfficeFactory
.insertTextContent( xTextDoc
, oTable
);
95 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
96 log
.println("Unable to insert TextContent...");
97 e
.printStackTrace(log
);
99 oObj
= SOfficeFactory
.getFirstTableCell( oTable
);
101 log
.println( " creating a new environment for bodytext object" );
102 TestEnvironment tEnv
= new TestEnvironment( oObj
);
104 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
106 XInterface oTS
= (XInterface
) oDocMSF
.createInstance
107 ("com.sun.star.text.TextSection");
108 log
.println(" adding TextSection object");
109 tEnv
.addObjRelation("CellProperties.TextSection", oTS
);
110 } catch (com
.sun
.star
.uno
.Exception e
) {
111 log
.println("Could not get instance of TextSection");
112 e
.printStackTrace(log
);
116 } // finish method getTestEnvironment
117 } // finish class SwXCell