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
.InstCreator
;
28 import util
.ParagraphDsc
;
29 import util
.SOfficeFactory
;
30 import util
.TextSectionDsc
;
32 import com
.sun
.star
.table
.XCell
;
33 import com
.sun
.star
.text
.XSimpleText
;
34 import com
.sun
.star
.text
.XTextDocument
;
35 import com
.sun
.star
.text
.XTextTable
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
40 * Test for object which is represented by cell text of the text table.<p>
41 * Object implements the following interfaces :
43 * <li> <code>com::sun::star::text::XTextRangeMover</code></li>
44 * <li> <code>com::sun::star::text::XSimpleText</code></li>
45 * <li> <code>com::sun::star::text::XTextRange</code></li>
46 * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li>
47 * <li> <code>com::sun::star::text::XTextRangeCompare</code></li>
48 * <li> <code>com::sun::star::container::XElementAccess</code></li>
49 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
50 * <li> <code>com::sun::star::text::XText</code></li>
52 * This object test <b> is NOT </b> designed to be run in several
53 * threads concurently.
54 * @see com.sun.star.text.XTextRangeMover
55 * @see com.sun.star.text.XSimpleText
56 * @see com.sun.star.text.XTextRange
57 * @see com.sun.star.text.XRelativeTextContentInsert
58 * @see com.sun.star.text.XTextRangeCompare
59 * @see com.sun.star.container.XElementAccess
60 * @see com.sun.star.container.XEnumerationAccess
61 * @see com.sun.star.text.XText
62 * @see ifc.text._XTextRangeMover
63 * @see ifc.text._XSimpleText
64 * @see ifc.text._XTextRange
65 * @see ifc.text._XRelativeTextContentInsert
66 * @see ifc.text._XTextRangeCompare
67 * @see ifc.container._XElementAccess
68 * @see ifc.container._XEnumerationAccess
69 * @see ifc.text._XText
71 public class SwXTableCellText
extends TestCase
{
72 XTextDocument xTextDoc
;
76 * Creates text document.
79 protected void initialize( TestParameters tParam
, PrintWriter log
) {
80 SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
82 log
.println( "creating a textdocument" );
83 xTextDoc
= SOF
.createTextDoc( null );
84 } catch ( com
.sun
.star
.uno
.Exception e
) {
85 e
.printStackTrace( log
);
86 throw new StatusException( "Couldn't create document", e
);
91 * Disposes text document.
94 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
95 log
.println( " disposing xTextDoc " );
96 util
.DesktopTools
.closeDoc(xTextDoc
);
100 * Creating a Testenvironment for the interfaces to be tested. After creation
101 * of text table, it is inserted to a text document. Then cell named 'A1' is
102 * obtained from table, string 'SwXTableCellText' is set to this cell, then
103 * cell text is gotten from cell obtained before and returned as a test
105 * Object relations created :
107 * <li> <code>'TEXT'</code> for
108 * {@link ifc.text._XTextRangeCompare} : table cell text</li>
109 * <li> <code>'PARA'</code> for
110 * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li>
111 * <li> <code>'XTEXTINFO'</code> for
112 * {@link ifc.text._XRelativeTextContentInsert},
113 * {@link ifc.text._XText} : creates text sections</li>
117 public synchronized TestEnvironment
createTestEnvironment(
118 TestParameters Param
, PrintWriter log
) throws StatusException
{
119 XInterface oObj
= null;
120 XTextTable oTable
= null;
122 log
.println( "Creating a test environment" );
123 oTable
= SOfficeFactory
.createTextTable( xTextDoc
);
126 SOfficeFactory
.insertTextContent(xTextDoc
, oTable
);
127 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
128 e
.printStackTrace( log
);
129 throw new StatusException("Couldn't insert text content : "
133 XCell oCell
= oTable
.getCellByName("A1");
134 XSimpleText oCellText
= UnoRuntime
.queryInterface(XSimpleText
.class, oCell
);
135 oCellText
.setString("SwXTableCellText");
136 oObj
= oCellText
.getText();
138 log
.println( "creating a new environment for Cell object" );
139 TestEnvironment tEnv
= new TestEnvironment( oObj
);
141 log
.println( "adding TextDocument as mod relation to environment" );
142 tEnv
.addObjRelation("TEXT", oObj
);
144 log
.println( " adding InstCreator object" );
145 TextSectionDsc tDsc
= new TextSectionDsc();
146 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc
, tDsc
) );
148 log
.println( " adding Paragraph" );
149 ParagraphDsc pDsc
= new ParagraphDsc();
150 tEnv
.addObjRelation( "PARA", new InstCreator( xTextDoc
, pDsc
) );
153 } // finish method getTestEnvironment
156 } // finish class SwXTableCellText