bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXBodyText.java
blobf10a161aa2af55e5511cc97f93af03364ae25bc0
1 /*
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 .
19 package mod._sw;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.InstCreator;
28 import util.ParagraphDsc;
29 import util.SOfficeFactory;
30 import util.TableDsc;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.text.Text</code>.<p>
39 * Object implements the following interfaces :
40 * <ul>
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>
49 * </ul> <p>
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;
73 /**
74 * Creates text document.
76 protected void initialize( TestParameters tParam, PrintWriter log ) {
77 SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
78 try {
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 );
87 /**
88 * Disposes text document.
90 protected void cleanup( TestParameters tParam, PrintWriter log ) {
91 log.println( " disposing xTextDoc " );
92 util.DesktopTools.closeDoc(xTextDoc);
95 /**
96 * Creating a Testenvironment for the interfaces to be tested.
97 * Obtains body text from text document.
98 * Object relations created :
99 * <ul>
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>
107 * </ul>
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 ) );
135 return tEnv;
136 } // finish method getTestEnvironment
138 } // finish class SwXBodyText