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 .
21 import lib
.MultiMethodTest
;
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
;
32 * Testing <code>com.sun.star.sheet.XCellRangeReferrer</code>
35 * <li><code> getReferredCells() </code></li>
37 * This test needs the following object relations :
39 * <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>):
40 * to have cell range address </li>
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;
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();
65 log
.println("getReferredCells returned NULL.");
66 tRes
.tested("getReferredCells()", false);
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
);