tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XTextContent.java
blobbcb65b8063430c99f09479af03c726da4ff99697
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 ifc.text;
21 import lib.MultiMethodTest;
23 import com.sun.star.text.XTextContent;
24 import com.sun.star.text.XTextRange;
26 /**
27 * Testing <code>com.sun.star.text.XTextContent</code>
28 * interface methods :
29 * <ul>
30 * <li><code> attach()</code></li>
31 * <li><code> getAnchor()</code></li>
32 * </ul> <p>
33 * This test needs the following object relations :
34 * <ul>
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>
44 * <ul> <p>
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;
52 /**
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 ) ;
62 } // end getAnchor()
64 /**
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.
70 * @see #_getAnchor()
72 public void _attach() {
73 requiredMethod("getAnchor()");
74 try {
75 XTextContent aContent = (XTextContent) tEnv.getObjRelation("CONTENT");
76 XTextRange aRange = (XTextRange) tEnv.getObjRelation("RANGE");
78 if ( aContent !=null) {
79 aContent.attach(aRange);
80 } else {
81 oObj.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);
91 } else {
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);
101 } else {
102 re.printStackTrace(log);
103 tRes.tested("attach()",false);