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 lib
.MultiMethodTest
;
23 import com
.sun
.star
.text
.XTextContent
;
24 import com
.sun
.star
.text
.XTextRange
;
27 * Testing <code>com.sun.star.text.XTextContent</code>
30 * <li><code> attach()</code></li>
31 * <li><code> getAnchor()</code></li>
33 * This test needs the following object relations :
35 * <li> <code>'CONTENT'</code> <b>optional</b>
36 * (of type <code>XTextContent</code>):
37 * if this relation exists than it is used as the
38 * tested object. </li>
39 * <li> <code>'TEXT'</code> <b>optional</b>
40 * (of type <code>XText</code>):
41 * the relation must be specified if the 'CONTENT'
42 * relation exists. From this relation an anchor
43 * for <code>attach()</code> method is obtained.</li>
45 * Test is <b> NOT </b> multithread compliant. <p>
46 * @see com.sun.star.text.XTextContent
48 public class _XTextContent
extends MultiMethodTest
{
49 public XTextContent oObj
= null;
50 public XTextRange oAnchor
= null;
53 * Tries to get the anchor of the text content
54 * an XTextRange is returned. <p>
55 * The test is OK if a not null text range is returned
57 public void _getAnchor() {
58 log
.println("getAnchor()");
59 oAnchor
= oObj
.getAnchor();
60 tRes
.tested("getAnchor()", oAnchor
!= null ) ;
65 * Tries to attach the text content to the test range
66 * gotten with getAnchor(). If relations are found
67 * then they are used for testing. <p>
69 * The test is OK if the method works without error.
72 public void _attach() {
73 requiredMethod("getAnchor()");
75 XTextContent aContent
= (XTextContent
) tEnv
.getObjRelation("CONTENT");
76 XTextRange aRange
= (XTextRange
) tEnv
.getObjRelation("RANGE");
78 if ( aContent
!=null) {
79 aContent
.attach(aRange
);
83 tRes
.tested("attach()", true ) ;
85 catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
86 String noAttach
= (String
) tEnv
.getObjRelation("NoAttach");
87 if (noAttach
!= null) {
88 log
.println("Exception expected for "+noAttach
);
89 log
.println("This Component doesn't support attach");
90 tRes
.tested("attach()",true);
92 ex
.printStackTrace(log
);
93 tRes
.tested("attach()",false);
95 } catch (com
.sun
.star
.uno
.RuntimeException re
) {
96 String noAttach
= (String
) tEnv
.getObjRelation("NoAttach");
97 if (noAttach
!= null) {
98 log
.println("Exception expected for "+noAttach
);
99 log
.println("This Component doesn't support attach");
100 tRes
.tested("attach()",true);
102 re
.printStackTrace(log
);
103 tRes
.tested("attach()",false);