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
.lang
.XMultiServiceFactory
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.uno
.XInterface
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.text.Text</code>.<p>
39 * Object implements the following interfaces :
41 * <li> <code>com::sun::star::text::XTextRangeMover</code></li>
42 * <li> <code>com::sun::star::text::XSimpleText</code></li>
43 * <li> <code>com::sun::star::text::XTextRange</code></li>
44 * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li>
45 * <li> <code>com::sun::star::text::XTextRangeCompare</code></li>
46 * <li> <code>com::sun::star::container::XElementAccess</code></li>
47 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
48 * <li> <code>com::sun::star::text::XText</code></li>
50 * This object test <b> is NOT </b> designed to be run in several
51 * threads concurently.
52 * @see com.sun.star.text.XTextRangeMover
53 * @see com.sun.star.text.XSimpleText
54 * @see com.sun.star.text.XTextRange
55 * @see com.sun.star.text.XRelativeTextContentInsert
56 * @see com.sun.star.text.XTextRangeCompare
57 * @see com.sun.star.container.XElementAccess
58 * @see com.sun.star.container.XEnumerationAccess
59 * @see com.sun.star.text.XText
60 * @see ifc.text._XTextRangeMover
61 * @see ifc.text._XSimpleText
62 * @see ifc.text._XTextRange
63 * @see ifc.text._XRelativeTextContentInsert
64 * @see ifc.text._XTextRangeCompare
65 * @see ifc.container._XElementAccess
66 * @see ifc.container._XEnumerationAccess
67 * @see ifc.text._XText
69 public class SwXBodyText
extends TestCase
{
70 XTextDocument xTextDoc
= null;
71 SOfficeFactory SOF
= null;
74 * Creates text document.
76 protected void initialize( TestParameters tParam
, PrintWriter log
) {
77 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)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.
90 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
91 log
.println( " disposing xTextDoc " );
92 util
.DesktopTools
.closeDoc(xTextDoc
);
96 * Creating a Testenvironment for the interfaces to be tested.
97 * Obtains body text from text document.
98 * Object relations created :
100 * <li> <code>'TEXT'</code> for
101 * {@link ifc.text._XTextRangeCompare} : text</li>
102 * <li> <code>'XTEXTINFO'</code> for
103 * {@link ifc.text._XRelativeTextContentInsert},
104 * {@link ifc.text._XText} : creates 6x4 tables</li>
105 * <li> <code>'PARA'</code> for
106 * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li>
109 public synchronized TestEnvironment
createTestEnvironment(
110 TestParameters Param
, PrintWriter log
) throws StatusException
{
111 XInterface oObj
= null;
113 log
.println( "creating a test environment" );
115 // get the bodytext of textdocument here
116 log
.println( " getting the bodytext of textdocument with getText()" );
117 oObj
= xTextDoc
.getText();
119 log
.println( " creating a new environment for bodytext object" );
120 TestEnvironment tEnv
= new TestEnvironment( oObj
);
122 log
.println(" adding Text as ObjRelation");
123 tEnv
.addObjRelation("TEXT", oObj
);
125 log
.println( " adding InstDescriptor object" );
126 TableDsc tDsc
= new TableDsc( 6, 4 );
128 log
.println( " adding InstCreator object" );
129 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc
, tDsc
) );
131 log
.println( " adding Paragraph" );
132 ParagraphDsc pDsc
= new ParagraphDsc();
133 tEnv
.addObjRelation( "PARA", new InstCreator( xTextDoc
, pDsc
) );
136 } // finish method getTestEnvironment
138 } // finish class SwXBodyText