Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _XAutoTextEntry.java
blob36599411b7f1cf5c990325555d59c6dc4dd8bad0
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: _XAutoTextEntry.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.XAutoTextEntry;
38 import com.sun.star.text.XTextDocument;
40 /**
41 * Testing <code>com.sun.star.text.XAutoTextEntry</code>
42 * interface methods :
43 * <ul>
44 * <li><code> applyTo()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>):
49 * the text document for creating a text range.</li>
50 * <ul> <p>
51 * Test is <b> NOT </b> multithread compilant. <p>
52 * @see com.sun.star.text.XAutoTextEntry
54 public class _XAutoTextEntry extends MultiMethodTest {
56 public XAutoTextEntry oObj = null;
58 /**
59 * Applies the entry to a range created for the text document obtained from
60 * relation 'TEXTDOC'. <p>
61 * Has <b> OK </b> status if text of the document was changed. <p>
63 public void _applyTo() {
64 XTextDocument textDoc = (XTextDocument)tEnv.getObjRelation("TEXTDOC");
65 if (textDoc == null) {
66 throw new StatusException
67 (Status.failed("Couldn't get relation 'TEXTDOC'"));
70 String oldText = textDoc.getText().getString();
71 oObj.applyTo(textDoc.getText().createTextCursor());
72 String newText = textDoc.getText().getString();
74 log.println("Old text:\n" + oldText + "\nNew text:\n" + newText);
76 tRes.tested("applyTo()", ! newText.equals(oldText));
79 } // finish class _XAutoTextEntry