Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCellRangeReferrer.java
blobc5ca5ea5f8d25b440fcddc6855487bfe3d479a6d
1 /*
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 .
19 package ifc.sheet;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.sheet.XCellRangeAddressable;
26 import com.sun.star.sheet.XCellRangeReferrer;
27 import com.sun.star.table.CellRangeAddress;
28 import com.sun.star.table.XCellRange;
29 import com.sun.star.uno.UnoRuntime;
31 /**
32 * Testing <code>com.sun.star.sheet.XCellRangeReferrer</code>
33 * interface methods :
34 * <ul>
35 * <li><code> getReferredCells() </code></li>
36 * </ul> <p>
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>):
40 * to have cell range address </li>
41 * <ul> <p>
42 * @see com.sun.star.sheet.XCellRangeReferrer
43 * @see com.sun.star.table.CellRangeAddress
45 public class _XCellRangeReferrer extends MultiMethodTest {
47 public XCellRangeReferrer oObj = null;
49 /**
50 * Test calls the method and compares cell range address of returned cell range
51 * with cell range address gotten by relation <code>'DATAAREA'</code>. <p>
52 * Has <b> OK </b> status if all fields of cell range addresses are equal. <p>
54 public void _getReferredCells() {
55 boolean bResult = true;
57 CellRangeAddress oldCRA = (CellRangeAddress)
58 tEnv.getObjRelation("DATAAREA");
59 if (oldCRA == null) throw new StatusException(Status.failed
60 ("Relation 'DATAAREA' not found"));
62 XCellRange cr = oObj.getReferredCells();
64 if (cr == null) {
65 log.println("getReferredCells returned NULL.");
66 tRes.tested("getReferredCells()", false);
67 return;
69 log.println(cr.toString());
71 XCellRangeAddressable xCRA = UnoRuntime.queryInterface(XCellRangeAddressable.class, cr);
73 CellRangeAddress objCRA = xCRA.getRangeAddress();
75 log.println("The named range was 'ANamedRange A1:B2'");
76 log.println("Expected CellRangeAddress: (" + oldCRA.Sheet +
77 "," + oldCRA.StartColumn + "," + oldCRA.StartRow + "," +
78 oldCRA.EndColumn + "," + objCRA.EndRow + ")");
79 log.println("CellRangeAddress gotten: (" + objCRA.Sheet + ","
80 + objCRA.StartColumn + "," + objCRA.StartRow + "," +
81 objCRA.EndColumn + "," + objCRA.EndRow + ")");
83 bResult &= objCRA.EndColumn == oldCRA.EndColumn;
84 bResult &= objCRA.EndRow == oldCRA.EndRow;
85 bResult &= objCRA.Sheet == oldCRA.Sheet;
86 bResult &= objCRA.StartColumn == oldCRA.StartColumn;
87 bResult &= objCRA.StartRow == oldCRA.StartRow;
89 tRes.tested("getReferredCells()", bResult);