tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXFrames.java
blob5a85e0bfe37626dc06974b1a91d1f79bc7c54829
1 /*
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 .
19 package mod._sw;
21 import java.io.PrintWriter;
23 import lib.TestCase;
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;
37 /**
38 * Object implements the following interfaces :
39 * <ul>
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>
44 * </ul> <p>
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;
59 /**
60 * Creates text document.
62 @Override
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 );
69 /**
70 * Disposes text document.
72 @Override
73 protected void cleanup( TestParameters tParam, PrintWriter log ) {
74 log.println( " disposing xTextDoc " );
75 util.DesktopTools.closeDoc(xTextDoc);
78 /**
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>
85 @Override
86 public TestEnvironment createTestEnvironment(
87 TestParameters Param, PrintWriter log ) throws Exception {
88 XInterface oObj = null;
89 XTextFrame oFrame1 = null;
90 XText oText = 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 );
112 return tEnv;
113 } // finish method getTestEnvironment
115 } // finish class SwXFrames