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
;
32 import com
.sun
.star
.text
.XTextDocument
;
33 import com
.sun
.star
.uno
.XInterface
;
36 * Test for object which is represented by service
37 * <code>com.sun.star.text.Text</code>.<p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::text::XTextRangeMover</code></li>
41 * <li> <code>com::sun::star::text::XSimpleText</code></li>
42 * <li> <code>com::sun::star::text::XTextRange</code></li>
43 * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li>
44 * <li> <code>com::sun::star::text::XTextRangeCompare</code></li>
45 * <li> <code>com::sun::star::container::XElementAccess</code></li>
46 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
47 * <li> <code>com::sun::star::text::XText</code></li>
49 * This object test <b> is NOT </b> designed to be run in several
50 * threads concurently.
51 * @see com.sun.star.text.XTextRangeMover
52 * @see com.sun.star.text.XSimpleText
53 * @see com.sun.star.text.XTextRange
54 * @see com.sun.star.text.XRelativeTextContentInsert
55 * @see com.sun.star.text.XTextRangeCompare
56 * @see com.sun.star.container.XElementAccess
57 * @see com.sun.star.container.XEnumerationAccess
58 * @see com.sun.star.text.XText
59 * @see ifc.text._XTextRangeMover
60 * @see ifc.text._XSimpleText
61 * @see ifc.text._XTextRange
62 * @see ifc.text._XRelativeTextContentInsert
63 * @see ifc.text._XTextRangeCompare
64 * @see ifc.container._XElementAccess
65 * @see ifc.container._XEnumerationAccess
66 * @see ifc.text._XText
68 public class SwXBodyText
extends TestCase
{
69 XTextDocument xTextDoc
= null;
70 SOfficeFactory SOF
= null;
73 * Creates text document.
76 protected void initialize( TestParameters tParam
, PrintWriter log
) {
77 SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
79 log
.println( "creating a textdocument" );
80 xTextDoc
= SOF
.createTextDoc( null );
81 } catch ( com
.sun
.star
.uno
.Exception e
) {
82 e
.printStackTrace( log
);
83 throw new StatusException( "Couldn't create document", e
);
88 * 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.
98 * Obtains body text from text document.
99 * Object relations created :
101 * <li> <code>'TEXT'</code> for
102 * {@link ifc.text._XTextRangeCompare} : text</li>
103 * <li> <code>'XTEXTINFO'</code> for
104 * {@link ifc.text._XRelativeTextContentInsert},
105 * {@link ifc.text._XText} : creates 6x4 tables</li>
106 * <li> <code>'PARA'</code> for
107 * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li>
111 public synchronized TestEnvironment
createTestEnvironment(
112 TestParameters Param
, PrintWriter log
) throws StatusException
{
113 XInterface oObj
= null;
115 log
.println( "creating a test environment" );
117 // get the bodytext of textdocument here
118 log
.println( " getting the bodytext of textdocument with getText()" );
119 oObj
= xTextDoc
.getText();
121 log
.println( " creating a new environment for bodytext object" );
122 TestEnvironment tEnv
= new TestEnvironment( oObj
);
124 log
.println(" adding Text as ObjRelation");
125 tEnv
.addObjRelation("TEXT", oObj
);
127 log
.println( " adding InstDescriptor object" );
128 TableDsc tDsc
= new TableDsc( 6, 4 );
130 log
.println( " adding InstCreator object" );
131 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc
, tDsc
) );
133 log
.println( " adding Paragraph" );
134 ParagraphDsc pDsc
= new ParagraphDsc();
135 tEnv
.addObjRelation( "PARA", new InstCreator( xTextDoc
, pDsc
) );
138 } // finish method getTestEnvironment
140 } // finish class SwXBodyText