1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XTextContent.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.text
.XTextContent
;
36 import com
.sun
.star
.text
.XTextRange
;
39 * Testing <code>com.sun.star.text.XTextContent</code>
42 * <li><code> attach()</code></li>
43 * <li><code> getAnchor()</code></li>
45 * This test needs the following object relations :
47 * <li> <code>'CONTENT'</code> <b>optional</b>
48 * (of type <code>XTextContent</code>):
49 * if this relation exists than it is used as the
50 * tested object. </li>
51 * <li> <code>'TEXT'</code> <b>optional</b>
52 * (of type <code>XText</code>):
53 * the relation must be specified if the 'CONTENT'
54 * relation exists. From this relation an anchor
55 * for <code>attach()</code> method is obtained.</li>
57 * Test is <b> NOT </b> multithread compilant. <p>
58 * @see com.sun.star.text.XTextContent
60 public class _XTextContent
extends MultiMethodTest
{
61 public XTextContent oObj
= null;
62 public XTextRange oAnchor
= null;
65 * Tries to get the anchor of the text content
66 * an XTextRange is returned. <p>
67 * The test is OK if an not null text range is returned
69 public void _getAnchor() {
70 log
.println("getAnchor()");
71 oAnchor
= oObj
.getAnchor();
72 tRes
.tested("getAnchor()", oAnchor
!= null ) ;
77 * Tries to attach the text content to the test range
78 * gotten with getAnchor(). If relations are found
79 * then they are are used for testing. <p>
81 * The test is OK if the method works without error.
84 public void _attach() {
85 requiredMethod("getAnchor()");
87 XTextContent aContent
= (XTextContent
) tEnv
.getObjRelation("CONTENT");
88 XTextRange aRange
= (XTextRange
) tEnv
.getObjRelation("RANGE");
90 if ( aContent
!=null) {
91 aContent
.attach(aRange
);
95 tRes
.tested("attach()", true ) ;
97 catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
98 String noAttach
= (String
) tEnv
.getObjRelation("NoAttach");
99 if (noAttach
!= null) {
100 log
.println("Exception expected for "+noAttach
);
101 log
.println("This Component doesn't support attach");
102 tRes
.tested("attach()",true);
104 ex
.printStackTrace(log
);
105 tRes
.tested("attach()",false);
107 } catch (com
.sun
.star
.uno
.RuntimeException re
) {
108 String noAttach
= (String
) tEnv
.getObjRelation("NoAttach");
109 if (noAttach
!= null) {
110 log
.println("Exception expected for "+noAttach
);
111 log
.println("This Component doesn't support attach");
112 tRes
.tested("attach()",true);
114 re
.printStackTrace(log
);
115 tRes
.tested("attach()",false);