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
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.lang
.XMultiServiceFactory
;
29 import com
.sun
.star
.text
.XFootnote
;
30 import com
.sun
.star
.text
.XFootnotesSupplier
;
31 import com
.sun
.star
.text
.XText
;
32 import com
.sun
.star
.text
.XTextCursor
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.uno
.XInterface
;
39 * Test for the object, which is represented as set of footnote properties
40 * (instance of <code>com.sun.star.text.FootnoteSettings</code> service).
41 * Object implements the following interfaces :
43 * <li> <code>com::sun::star::text::FootnoteSettings</code></li>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurrently.
47 * @see com.sun.star.text.FootnoteSettings
48 * @see ifc.text._FootnoteSettings
50 public class SwXFootnoteProperties
extends TestCase
{
51 XTextDocument xTextDoc
;
54 * Creates text document.
57 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
58 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
59 log
.println( "creating a textdocument" );
60 xTextDoc
= SOF
.createTextDoc( null );
64 * Disposes text document.
67 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
68 log
.println( " disposing xTextDoc " );
69 util
.DesktopTools
.closeDoc(xTextDoc
);
73 * Creating a TestEnvironment for the interfaces to be tested.
74 * Creates an instance of the service
75 * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote
76 * to the text document, and finally gets footnote settings from text
77 * document through <code>XFootnotesSupplier</code> interface.<br>
80 public TestEnvironment
createTestEnvironment(
81 TestParameters Param
, PrintWriter log
) throws Exception
{
82 XFootnotesSupplier oInterface
= null;
83 XInterface oObj
= null;
86 log
.println( "Creating a test environment" );
87 // get a soffice factory object
88 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
89 log
.println("creating a footnote");
91 oFootnote
= UnoRuntime
.queryInterface(XFootnote
.class,
92 msf
.createInstance("com.sun.star.text.Footnote"));
94 XText oText
= xTextDoc
.getText();
95 XTextCursor oCursor
= oText
.createTextCursor();
97 log
.println("inserting the footnote into text document");
98 oText
.insertTextContent(oCursor
, oFootnote
, false);
100 oInterface
= UnoRuntime
.queryInterface(XFootnotesSupplier
.class, xTextDoc
);
101 oObj
= oInterface
.getFootnoteSettings();
103 TestEnvironment tEnv
= new TestEnvironment(oObj
);