1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXBodyText.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.InstCreator
;
40 import util
.ParagraphDsc
;
41 import util
.SOfficeFactory
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.text
.XTextDocument
;
46 import com
.sun
.star
.uno
.XInterface
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.text.Text</code>.<p>
51 * Object implements the following interfaces :
53 * <li> <code>com::sun::star::text::XTextRangeMover</code></li>
54 * <li> <code>com::sun::star::text::XSimpleText</code></li>
55 * <li> <code>com::sun::star::text::XTextRange</code></li>
56 * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li>
57 * <li> <code>com::sun::star::text::XTextRangeCompare</code></li>
58 * <li> <code>com::sun::star::container::XElementAccess</code></li>
59 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
60 * <li> <code>com::sun::star::text::XText</code></li>
62 * This object test <b> is NOT </b> designed to be run in several
63 * threads concurently.
64 * @see com.sun.star.text.XTextRangeMover
65 * @see com.sun.star.text.XSimpleText
66 * @see com.sun.star.text.XTextRange
67 * @see com.sun.star.text.XRelativeTextContentInsert
68 * @see com.sun.star.text.XTextRangeCompare
69 * @see com.sun.star.container.XElementAccess
70 * @see com.sun.star.container.XEnumerationAccess
71 * @see com.sun.star.text.XText
72 * @see ifc.text._XTextRangeMover
73 * @see ifc.text._XSimpleText
74 * @see ifc.text._XTextRange
75 * @see ifc.text._XRelativeTextContentInsert
76 * @see ifc.text._XTextRangeCompare
77 * @see ifc.container._XElementAccess
78 * @see ifc.container._XEnumerationAccess
79 * @see ifc.text._XText
81 public class SwXBodyText
extends TestCase
{
82 XTextDocument xTextDoc
= null;;
83 SOfficeFactory SOF
= null;
86 * Creates text document.
88 protected void initialize( TestParameters tParam
, PrintWriter log
) {
89 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
91 log
.println( "creating a textdocument" );
92 xTextDoc
= SOF
.createTextDoc( null );
93 } catch ( com
.sun
.star
.uno
.Exception e
) {
94 e
.printStackTrace( log
);
95 throw new StatusException( "Couldn't create document", e
);
100 * Disposes text document.
102 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
103 log
.println( " disposing xTextDoc " );
104 util
.DesktopTools
.closeDoc(xTextDoc
);
108 * Creating a Testenvironment for the interfaces to be tested.
109 * Obtains body text from text document.
110 * Object relations created :
112 * <li> <code>'TEXT'</code> for
113 * {@link ifc.text._XTextRangeCompare} : text</li>
114 * <li> <code>'XTEXTINFO'</code> for
115 * {@link ifc.text._XRelativeTextContentInsert},
116 * {@link ifc.text._XText} : creates 6x4 tables</li>
117 * <li> <code>'PARA'</code> for
118 * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li>
121 public synchronized TestEnvironment
createTestEnvironment(
122 TestParameters Param
, PrintWriter log
) throws StatusException
{
123 XInterface oObj
= null;
125 log
.println( "creating a test environment" );
127 // get the bodytext of textdocument here
128 log
.println( " getting the bodytext of textdocument with getText()" );
129 oObj
= xTextDoc
.getText();
131 log
.println( " creating a new environment for bodytext object" );
132 TestEnvironment tEnv
= new TestEnvironment( oObj
);
134 log
.println(" adding Text as ObjRelation");
135 tEnv
.addObjRelation("TEXT", oObj
);
137 log
.println( " adding InstDescriptor object" );
138 TableDsc tDsc
= new TableDsc( 6, 4 );
140 log
.println( " adding InstCreator object" );
141 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc
, tDsc
) );
143 log
.println( " adding Paragraph" );
144 ParagraphDsc pDsc
= new ParagraphDsc();
145 tEnv
.addObjRelation( "PARA", new InstCreator( xTextDoc
, pDsc
) );
148 } // finish method getTestEnvironment
150 } // finish class SwXBodyText