1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.text
.ControlCharacter
;
33 import com
.sun
.star
.text
.XPageCursor
;
34 import com
.sun
.star
.text
.XText
;
35 import com
.sun
.star
.text
.XTextCursor
;
36 import com
.sun
.star
.text
.XTextDocument
;
40 * Testing <code>com.sun.star.text.XPageCursor</code>
43 * <li><code> jumpToFirstPage()</code></li>
44 * <li><code> jumpToLastPage()</code></li>
45 * <li><code> jumpToPage()</code></li>
46 * <li><code> getPage()</code></li>
47 * <li><code> jumpToNextPage()</code></li>
48 * <li><code> jumpToPreviousPage()</code></li>
49 * <li><code> jumpToEndOfPage()</code></li>
50 * <li><code> jumpToStartOfPage()</code></li>
52 * This test needs the following object relations :
54 * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>):
55 * is used to insert text to document to fill at least two pages. </li>
57 * Test is <b> NOT </b> multithread compilant. <p>
58 * @see com.sun.star.text.XPageCursor
60 public class _XPageCursor
extends MultiMethodTest
{
62 public XPageCursor oObj
= null; // oObj filled by MultiMethodTest
66 * First adds text to the document using relation to fill at least two
67 * pages. Then obtains the number of current page. <p>
69 * Has <b>OK</b> status if the returned value is positive.
71 public void _getPage(){
72 log
.println( "test for getPage()" );
73 XTextDocument myText
= (XTextDocument
)tEnv
.getObjRelation( "TEXTDOC" );
74 XText aText
= myText
.getText();
75 XTextCursor myCursor
= aText
.createTextCursor();
78 for (int i
= 0; i
< 10; i
++){
79 for (int j
= 0; j
< 20; j
++){
80 aText
.insertString(myCursor
, "The quick brown fox ",false);
81 aText
.insertString(myCursor
, "jumps over the lazy dog ",
84 aText
.insertControlCharacter(myCursor
,
85 ControlCharacter
.PARAGRAPH_BREAK
, false);
87 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
88 log
.println( "Exception :" );
89 e
.printStackTrace(log
);
92 count
= oObj
.getPage();
93 tRes
.tested("getPage()", count
> 0 );
97 * Test calls the method. <p>
98 * Has <b> OK </b> status if the method returns
99 * <code>true</code> value.
101 public void _jumpToEndOfPage(){
102 log
.println( "test for jumpToEndOfPage()" );
103 tRes
.tested("jumpToEndOfPage()", oObj
.jumpToEndOfPage());
107 * Test calls the method. <p>
108 * Has <b> OK </b> status if the method returns
109 * <code>true</code> value.
111 public void _jumpToFirstPage(){
112 log
.println( "test for jumpToFirstPage()" );
113 tRes
.tested("jumpToFirstPage()", oObj
.jumpToFirstPage());
117 * Test calls the method. <p>
118 * Has <b> OK </b> status if the method returns
119 * <code>true</code> value.
121 public void _jumpToLastPage(){
122 log
.println( "test for jumpToLastPage()" );
123 tRes
.tested("jumpToLastPage()", oObj
.jumpToLastPage());
127 * Firts jumps to the first page to have at least one
128 * next page, then call the method. <p>
129 * Has <b> OK </b> status if the method returns
130 * <code>true</code> value.
132 public void _jumpToNextPage(){
133 oObj
.jumpToFirstPage() ;
134 log
.println( "test for jumpToNextPage()" );
135 tRes
.tested("jumpToNextPage()", oObj
.jumpToNextPage());
139 * Tries to jump to the page with number 1. <p>
140 * Has <b> OK </b> status if the method returns
141 * <code>true</code> value.
143 public void _jumpToPage(){
145 log
.println( "test for jumpToPage()" );
146 tRes
.tested("jumpToPage()", oObj
.jumpToPage(n
));
150 * Firts jumps to the last page to have at least one
151 * previous page, then call the method. <p>
152 * Has <b> OK </b> status if the method returns
153 * <code>true</code> value.
155 public void _jumpToPreviousPage(){
156 log
.println( "test for jumpToPreviousPage()" );
157 oObj
.jumpToLastPage();
158 tRes
.tested("jumpToPreviousPage()", oObj
.jumpToPreviousPage());
162 * Test calls the method. <p>
163 * Has <b> OK </b> status if the method returns
164 * <code>true</code> value.
166 public void _jumpToStartOfPage(){
167 log
.println( "test for jumpToStartOfPage()" );
168 tRes
.tested("jumpToStartOfPage()", oObj
.jumpToStartOfPage());
170 } // finish class _XPageCursor