1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.text; 29 30 import lib.MultiMethodTest; 31 import util.XInstCreator; 32 33 import com.sun.star.text.XParagraphCursor; 34 35 /** 36 * Testing <code>com.sun.star.text.XParagraphCursor</code> 37 * interface methods : 38 * <ul> 39 * <li><code> isStartOfParagraph()</code></li> 40 * <li><code> isEndOfParagraph()</code></li> 41 * <li><code> gotoStartOfParagraph()</code></li> 42 * <li><code> gotoEndOfParagraph()</code></li> 43 * <li><code> gotoNextParagraph()</code></li> 44 * <li><code> gotoPreviousParagraph()</code></li> 45 * </ul> <p> 46 * 47 * <b>Prerequisites :</b> the text must have at least 48 * two paragraphs. <p> 49 * 50 * Test is <b> NOT </b> multithread compilant. <p> 51 * @see com.sun.star.text.XParagraphCursor 52 */ 53 public class _XParagraphCursor extends MultiMethodTest { 54 55 public XParagraphCursor oObj = null; // oObj filled by MultiMethodTest 56 XInstCreator info = null; // instance creator 57 58 /** 59 * Test calls the method. <p> 60 * Has <b> OK </b> status if the method returns 61 * <code>true</code> value. 62 */ 63 public void _gotoEndOfParagraph(){ 64 log.println( "test for gotoEndOfParagraph()" ); 65 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); 66 else log.println("This isn't the end of the paragraph"); 67 log.println("gotoEndOfParagraph()"); 68 boolean result = oObj.gotoEndOfParagraph(false); 69 tRes.tested("gotoEndOfParagraph()", result ); 70 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); 71 else log.println("This isn't the end of the paragraph"); 72 if (!result) log.println("But 'gotoEndOfParagraph()' returns false"); 73 } 74 75 /** 76 * Test calls the method. <p> 77 * Has <b> OK </b> status if the method returns 78 * <code>true</code> value. <p> 79 * 80 * The following method tests are to be completed successfully before : 81 * <ul> 82 * <li> <code>gotoPreviousParagraph()</code> : to be sure next paragraph 83 * exists. </li> 84 * </ul> 85 */ 86 public void _gotoNextParagraph(){ 87 requiredMethod( "gotoPreviousParagraph()" ); 88 log.println( "test for gotoNextParagraph()" ); 89 tRes.tested("gotoNextParagraph()", oObj.gotoNextParagraph(false) ); 90 } 91 92 /** 93 * First moves the cursor to the next paragraph to be sure 94 * that previous paragraph exists and then calls the method. <p> 95 * Has <b> OK </b> status if the method returns 96 * <code>true</code> value. 97 */ 98 public void _gotoPreviousParagraph(){ 99 //requiredMethod( "gotoNextParagraph()" ); 100 oObj.gotoNextParagraph(false); 101 log.println( "test for gotoPreviousParagraph()" ); 102 tRes.tested("gotoPreviousParagraph()", oObj.gotoPreviousParagraph(false) ); 103 } 104 105 /** 106 * Test calls the method. <p> 107 * Has <b> OK </b> status if the method returns 108 * <code>true</code> value. 109 */ 110 public void _gotoStartOfParagraph(){ 111 log.println( "test for gotoStartOfParagraph()" ); 112 tRes.tested("gotoStartOfParagraph()", oObj.gotoStartOfParagraph(false) ); 113 } 114 115 /** 116 * Moves the cursor to the end of paragraph then check if it is 117 * at the end. <p> 118 * Has <b> OK </b> status if the method returns 119 * <code>true</code> value. 120 */ 121 public void _isEndOfParagraph(){ 122 oObj.gotoEndOfParagraph(false); 123 log.println( "test for isEndOfParagraph()" ); 124 tRes.tested("isEndOfParagraph()", oObj.isEndOfParagraph() ); 125 } 126 127 /** 128 * Moves the cursor to the start of paragraph then check if it is 129 * at the start. <p> 130 * Has <b> OK </b> status if the method returns 131 * <code>true</code> value. 132 */ 133 public void _isStartOfParagraph(){ 134 oObj.gotoStartOfParagraph(false); 135 log.println( "test for isStartOfParagraph()" ); 136 tRes.tested("isStartOfParagraph()", oObj.isStartOfParagraph() ); 137 } 138 139 } // finish class _XParagraphCursor 140 141