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 .
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
;
29 import lib
.StatusException
;
34 public class _XSheetOutline
extends MultiMethodTest
{
35 public XSheetOutline oObj
= null;
36 CellRangeAddress address
= null;
37 CellRangeAddress subaddress
= null;
40 public void before() {
41 address
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeAddress");
42 subaddress
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeSubAddress");
44 throw new StatusException(Status
.failed("Object relation CellRangeAddress not found"));
45 if (subaddress
== null)
46 throw new StatusException(Status
.failed("Object relation CellRangeSubAddress not found"));
49 public void _autoOutline() {
50 executeMethod("ungroup()");
51 boolean result
= false;
52 oObj
.autoOutline(address
);
53 // initially the range is grouped and shown
54 result
= isCellShown(subaddress
);
55 oObj
.hideDetail(address
);
56 // here only a part of the address is hidden: subaddress must be that part
57 result
&= !isCellShown(subaddress
);
58 tRes
.tested("autoOutline()", result
);
61 public void _clearOutline() {
62 executeMethod("autoOutline()");
63 boolean result
= false;
65 result
= isCellShown(subaddress
);
66 oObj
.hideDetail(address
);
67 result
&= isCellShown(subaddress
);
68 tRes
.tested("clearOutline()", result
);
71 public void _group() {
72 oObj
.group(address
, TableOrientation
.COLUMNS
);
73 oObj
.group(address
, TableOrientation
.ROWS
);
74 tRes
.tested("group()", true);
77 public void _ungroup() {
78 executeMethod("showDetail()");
79 oObj
.ungroup(address
, TableOrientation
.COLUMNS
);
80 oObj
.ungroup(address
, TableOrientation
.ROWS
);
81 oObj
.hideDetail(address
);
82 tRes
.tested("ungroup()", isCellShown(address
));
85 public void _hideDetail() {
86 requiredMethod("group()");
87 oObj
.hideDetail(address
);
88 tRes
.tested("hideDetail()", !isCellShown(address
));
91 public void _showDetail() {
92 executeMethod("showLevel()");
93 oObj
.showDetail(address
);
94 tRes
.tested("showDetail()", isCellShown(address
));
97 public void _showLevel() {
98 executeMethod("hideDetail()");
99 boolean result
= false;
100 oObj
.showLevel((short)2, TableOrientation
.COLUMNS
);
101 oObj
.showLevel((short)2, TableOrientation
.ROWS
);
102 result
= isCellShown(address
);
103 oObj
.showLevel((short)0, TableOrientation
.COLUMNS
);
104 oObj
.showLevel((short)0, TableOrientation
.ROWS
);
106 result
&= !isCellShown(address
);
107 tRes
.tested("showLevel()", result
);
110 private boolean isCellShown(CellRangeAddress range
) {
111 boolean isNotShown
= true;
112 XCellRangesQuery xCellRangesQuery
= UnoRuntime
.queryInterface(XCellRangesQuery
.class, oObj
);
113 if (xCellRangesQuery
!= null) {
114 XSheetCellRanges xRanges
= xCellRangesQuery
.queryVisibleCells();
115 CellRangeAddress
[] visibleRanges
= xRanges
.getRangeAddresses();
116 for (int i
=0; i
<visibleRanges
.length
; i
++) {
117 isNotShown
&= dotIsOutsideRange(range
.StartRow
, range
.StartColumn
, visibleRanges
[i
]);
118 isNotShown
&= dotIsOutsideRange(range
.StartRow
, range
.EndColumn
, visibleRanges
[i
]);
119 isNotShown
&= dotIsOutsideRange(range
.EndRow
, range
.StartColumn
, visibleRanges
[i
]);
120 isNotShown
&= dotIsOutsideRange(range
.EndRow
, range
.EndColumn
, visibleRanges
[i
]);
121 log
.println(isNotShown?
"\tisOutSide":"\tisInside");
127 private boolean dotIsOutsideRange(int dotRow
, int dotColumn
, CellRangeAddress range
) {
128 log
.println("Checking dot(" + dotRow
+ "," + dotColumn
+ ") against row["
129 + range
.StartRow
+ ":" + range
.EndRow
+ "] column["
130 + range
.StartColumn
+ ":" + range
.EndColumn
+ "]");
131 boolean isInside
= true;
132 if (dotRow
>= range
.StartRow
&& dotRow
<= range
.EndRow
)
133 if (dotColumn
>= range
.StartColumn
&& dotColumn
<= range
.EndColumn
)