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
.sheet
.XCellRangeAddressable
;
33 import com
.sun
.star
.sheet
.XSheetCellCursor
;
34 import com
.sun
.star
.sheet
.XUsedAreaCursor
;
35 import com
.sun
.star
.table
.CellRangeAddress
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
39 * Testing <code>com.sun.star.sheet.XUsedAreaCursor</code>
42 * <li><code> gotoStartOfUsedArea()</code></li>
43 * <li><code> gotoEndOfUsedArea()</code></li>
45 * Component must also implement the following interfaces :
47 * <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current
48 * position of the cursor </li>
50 * @see com.sun.star.sheet.XUsedAreaCursor
52 public class _XUsedAreaCursor
extends MultiMethodTest
{
54 public XUsedAreaCursor oObj
= null;
55 public XSheetCellCursor oC
= null;
56 CellRangeAddress sAddr
= null;
59 * Test points the cursor to the start of used area, expands cursor to the
60 * end of the used area, gets and checks current range address, then
61 * points the cursor to the end of the used area, gets and checks current
62 * range address again. <p>
63 * Has <b> OK </b> status if the range address expands at all used area
64 * in first case and if the range address just points to the cell at the end
65 * of the used area in second case. <p>
67 public void _gotoEndOfUsedArea() {
68 boolean result
= true ;
70 XCellRangeAddressable oAddr
= (XCellRangeAddressable
)
71 UnoRuntime
.queryInterface (XCellRangeAddressable
.class, oObj
) ;
73 // first with true argument
74 oObj
.gotoStartOfUsedArea(false);
75 oObj
.gotoEndOfUsedArea(true);
76 sAddr
= oAddr
.getRangeAddress();
78 result
&= (sAddr
.StartColumn
== 1);
79 result
&= (sAddr
.StartRow
== 1);
80 result
&= (sAddr
.EndColumn
== 4);
81 result
&= (sAddr
.EndRow
== 5);
83 oObj
.gotoEndOfUsedArea(false);
84 sAddr
= oAddr
.getRangeAddress();
86 result
&= (sAddr
.StartColumn
== 4);
87 result
&= (sAddr
.StartRow
== 5);
88 result
&= (sAddr
.EndColumn
== 4);
89 result
&= (sAddr
.EndRow
== 5);
91 tRes
.tested("gotoEndOfUsedArea()", result
) ;
95 * Test points the cursor to the end of used area, expands cursor to the
96 * start of the used area, gets and checks current range address, then
97 * points the cursor to the start of the used area, gets and checks current
98 * range address again. <p>
99 * Has <b> OK </b> status if the range address expands at all used area
100 * in first case and if the range address just points to the cell at the
101 * start of the used area in second case. <p>
103 public void _gotoStartOfUsedArea() {
104 XCellRangeAddressable oAddr
= (XCellRangeAddressable
)
105 UnoRuntime
.queryInterface (XCellRangeAddressable
.class, oObj
) ;
107 boolean result
= true ;
109 // with true parameter first
110 oObj
.gotoEndOfUsedArea(false);
111 oObj
.gotoStartOfUsedArea(true);
112 sAddr
= oAddr
.getRangeAddress();
114 result
&= (sAddr
.StartColumn
== 1);
115 result
&= (sAddr
.StartRow
== 1);
116 result
&= (sAddr
.EndColumn
== 4);
117 result
&= (sAddr
.EndRow
== 5);
119 // now testing with false parameter
120 oObj
.gotoStartOfUsedArea(false);
121 sAddr
= oAddr
.getRangeAddress();
123 result
&= (sAddr
.StartColumn
== 1);
124 result
&= (sAddr
.StartRow
== 1);
125 result
&= (sAddr
.EndColumn
== 1);
126 result
&= (sAddr
.EndRow
== 1);
128 tRes
.tested("gotoStartOfUsedArea()", result
) ;
129 } // finished gotoStartOfUsedArea
132 * Forces object environment recreation.
134 protected void after() {
135 this.disposeEnvironment();
137 } // finished class _XUsedAreaCursor