Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XCellRangeReferrer.java
blobc405ce4204fa4571e3c9a51be2c33af5d9f7eb3d
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: _XCellRangeReferrer.java,v $
10 * $Revision: 1.4 $
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;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.sheet.XCellRangeAddressable;
38 import com.sun.star.sheet.XCellRangeReferrer;
39 import com.sun.star.table.CellRangeAddress;
40 import com.sun.star.table.XCellRange;
41 import com.sun.star.uno.UnoRuntime;
43 /**
44 * Testing <code>com.sun.star.sheet.XCellRangeReferrer</code>
45 * interface methods :
46 * <ul>
47 * <li><code> getReferredCells() </code></li>
48 * </ul> <p>
49 * This test needs the following object relations :
50 * <ul>
51 * <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>):
52 * to have cell range address </li>
53 * <ul> <p>
54 * @see com.sun.star.sheet.XCellRangeReferrer
55 * @see com.sun.star.table.CellRangeAddress
57 public class _XCellRangeReferrer extends MultiMethodTest {
59 public XCellRangeReferrer oObj = null;
61 /**
62 * Test calls the method and compares cell range address of returned cell range
63 * with cell range address gotten by relation <code>'DATAAREA'</code>. <p>
64 * Has <b> OK </b> status if all fields of cell range addresses are equal. <p>
66 public void _getReferredCells() {
67 boolean bResult = true;
69 CellRangeAddress oldCRA = (CellRangeAddress)
70 tEnv.getObjRelation("DATAAREA");
71 if (oldCRA == null) throw new StatusException(Status.failed
72 ("Relation 'DATAAREA' not found"));
74 XCellRange cr = oObj.getReferredCells();
75 log.println(cr.toString());
77 if (cr == null) {
78 log.println("getReferredCells returned NULL.");
79 tRes.tested("getReferredCells()", false);
80 return;
83 XCellRangeAddressable xCRA = (XCellRangeAddressable)
84 UnoRuntime.queryInterface(XCellRangeAddressable.class, cr);
86 CellRangeAddress objCRA = xCRA.getRangeAddress();
88 log.println("The named range was 'ANamedRange A1:B2'");
89 log.println("Expected CellRangeAddress: (" + oldCRA.Sheet +
90 "," + oldCRA.StartColumn + "," + oldCRA.StartRow + "," +
91 oldCRA.EndColumn + "," + objCRA.EndRow + ")");
92 log.println("CellRangeAddress gotten: (" + objCRA.Sheet + ","
93 + objCRA.StartColumn + "," + objCRA.StartRow + "," +
94 objCRA.EndColumn + "," + objCRA.EndRow + ")");
96 bResult &= objCRA.EndColumn == oldCRA.EndColumn;
97 bResult &= objCRA.EndRow == oldCRA.EndRow;
98 bResult &= objCRA.Sheet == oldCRA.Sheet;
99 bResult &= objCRA.StartColumn == oldCRA.StartColumn;
100 bResult &= objCRA.StartRow == oldCRA.StartRow;
102 tRes.tested("getReferredCells()", bResult);