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
.XPrintAreas
;
21 import com
.sun
.star
.table
.CellRangeAddress
;
22 import lib
.MultiMethodTest
;
24 import lib
.StatusException
;
25 import util
.ValueComparer
;
30 public class _XPrintAreas
extends MultiMethodTest
{
31 public XPrintAreas oObj
= null;
32 CellRangeAddress address
= null;
33 CellRangeAddress subaddress
= null;
34 CellRangeAddress titleColumns
;
35 CellRangeAddress titleRows
;
38 public void before() {
39 address
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeAddress");
40 subaddress
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeSubAddress");
42 throw new StatusException(Status
.failed("Object relation CellRangeAddress not found"));
43 if (subaddress
== null)
44 throw new StatusException(Status
.failed("Object relation CellRangeSubAddress not found"));
47 public void _getPrintAreas() {
48 requiredMethod("getPrintTitleColumns()");
49 requiredMethod("getPrintTitleRows()");
50 executeMethod("getTitleColumns()");
51 executeMethod("getTitleRows()");
52 CellRangeAddress
[] printAreas
= oObj
.getPrintAreas();
53 CellRangeAddress
[] setValue
= new CellRangeAddress
[]{address
};
54 boolean ret
= ValueComparer
.equalValue(printAreas
, setValue
);
55 // delete the print area
56 oObj
.setPrintAreas(null);
57 printAreas
= oObj
.getPrintAreas();
58 ret
&= printAreas
.length
== 0;
60 tRes
.tested("getPrintAreas()", ret
);
63 public void _getPrintTitleColumns() {
64 requiredMethod("setPrintTitleColumns()");
65 tRes
.tested("getPrintTitleColumns()", !oObj
.getPrintTitleColumns());
68 public void _getPrintTitleRows() {
69 requiredMethod("setPrintTitleRows()");
70 tRes
.tested("getPrintTitleRows()", !oObj
.getPrintTitleRows());
73 public void _getTitleColumns() {
74 requiredMethod("setTitleColumns()");
75 CellRangeAddress setValue
= oObj
.getTitleColumns();
76 tRes
.tested("getTitleColumns()", ValueComparer
.equalValue(setValue
,titleColumns
));
79 public void _getTitleRows() {
80 requiredMethod("setTitleRows()");
81 CellRangeAddress setValue
= oObj
.getTitleRows();
82 tRes
.tested("getTitleRows()", ValueComparer
.equalValue(setValue
,titleRows
));
85 public void _setPrintAreas() {
87 CellRangeAddress
[]setValue
= new CellRangeAddress
[]{subaddress
};
88 oObj
.setPrintAreas(setValue
);
89 CellRangeAddress
[]newVal
= oObj
.getPrintAreas();
90 ret
= ValueComparer
.equalValue(newVal
, setValue
);
91 setValue
= new CellRangeAddress
[]{address
};
92 oObj
.setPrintAreas(setValue
);
93 newVal
= oObj
.getPrintAreas();
94 ret
&= ValueComparer
.equalValue(newVal
, setValue
);
95 tRes
.tested("setPrintAreas()", ret
);
98 public void _setPrintTitleColumns() {
99 requiredMethod("setTitleColumns()");
101 boolean value
= oObj
.getPrintTitleColumns();
102 oObj
.setPrintTitleColumns(!value
);
103 ret
= value
!= oObj
.getPrintTitleColumns();
104 oObj
.setPrintTitleColumns(false);
105 tRes
.tested("setPrintTitleColumns()", ret
);
108 public void _setPrintTitleRows() {
109 requiredMethod("setTitleRows()");
111 boolean value
= oObj
.getPrintTitleRows();
112 oObj
.setPrintTitleRows(!value
);
113 ret
= value
!= oObj
.getPrintTitleRows();
114 oObj
.setPrintTitleRows(false);
115 tRes
.tested("setPrintTitleRows()", ret
);
118 public void _setTitleColumns() {
119 requiredMethod("setPrintAreas()");
121 CellRangeAddress newVal
= oObj
.getTitleColumns();
122 ret
= ValueComparer
.equalValue(newVal
, new CellRangeAddress((short)0, 0, 0, 0, 0));
123 // use first row of range as title column
124 titleColumns
= new CellRangeAddress();
125 titleColumns
.Sheet
= address
.Sheet
;
126 titleColumns
.StartColumn
= address
.StartColumn
;
127 titleColumns
.StartRow
= address
.StartRow
;
128 titleColumns
.EndColumn
= address
.EndColumn
;
129 titleColumns
.EndRow
= address
.StartRow
;
130 oObj
.setTitleColumns(titleColumns
);
131 tRes
.tested("setTitleColumns()", ret
);
134 public void _setTitleRows() {
135 requiredMethod("setPrintAreas()");
137 CellRangeAddress newVal
= oObj
.getTitleRows();
138 ret
= ValueComparer
.equalValue(newVal
, new CellRangeAddress((short)0, 0, 0, 0, 0));
139 // use first column of range as title row
140 titleRows
= new CellRangeAddress();
141 titleRows
.Sheet
= address
.Sheet
;
142 titleRows
.StartColumn
= address
.StartColumn
;
143 titleRows
.StartRow
= address
.StartRow
;
144 titleRows
.EndColumn
= address
.StartColumn
;
145 titleRows
.EndRow
= address
.EndRow
;
146 oObj
.setTitleColumns(titleRows
);
147 tRes
.tested("setTitleRows()", ret
);