tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXDocumentIndexMark.java
blob1e18e920f6d6781695bff8fc9197136f226fa12d
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.XDocumentIndexMark;
30 import com.sun.star.text.XText;
31 import com.sun.star.text.XTextContent;
32 import com.sun.star.text.XTextCursor;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.uno.UnoRuntime;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.text.DocumentIndexMark</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>com::sun::star::lang::XComponent</code></li>
43 * <li> <code>com::sun::star::text::BaseIndexMark</code></li>
44 * <li> <code>com::sun::star::text::XTextContent</code></li>
45 * <li> <code>com::sun::star::text::TextContent</code></li>
46 * <li> <code>com::sun::star::text::DocumentIndexMark</code></li>
47 * </ul> <p>
48 * This object test <b> is NOT </b> designed to be run in several
49 * threads concurrently.
50 * @see com.sun.star.lang.XComponent
51 * @see com.sun.star.text.BaseIndexMark
52 * @see com.sun.star.text.XTextContent
53 * @see com.sun.star.text.TextContent
54 * @see com.sun.star.text.DocumentIndexMark
55 * @see ifc.lang._XComponent
56 * @see ifc.text._BaseIndexMark
57 * @see ifc.text._XTextContent
58 * @see ifc.text._TextContent
59 * @see ifc.text._DocumentIndexMark
61 public class SwXDocumentIndexMark extends TestCase {
62 XTextDocument xTextDoc;
64 /**
65 * Creates text document.
67 @Override
68 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
69 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
70 log.println( "creating a textdocument" );
71 xTextDoc = SOF.createTextDoc( null );
74 /**
75 * Disposes text document.
77 @Override
78 protected void cleanup( TestParameters tParam, PrintWriter log ) {
79 log.println( " disposing xTextDoc " );
80 util.DesktopTools.closeDoc(xTextDoc);
84 /**
85 * Creating a TestEnvironment for the interfaces to be tested.
86 * Creates an instance of the service
87 * <code>com.sun.star.text.DocumentIndexMark</code>, attaches text to
88 * created DocumentIndexMark, and inserts DocumentIndexMark to the
89 * text document.
91 @Override
92 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
94 XText oText = xTextDoc.getText();
95 XTextCursor oCursor = oText.createTextCursor();
97 XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc);
99 Object oDIM = null;
100 Object instance = null;
101 try {
102 oDIM = oDocMSF.createInstance
103 ("com.sun.star.text.DocumentIndexMark");
104 instance = oDocMSF.createInstance
105 ("com.sun.star.text.DocumentIndexMark");
106 } catch ( com.sun.star.uno.Exception e ) {
107 log.println("Error:" + e);
110 XDocumentIndexMark xDIM = UnoRuntime.queryInterface(XDocumentIndexMark.class, oDIM);
112 oText.insertTextContent(oCursor, xDIM, false);
114 TestEnvironment tEnv = new TestEnvironment(xDIM);
116 tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance));
117 tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor());
119 return tEnv;
121 } // finish method getTestEnvironment
123 } // finish class SwXDocumentIndexMark