Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XUsedAreaCursor.java
blobd5e4bd3f9f18219d420a194068e5925abb6acc6c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XUsedAreaCursor.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sheet;
33 import lib.MultiMethodTest;
35 import com.sun.star.sheet.XCellRangeAddressable;
36 import com.sun.star.sheet.XSheetCellCursor;
37 import com.sun.star.sheet.XUsedAreaCursor;
38 import com.sun.star.table.CellRangeAddress;
39 import com.sun.star.uno.UnoRuntime;
41 /**
42 * Testing <code>com.sun.star.sheet.XUsedAreaCursor</code>
43 * interface methods :
44 * <ul>
45 * <li><code> gotoStartOfUsedArea()</code></li>
46 * <li><code> gotoEndOfUsedArea()</code></li>
47 * </ul> <p>
48 * Component must also implement the following interfaces :
49 * <ul>
50 * <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current
51 * position of the cursor </li>
52 * <ul> <p>
53 * @see com.sun.star.sheet.XUsedAreaCursor
55 public class _XUsedAreaCursor extends MultiMethodTest {
57 public XUsedAreaCursor oObj = null;
58 public XSheetCellCursor oC = null;
59 CellRangeAddress sAddr = null;
61 /**
62 * Test points the cursor to the start of used area, expands cursor to the
63 * end of the used area, gets and checks current range address, then
64 * points the cursor to the end of the used area, gets and checks current
65 * range address again. <p>
66 * Has <b> OK </b> status if the range address expands at all used area
67 * in first case and if the range address just points to the cell at the end
68 * of the used area in second case. <p>
70 public void _gotoEndOfUsedArea() {
71 boolean result = true ;
73 XCellRangeAddressable oAddr = (XCellRangeAddressable)
74 UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
76 // first with true argument
77 oObj.gotoStartOfUsedArea(false);
78 oObj.gotoEndOfUsedArea(true);
79 sAddr = oAddr.getRangeAddress();
81 result &= (sAddr.StartColumn == 1);
82 result &= (sAddr.StartRow == 1);
83 result &= (sAddr.EndColumn == 4);
84 result &= (sAddr.EndRow == 5);
86 oObj.gotoEndOfUsedArea(false);
87 sAddr = oAddr.getRangeAddress();
89 result &= (sAddr.StartColumn == 4);
90 result &= (sAddr.StartRow == 5);
91 result &= (sAddr.EndColumn == 4);
92 result &= (sAddr.EndRow == 5);
94 tRes.tested("gotoEndOfUsedArea()", result) ;
97 /**
98 * Test points the cursor to the end of used area, expands cursor to the
99 * start of the used area, gets and checks current range address, then
100 * points the cursor to the start of the used area, gets and checks current
101 * range address again. <p>
102 * Has <b> OK </b> status if the range address expands at all used area
103 * in first case and if the range address just points to the cell at the
104 * start of the used area in second case. <p>
106 public void _gotoStartOfUsedArea() {
107 XCellRangeAddressable oAddr = (XCellRangeAddressable)
108 UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
110 boolean result = true ;
112 // with true parameter first
113 oObj.gotoEndOfUsedArea(false);
114 oObj.gotoStartOfUsedArea(true);
115 sAddr = oAddr.getRangeAddress();
117 result &= (sAddr.StartColumn == 1);
118 result &= (sAddr.StartRow == 1);
119 result &= (sAddr.EndColumn == 4);
120 result &= (sAddr.EndRow == 5);
122 // now testing with false parameter
123 oObj.gotoStartOfUsedArea(false);
124 sAddr = oAddr.getRangeAddress();
126 result &= (sAddr.StartColumn == 1);
127 result &= (sAddr.StartRow == 1);
128 result &= (sAddr.EndColumn == 1);
129 result &= (sAddr.EndRow == 1);
131 tRes.tested("gotoStartOfUsedArea()", result) ;
132 } // finished gotoStartOfUsedArea
135 * Forces object environment recreation.
137 protected void after() {
138 this.disposeEnvironment();
140 } // finished class _XUsedAreaCursor