2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.text
.ControlCharacter
;
24 import com
.sun
.star
.text
.XPageCursor
;
25 import com
.sun
.star
.text
.XText
;
26 import com
.sun
.star
.text
.XTextCursor
;
27 import com
.sun
.star
.text
.XTextDocument
;
31 * Testing <code>com.sun.star.text.XPageCursor</code>
34 * <li><code> jumpToFirstPage()</code></li>
35 * <li><code> jumpToLastPage()</code></li>
36 * <li><code> jumpToPage()</code></li>
37 * <li><code> getPage()</code></li>
38 * <li><code> jumpToNextPage()</code></li>
39 * <li><code> jumpToPreviousPage()</code></li>
40 * <li><code> jumpToEndOfPage()</code></li>
41 * <li><code> jumpToStartOfPage()</code></li>
43 * This test needs the following object relations :
45 * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>):
46 * is used to insert text to document to fill at least two pages. </li>
48 * Test is <b> NOT </b> multithread compliant. <p>
49 * @see com.sun.star.text.XPageCursor
51 public class _XPageCursor
extends MultiMethodTest
{
53 public XPageCursor oObj
= null; // oObj filled by MultiMethodTest
57 * First adds text to the document using relation to fill at least two
58 * pages. Then obtains the number of current page. <p>
60 * Has <b>OK</b> status if the returned value is positive.
62 public void _getPage(){
63 log
.println( "test for getPage()" );
64 XTextDocument myText
= (XTextDocument
)tEnv
.getObjRelation( "TEXTDOC" );
65 XText aText
= myText
.getText();
66 XTextCursor myCursor
= aText
.createTextCursor();
69 for (int i
= 0; i
< 10; i
++){
70 for (int j
= 0; j
< 20; j
++){
71 aText
.insertString(myCursor
, "The quick brown fox ",false);
72 aText
.insertString(myCursor
, "jumps over the lazy dog ",
75 aText
.insertControlCharacter(myCursor
,
76 ControlCharacter
.PARAGRAPH_BREAK
, false);
78 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
79 log
.println( "Exception :" );
80 e
.printStackTrace(log
);
83 count
= oObj
.getPage();
84 tRes
.tested("getPage()", count
> 0 );
88 * Test calls the method. <p>
89 * Has <b> OK </b> status if the method returns
90 * <code>true</code> value.
92 public void _jumpToEndOfPage(){
93 log
.println( "test for jumpToEndOfPage()" );
94 tRes
.tested("jumpToEndOfPage()", oObj
.jumpToEndOfPage());
98 * Test calls the method. <p>
99 * Has <b> OK </b> status if the method returns
100 * <code>true</code> value.
102 public void _jumpToFirstPage(){
103 log
.println( "test for jumpToFirstPage()" );
104 tRes
.tested("jumpToFirstPage()", oObj
.jumpToFirstPage());
108 * Test calls the method. <p>
109 * Has <b> OK </b> status if the method returns
110 * <code>true</code> value.
112 public void _jumpToLastPage(){
113 log
.println( "test for jumpToLastPage()" );
114 tRes
.tested("jumpToLastPage()", oObj
.jumpToLastPage());
118 * First jumps to the first page to have at least one
119 * next page, then call the method. <p>
120 * Has <b> OK </b> status if the method returns
121 * <code>true</code> value.
123 public void _jumpToNextPage(){
124 oObj
.jumpToFirstPage() ;
125 log
.println( "test for jumpToNextPage()" );
126 tRes
.tested("jumpToNextPage()", oObj
.jumpToNextPage());
130 * Tries to jump to the page with number 1. <p>
131 * Has <b> OK </b> status if the method returns
132 * <code>true</code> value.
134 public void _jumpToPage(){
136 log
.println( "test for jumpToPage()" );
137 tRes
.tested("jumpToPage()", oObj
.jumpToPage(n
));
141 * First jumps to the last page to have at least one
142 * previous page, then call the method. <p>
143 * Has <b> OK </b> status if the method returns
144 * <code>true</code> value.
146 public void _jumpToPreviousPage(){
147 log
.println( "test for jumpToPreviousPage()" );
148 oObj
.jumpToLastPage();
149 tRes
.tested("jumpToPreviousPage()", oObj
.jumpToPreviousPage());
153 * Test calls the method. <p>
154 * Has <b> OK </b> status if the method returns
155 * <code>true</code> value.
157 public void _jumpToStartOfPage(){
158 log
.println( "test for jumpToStartOfPage()" );
159 tRes
.tested("jumpToStartOfPage()", oObj
.jumpToStartOfPage());
161 } // finish class _XPageCursor