bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XSheetOutline.java
blob2b73249a12efc412f356543f3d0e2b40be137aac
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 .
18 package ifc.sheet;
20 import com.sun.star.sheet.XCellRangesQuery;
21 import com.sun.star.sheet.XSheetCellRanges;
22 import lib.MultiMethodTest;
24 import com.sun.star.sheet.XSheetOutline;
25 import com.sun.star.table.CellRangeAddress;
26 import com.sun.star.table.TableOrientation;
27 import com.sun.star.uno.UnoRuntime;
28 import lib.Status;
29 import lib.StatusException;
31 /**
34 public class _XSheetOutline extends MultiMethodTest {
35 public XSheetOutline oObj = null;
36 CellRangeAddress address = null;
37 CellRangeAddress subaddress = null;
39 public void before() {
40 address = (CellRangeAddress)tEnv.getObjRelation("CellRangeAddress");
41 subaddress = (CellRangeAddress)tEnv.getObjRelation("CellRangeSubAddress");
42 if (address == null)
43 throw new StatusException(Status.failed("Object relation CellRangeAddress not found"));
44 if (subaddress == null)
45 throw new StatusException(Status.failed("Object relation CellRangeSubAddress not found"));
48 public void _autoOutline() {
49 executeMethod("ungroup()");
50 boolean result = false;
51 oObj.autoOutline(address);
52 // initially the range is grouped and shown
53 result = isCellShown(subaddress);
54 oObj.hideDetail(address);
55 // here only a part of the address is hidden: subaddress must be that part
56 result &= !isCellShown(subaddress);
57 tRes.tested("autoOutline()", result);
60 public void _clearOutline() {
61 executeMethod("autoOutline()");
62 boolean result = false;
63 oObj.clearOutline();
64 result = isCellShown(subaddress);
65 oObj.hideDetail(address);
66 result &= isCellShown(subaddress);
67 tRes.tested("clearOutline()", result);
70 public void _group() {
71 oObj.group(address, TableOrientation.COLUMNS);
72 oObj.group(address, TableOrientation.ROWS);
73 tRes.tested("group()", true);
76 public void _ungroup() {
77 executeMethod("showDetail()");
78 oObj.ungroup(address, TableOrientation.COLUMNS);
79 oObj.ungroup(address, TableOrientation.ROWS);
80 oObj.hideDetail(address);
81 tRes.tested("ungroup()", isCellShown(address));
84 public void _hideDetail() {
85 requiredMethod("group()");
86 oObj.hideDetail(address);
87 tRes.tested("hideDetail()", !isCellShown(address));
90 public void _showDetail() {
91 executeMethod("showLevel()");
92 oObj.showDetail(address);
93 tRes.tested("showDetail()", isCellShown(address));
96 public void _showLevel() {
97 executeMethod("hideDetail()");
98 boolean result = false;
99 oObj.showLevel((short)2, TableOrientation.COLUMNS);
100 oObj.showLevel((short)2, TableOrientation.ROWS);
101 result = isCellShown(address);
102 oObj.showLevel((short)0, TableOrientation.COLUMNS);
103 oObj.showLevel((short)0, TableOrientation.ROWS);
105 result &= !isCellShown(address);
106 tRes.tested("showLevel()", result);
109 private boolean isCellShown(CellRangeAddress range) {
110 boolean isNotShown = true;
111 XCellRangesQuery xCellRangesQuery = UnoRuntime.queryInterface(XCellRangesQuery.class, oObj);
112 if (xCellRangesQuery != null) {
113 XSheetCellRanges xRanges = xCellRangesQuery.queryVisibleCells();
114 CellRangeAddress[] visibleRanges = xRanges.getRangeAddresses();
115 for (int i=0; i<visibleRanges.length; i++) {
116 isNotShown &= dotIsOutsideRange(range.StartRow, range.StartColumn, visibleRanges[i]);
117 isNotShown &= dotIsOutsideRange(range.StartRow, range.EndColumn, visibleRanges[i]);
118 isNotShown &= dotIsOutsideRange(range.EndRow, range.StartColumn, visibleRanges[i]);
119 isNotShown &= dotIsOutsideRange(range.EndRow, range.EndColumn, visibleRanges[i]);
120 log.println(isNotShown?"\tisOutSide":"\tisInside");
123 return !isNotShown;
126 private boolean dotIsOutsideRange(int dotRow, int dotColumn, CellRangeAddress range) {
127 log.println("Checking dot(" + dotRow + "," + dotColumn + ") against row["
128 + range.StartRow + ":" + range.EndRow + "] column["
129 + range.StartColumn + ":" + range.EndColumn + "]");
130 boolean isInside = true;
131 if (dotRow >= range.StartRow && dotRow <= range.EndRow)
132 if (dotColumn >= range.StartColumn && dotColumn <= range.EndColumn)
133 isInside = false;
134 return isInside;