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
.XText
;
30 import com
.sun
.star
.text
.XTextCursor
;
31 import com
.sun
.star
.text
.XTextDocument
;
32 import com
.sun
.star
.text
.XTextFrame
;
33 import com
.sun
.star
.text
.XTextFramesSupplier
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.uno
.XInterface
;
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::container::XContainer</code></li>
41 * <li> <code>com::sun::star::container::XNameAccess</code></li>
42 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
43 * <li> <code>com::sun::star::container::XElementAccess</code></li>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurrently.
47 * @see com.sun.star.container.XContainer
48 * @see com.sun.star.container.XNameAccess
49 * @see com.sun.star.container.XIndexAccess
50 * @see com.sun.star.container.XElementAccess
51 * @see ifc.container._XContainer
52 * @see ifc.container._XNameAccess
53 * @see ifc.container._XIndexAccess
54 * @see ifc.container._XElementAccess
56 public class SwXFrames
extends TestCase
{
57 XTextDocument xTextDoc
;
60 * Creates text document.
63 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
64 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
65 log
.println( "creating a textdocument" );
66 xTextDoc
= SOF
.createTextDoc( null );
70 * Disposes text document.
73 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
74 log
.println( " disposing xTextDoc " );
75 util
.DesktopTools
.closeDoc(xTextDoc
);
79 * Creating a TestEnvironment for the interfaces to be tested.
80 * Creates an instance of the service
81 * <code>com.sun.star.text.TextFrame</code>. Then inserts created text frame
82 * to the text, and finally gets all frames of text document using
83 * <code>XTextFramesSupplier</code> interface.<br>
86 public TestEnvironment
createTestEnvironment(
87 TestParameters Param
, PrintWriter log
) throws Exception
{
88 XInterface oObj
= null;
89 XTextFrame oFrame1
= null;
91 XTextCursor oCursor
= null;
92 XMultiServiceFactory oDocMSF
= null;
93 XTextFramesSupplier oInterface
= null;
95 log
.println( "creating a test environment" );
96 oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
97 Object oInt
= oDocMSF
.createInstance("com.sun.star.text.TextFrame");
98 oFrame1
= UnoRuntime
.queryInterface( XTextFrame
.class, oInt
);
100 oText
= xTextDoc
.getText();
101 oCursor
= oText
.createTextCursor();
103 oText
.insertTextContent(oCursor
, oFrame1
, false);
105 oInterface
= UnoRuntime
.queryInterface( XTextFramesSupplier
.class, xTextDoc
);
107 oObj
= oInterface
.getTextFrames();
109 log
.println( "creating a new environment for Frame object" );
110 TestEnvironment tEnv
= new TestEnvironment( oObj
);
113 } // finish method getTestEnvironment
115 } // finish class SwXFrames