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
;
29 import com
.sun
.star
.beans
.XPropertySet
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.text
.XEndnotesSupplier
;
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
;
37 import com
.sun
.star
.uno
.XInterface
;
40 * Test for object which is represented by service
41 * <code>com.sun.star.text.FootnoteSettings</code>. <p>
42 * Object implements the following interfaces :
44 * <li> <code>com::sun::star::text::FootnoteSettings</code></li>
46 * This object test <b> is NOT </b> designed to be run in several
47 * threads concurrently.
48 * @see com.sun.star.text.FootnoteSettings
49 * @see ifc.text._FootnoteSettings
51 public class SwXEndnoteProperties
extends TestCase
{
52 XTextDocument xTextDoc
;
55 * Creates text document.
58 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
59 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
60 log
.println( "creating a textdocument" );
61 xTextDoc
= SOF
.createTextDoc( null );
65 * Disposes text document.
68 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
69 log
.println( " disposing xTextDoc " );
70 util
.DesktopTools
.closeDoc(xTextDoc
);
74 * Creating a TestEnvironment for the interfaces to be tested.
75 * Creates an instance of the service
76 * <code>com.sun.star.text.Endnote</code>. Then created endnote is inserted
77 * to the text document, and finally endnote settings are gotten from text
78 * document using <code>XEndnotesSupplier</code> interface.
81 public TestEnvironment
createTestEnvironment(
82 TestParameters Param
, PrintWriter log
) throws Exception
{
83 XEndnotesSupplier oInterface
= null;
84 XInterface oObj
= null;
87 log
.println( "Creating a test environment" );
88 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
89 log
.println("creating an endnote");
90 oEndnote
= UnoRuntime
.queryInterface(XInterface
.class,
91 msf
.createInstance("com.sun.star.text.Endnote"));
93 XText oText
= xTextDoc
.getText();
94 XTextCursor oCursor
= oText
.createTextCursor();
96 log
.println("inserting the footnote into text document");
97 XTextContent xTC
= UnoRuntime
.queryInterface(XTextContent
.class, oEndnote
);
98 oText
.insertTextContent(oCursor
, xTC
, false);
100 oInterface
= UnoRuntime
.queryInterface(XEndnotesSupplier
.class, xTextDoc
);
101 oObj
= oInterface
.getEndnoteSettings();
102 dbg
.printPropertiesNames((XPropertySet
) oObj
);
104 TestEnvironment tEnv
= new TestEnvironment(oObj
);