Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _XTextContent.java
blob433f12a0b2a2c38ca9dcfe11e52cbdf8763a916c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XTextContent.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.text;
33 import lib.MultiMethodTest;
35 import com.sun.star.text.XTextContent;
36 import com.sun.star.text.XTextRange;
38 /**
39 * Testing <code>com.sun.star.text.XTextContent</code>
40 * interface methods :
41 * <ul>
42 * <li><code> attach()</code></li>
43 * <li><code> getAnchor()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
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>
56 * <ul> <p>
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;
64 /**
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 ) ;
74 } // end getAnchor()
76 /**
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.
82 * @see #_getAnchor()
84 public void _attach() {
85 requiredMethod("getAnchor()");
86 try {
87 XTextContent aContent = (XTextContent) tEnv.getObjRelation("CONTENT");
88 XTextRange aRange = (XTextRange) tEnv.getObjRelation("RANGE");
90 if ( aContent !=null) {
91 aContent.attach(aRange);
92 } else {
93 oObj.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);
103 } else {
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);
113 } else {
114 re.printStackTrace(log);
115 tRes.tested("attach()",false);