merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / text / _XTextRangeMover.java
blobee49474f2761d4cda18e2e5533c2f52433a132cd
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: _XTextRangeMover.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;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.text.XTextRange;
38 import com.sun.star.text.XTextRangeMover;
40 /**
41 * Testing <code>com.sun.star.text.XTextRangeMover</code>
42 * interface methods :
43 * <ul>
44 * <li><code> moveTextRange()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 * <li> <code>'RangeForMove'</code> (of type <code>XTextRange</code>):
49 * the range to be moved. </li>
50 * <li> <code>'XTextRange'</code> (of type <code>XTextRange</code>):
51 * the range that includes moving range. </li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.text.XTextRangeMover
56 public class _XTextRangeMover extends MultiMethodTest {
58 public XTextRangeMover oObj = null;
60 XTextRange xTextRange = null;
61 XTextRange oMoveRange = null;
63 /**
64 * Moves the range obtained from relation 'RangeForMove' by 1 paragraph
65 * and compares index of moved string in the whole text obtained
66 * from relation 'XTextRange'. <p>
67 * Has <b>OK</b> status if index of moved range is changed after method call.
69 public void _moveTextRange(){
70 oMoveRange = (XTextRange) tEnv.getObjRelation("RangeForMove");
71 xTextRange = (XTextRange) tEnv.getObjRelation("XTextRange");
73 if (oMoveRange == null) {
74 throw new StatusException(
75 Status.failed("Couldn't get relation 'RangeForMove'"));
78 if (xTextRange == null) {
79 throw new StatusException(
80 Status.failed("Couldn't get relation 'XTextRange'"));
83 log.println("Content before moving:");
84 log.println(xTextRange.getString());
85 log.println("Text range for moving:");
86 log.println(oMoveRange.getString());
87 int indexBefore = xTextRange.getString().indexOf(oMoveRange.getString());
88 oObj.moveTextRange(oMoveRange,(short) 1);
89 log.println("Content after moving:");
90 log.println(xTextRange.getString());
91 int indexAfter = xTextRange.getString().indexOf(oMoveRange.getString());
93 boolean res = indexBefore != indexAfter;
94 log.println("Index before moving:" + indexBefore);
95 log.println("Index after moving:" + indexAfter);
97 tRes.tested("moveTextRange()", res);