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
.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
;
38 * Test for object which is represented by service
39 * <code>com.sun.star.text.DocumentIndexMark</code>. <p>
40 * Object implements the following interfaces :
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>
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
;
65 * Creates text document.
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 );
75 * Disposes text document.
78 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
79 log
.println( " disposing xTextDoc " );
80 util
.DesktopTools
.closeDoc(xTextDoc
);
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
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
);
100 Object instance
= null;
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());
121 } // finish method getTestEnvironment
123 } // finish class SwXDocumentIndexMark