1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.text; 25 26 import lib.MultiMethodTest; 27 import util.XInstCreator; 28 29 import com.sun.star.text.XParagraphCursor; 30 31 /** 32 * Testing <code>com.sun.star.text.XParagraphCursor</code> 33 * interface methods : 34 * <ul> 35 * <li><code> isStartOfParagraph()</code></li> 36 * <li><code> isEndOfParagraph()</code></li> 37 * <li><code> gotoStartOfParagraph()</code></li> 38 * <li><code> gotoEndOfParagraph()</code></li> 39 * <li><code> gotoNextParagraph()</code></li> 40 * <li><code> gotoPreviousParagraph()</code></li> 41 * </ul> <p> 42 * 43 * <b>Prerequisites :</b> the text must have at least 44 * two paragraphs. <p> 45 * 46 * Test is <b> NOT </b> multithread compilant. <p> 47 * @see com.sun.star.text.XParagraphCursor 48 */ 49 public class _XParagraphCursor extends MultiMethodTest { 50 51 public XParagraphCursor oObj = null; // oObj filled by MultiMethodTest 52 XInstCreator info = null; // instance creator 53 54 /** 55 * Test calls the method. <p> 56 * Has <b> OK </b> status if the method returns 57 * <code>true</code> value. 58 */ _gotoEndOfParagraph()59 public void _gotoEndOfParagraph(){ 60 log.println( "test for gotoEndOfParagraph()" ); 61 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); 62 else log.println("This isn't the end of the paragraph"); 63 log.println("gotoEndOfParagraph()"); 64 boolean result = oObj.gotoEndOfParagraph(false); 65 tRes.tested("gotoEndOfParagraph()", result ); 66 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); 67 else log.println("This isn't the end of the paragraph"); 68 if (!result) log.println("But 'gotoEndOfParagraph()' returns false"); 69 } 70 71 /** 72 * Test calls the method. <p> 73 * Has <b> OK </b> status if the method returns 74 * <code>true</code> value. <p> 75 * 76 * The following method tests are to be completed successfully before : 77 * <ul> 78 * <li> <code>gotoPreviousParagraph()</code> : to be sure next paragraph 79 * exists. </li> 80 * </ul> 81 */ _gotoNextParagraph()82 public void _gotoNextParagraph(){ 83 requiredMethod( "gotoPreviousParagraph()" ); 84 log.println( "test for gotoNextParagraph()" ); 85 tRes.tested("gotoNextParagraph()", oObj.gotoNextParagraph(false) ); 86 } 87 88 /** 89 * First moves the cursor to the next paragraph to be sure 90 * that previous paragraph exists and then calls the method. <p> 91 * Has <b> OK </b> status if the method returns 92 * <code>true</code> value. 93 */ _gotoPreviousParagraph()94 public void _gotoPreviousParagraph(){ 95 //requiredMethod( "gotoNextParagraph()" ); 96 oObj.gotoNextParagraph(false); 97 log.println( "test for gotoPreviousParagraph()" ); 98 tRes.tested("gotoPreviousParagraph()", oObj.gotoPreviousParagraph(false) ); 99 } 100 101 /** 102 * Test calls the method. <p> 103 * Has <b> OK </b> status if the method returns 104 * <code>true</code> value. 105 */ _gotoStartOfParagraph()106 public void _gotoStartOfParagraph(){ 107 log.println( "test for gotoStartOfParagraph()" ); 108 tRes.tested("gotoStartOfParagraph()", oObj.gotoStartOfParagraph(false) ); 109 } 110 111 /** 112 * Moves the cursor to the end of paragraph then check if it is 113 * at the end. <p> 114 * Has <b> OK </b> status if the method returns 115 * <code>true</code> value. 116 */ _isEndOfParagraph()117 public void _isEndOfParagraph(){ 118 oObj.gotoEndOfParagraph(false); 119 log.println( "test for isEndOfParagraph()" ); 120 tRes.tested("isEndOfParagraph()", oObj.isEndOfParagraph() ); 121 } 122 123 /** 124 * Moves the cursor to the start of paragraph then check if it is 125 * at the start. <p> 126 * Has <b> OK </b> status if the method returns 127 * <code>true</code> value. 128 */ _isStartOfParagraph()129 public void _isStartOfParagraph(){ 130 oObj.gotoStartOfParagraph(false); 131 log.println( "test for isStartOfParagraph()" ); 132 tRes.tested("isStartOfParagraph()", oObj.isStartOfParagraph() ); 133 } 134 135 } // finish class _XParagraphCursor 136 137