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
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.SOfficeFactory
;
30 import com
.sun
.star
.beans
.XPropertySet
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.text
.XEndnotesSupplier
;
33 import com
.sun
.star
.text
.XText
;
34 import com
.sun
.star
.text
.XTextContent
;
35 import com
.sun
.star
.text
.XTextCursor
;
36 import com
.sun
.star
.text
.XTextDocument
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
41 * Test for object which is represented by service
42 * <code>com.sun.star.text.FootnoteSettings</code>. <p>
43 * Object implements the following interfaces :
45 * <li> <code>com::sun::star::text::FootnoteSettings</code></li>
47 * This object test <b> is NOT </b> designed to be run in several
48 * threads concurently.
49 * @see com.sun.star.text.FootnoteSettings
50 * @see ifc.text._FootnoteSettings
52 public class SwXEndnoteProperties
extends TestCase
{
53 XTextDocument xTextDoc
;
56 * Creates text document.
59 protected void initialize( TestParameters tParam
, PrintWriter log
) {
60 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
62 log
.println( "creating a textdocument" );
63 xTextDoc
= SOF
.createTextDoc( null );
64 } catch ( com
.sun
.star
.uno
.Exception e
) {
65 e
.printStackTrace( log
);
66 throw new StatusException( "Couldn't create document", e
);
71 * Disposes text document.
74 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
75 log
.println( " disposing xTextDoc " );
76 util
.DesktopTools
.closeDoc(xTextDoc
);
80 * Creating a Testenvironment for the interfaces to be tested.
81 * Creates an instance of the service
82 * <code>com.sun.star.text.Endnote</code>. Then created endnote is inserted
83 * to the text document, and finally endnote settings are gotten from text
84 * document using <code>XEndnotesSupplier</code> interface.
87 public synchronized TestEnvironment
createTestEnvironment(
88 TestParameters Param
, PrintWriter log
) throws StatusException
{
89 XEndnotesSupplier oInterface
= null;
90 XInterface oObj
= null;
93 log
.println( "Creating a test environment" );
94 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
95 log
.println("creating a endnote");
97 oEndnote
= UnoRuntime
.queryInterface(XInterface
.class,
98 msf
.createInstance("com.sun.star.text.Endnote"));
99 } catch (com
.sun
.star
.uno
.Exception e
) {
100 e
.printStackTrace(log
);
101 throw new StatusException("Couldn't create endnote", e
);
104 XText oText
= xTextDoc
.getText();
105 XTextCursor oCursor
= oText
.createTextCursor();
107 log
.println("inserting the footnote into text document");
108 XTextContent xTC
= UnoRuntime
.queryInterface(XTextContent
.class, oEndnote
);
110 oText
.insertTextContent(oCursor
, xTC
, false);
111 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
112 e
.printStackTrace(log
);
113 throw new StatusException("Couldn't insert the endnote", e
);
116 oInterface
= UnoRuntime
.queryInterface(XEndnotesSupplier
.class, xTextDoc
);
117 oObj
= oInterface
.getEndnoteSettings();
118 dbg
.printPropertiesNames((XPropertySet
) oObj
);
120 TestEnvironment tEnv
= new TestEnvironment(oObj
);