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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
27 import util
.InstCreator
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.text
.XFootnote
;
32 import com
.sun
.star
.text
.XText
;
33 import com
.sun
.star
.text
.XTextContent
;
34 import com
.sun
.star
.text
.XTextCursor
;
35 import com
.sun
.star
.text
.XTextDocument
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
39 * Test for object which is represented by service
40 * <code>com.sun.star.text.Footnote</code>. <p>
41 * Object implements the following interfaces :
43 * <li> <code>com::sun::star::text::XFootnote</code></li>
44 * <li> <code>com::sun::star::lang::XComponent</code></li>
45 * <li> <code>com::sun::star::text::XSimpleText</code></li>
46 * <li> <code>com::sun::star::text::Footnote</code></li>
47 * <li> <code>com::sun::star::text::XTextContent</code></li>
48 * <li> <code>com::sun::star::text::XTextRange</code></li>
49 * <li> <code>com::sun::star::text::XText</code></li>
51 * This object test <b> is NOT </b> designed to be run in several
52 * threads concurrently.
53 * @see com.sun.star.text.XFootnote
54 * @see com.sun.star.lang.XComponent
55 * @see com.sun.star.text.XSimpleText
56 * @see com.sun.star.text.Footnote
57 * @see com.sun.star.text.XTextContent
58 * @see com.sun.star.text.XTextRange
59 * @see com.sun.star.text.XText
60 * @see ifc.text._XFootnote
61 * @see ifc.lang._XComponent
62 * @see ifc.text._XSimpleText
63 * @see ifc.text._Footnote
64 * @see ifc.text._XTextContent
65 * @see ifc.text._XTextRange
66 * @see ifc.text._XText
68 public class SwXFootnote
extends TestCase
{
69 XTextDocument xTextDoc
;
72 * Creates text document.
75 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
76 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
77 log
.println( "creating a textdocument" );
78 xTextDoc
= SOF
.createTextDoc( null );
82 * Disposes text document.
85 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
86 log
.println( " disposing xTextDoc " );
87 util
.DesktopTools
.closeDoc(xTextDoc
);
91 * Creating a TestEnvironment for the interfaces to be tested.
92 * Creates an instance of the service
93 * <code>com.sun.star.text.Footnote</code>. Then inserts created footnote
94 * to a text of document as content.
95 * Object relations created :
97 * <li><code>'XTEXTINFO'</code> for
98 * {@link ifc.text._XText} </li>
102 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) throws Exception
{
105 log
.println( "Creating a test environment" );
106 // get a soffice factory object
107 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
108 log
.println("creating a footnote");
109 Object instance
= null;
110 oFootnote
= UnoRuntime
.queryInterface(XFootnote
.class,
111 msf
.createInstance("com.sun.star.text.Footnote"));
112 instance
= msf
.createInstance("com.sun.star.text.Footnote");
114 XText oText
= xTextDoc
.getText();
115 XTextCursor oCursor
= oText
.createTextCursor();
117 log
.println("inserting the footnote into text document");
118 oText
.insertTextContent(oCursor
, oFootnote
, false);
120 TestEnvironment tEnv
= new TestEnvironment(oFootnote
);
122 tEnv
.addObjRelation("CONTENT", UnoRuntime
.queryInterface(XTextContent
.class,instance
));
123 tEnv
.addObjRelation("RANGE", xTextDoc
.getText().createTextCursor());
125 log
.println( "adding InstDescriptor object" );
126 FrameDsc tDsc
= new FrameDsc( 3000, 6000 );
127 log
.println( "adding InstCreator object" );
128 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc
, tDsc
) );
133 } // finish class SwXFootnote