1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.sheet;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiMethodTest;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import com.sun.star.sheet.XCellRangeAddressable;
29cdf0e10cSrcweir import com.sun.star.sheet.XSheetCellCursor;
30cdf0e10cSrcweir import com.sun.star.sheet.XUsedAreaCursor;
31cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress;
32cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /**
35cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XUsedAreaCursor</code>
36cdf0e10cSrcweir * interface methods :
37cdf0e10cSrcweir * <ul>
38cdf0e10cSrcweir *  <li><code> gotoStartOfUsedArea()</code></li>
39cdf0e10cSrcweir *  <li><code> gotoEndOfUsedArea()</code></li>
40cdf0e10cSrcweir * </ul> <p>
41cdf0e10cSrcweir * Component must also implement the following interfaces :
42cdf0e10cSrcweir * <ul>
43cdf0e10cSrcweir *  <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current
44cdf0e10cSrcweir *  position of the cursor </li>
45cdf0e10cSrcweir * <ul> <p>
46cdf0e10cSrcweir * @see com.sun.star.sheet.XUsedAreaCursor
47cdf0e10cSrcweir */
48cdf0e10cSrcweir public class _XUsedAreaCursor extends MultiMethodTest {
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     public XUsedAreaCursor oObj = null;
51cdf0e10cSrcweir     public XSheetCellCursor oC = null;
52cdf0e10cSrcweir     CellRangeAddress sAddr = null;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     /**
55cdf0e10cSrcweir     * Test points the cursor to the start of used area, expands cursor to the
56cdf0e10cSrcweir     * end of the used area, gets and checks current range address, then
57cdf0e10cSrcweir     * points the cursor to the end of the used area, gets and checks current
58cdf0e10cSrcweir     * range address again. <p>
59cdf0e10cSrcweir     * Has <b> OK </b> status if the range address expands at all used area
60cdf0e10cSrcweir     * in first case and if the range address just points to the cell at the end
61cdf0e10cSrcweir     * of the used area in second case. <p>
62cdf0e10cSrcweir     */
_gotoEndOfUsedArea()63cdf0e10cSrcweir     public void _gotoEndOfUsedArea() {
64cdf0e10cSrcweir         boolean result = true ;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         XCellRangeAddressable oAddr = (XCellRangeAddressable)
67cdf0e10cSrcweir                 UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir         // first with true argument
70cdf0e10cSrcweir         oObj.gotoStartOfUsedArea(false);
71cdf0e10cSrcweir         oObj.gotoEndOfUsedArea(true);
72cdf0e10cSrcweir         sAddr = oAddr.getRangeAddress();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         result &= (sAddr.StartColumn == 1);
75cdf0e10cSrcweir         result &= (sAddr.StartRow == 1);
76cdf0e10cSrcweir         result &= (sAddr.EndColumn == 4);
77cdf0e10cSrcweir         result &= (sAddr.EndRow == 5);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir         oObj.gotoEndOfUsedArea(false);
80cdf0e10cSrcweir         sAddr = oAddr.getRangeAddress();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         result &= (sAddr.StartColumn == 4);
83cdf0e10cSrcweir         result &= (sAddr.StartRow == 5);
84cdf0e10cSrcweir         result &= (sAddr.EndColumn == 4);
85cdf0e10cSrcweir         result &= (sAddr.EndRow == 5);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         tRes.tested("gotoEndOfUsedArea()", result) ;
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /**
91cdf0e10cSrcweir     * Test points the cursor to the end of used area, expands cursor to the
92cdf0e10cSrcweir     * start of the used area, gets and checks current range address, then
93cdf0e10cSrcweir     * points the cursor to the start of the used area, gets and checks current
94cdf0e10cSrcweir     * range address again. <p>
95cdf0e10cSrcweir     * Has <b> OK </b> status if the range address expands at all used area
96cdf0e10cSrcweir     * in first case and if the range address just points to the cell at the
97cdf0e10cSrcweir     * start of the used area in second case. <p>
98cdf0e10cSrcweir     */
_gotoStartOfUsedArea()99cdf0e10cSrcweir     public void _gotoStartOfUsedArea() {
100cdf0e10cSrcweir         XCellRangeAddressable oAddr = (XCellRangeAddressable)
101cdf0e10cSrcweir                 UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         boolean result = true ;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         // with true parameter first
106cdf0e10cSrcweir         oObj.gotoEndOfUsedArea(false);
107cdf0e10cSrcweir         oObj.gotoStartOfUsedArea(true);
108cdf0e10cSrcweir         sAddr = oAddr.getRangeAddress();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         result &= (sAddr.StartColumn == 1);
111cdf0e10cSrcweir         result &= (sAddr.StartRow == 1);
112cdf0e10cSrcweir         result &= (sAddr.EndColumn == 4);
113cdf0e10cSrcweir         result &= (sAddr.EndRow == 5);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // now testing with false parameter
116cdf0e10cSrcweir         oObj.gotoStartOfUsedArea(false);
117cdf0e10cSrcweir         sAddr = oAddr.getRangeAddress();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         result &= (sAddr.StartColumn == 1);
120cdf0e10cSrcweir         result &= (sAddr.StartRow == 1);
121cdf0e10cSrcweir         result &= (sAddr.EndColumn == 1);
122cdf0e10cSrcweir         result &= (sAddr.EndRow == 1);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         tRes.tested("gotoStartOfUsedArea()", result) ;
125cdf0e10cSrcweir     } // finished gotoStartOfUsedArea
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     /**
128cdf0e10cSrcweir     * Forces object environment recreation.
129cdf0e10cSrcweir     */
after()130cdf0e10cSrcweir     protected void after() {
131cdf0e10cSrcweir         this.disposeEnvironment();
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir } // finished class _XUsedAreaCursor
134cdf0e10cSrcweir 
135