1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XPrintAreas.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import com
.sun
.star
.sheet
.XPrintAreas
;
33 import com
.sun
.star
.table
.CellRangeAddress
;
34 import lib
.MultiMethodTest
;
36 import lib
.StatusException
;
37 import util
.ValueComparer
;
42 public class _XPrintAreas
extends MultiMethodTest
{
43 public XPrintAreas oObj
= null;
44 CellRangeAddress address
= null;
45 CellRangeAddress subaddress
= null;
46 CellRangeAddress titleColumns
;
47 CellRangeAddress titleRows
;
49 public void before() {
50 address
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeAddress");
51 subaddress
= (CellRangeAddress
)tEnv
.getObjRelation("CellRangeSubAddress");
53 throw new StatusException(Status
.failed("Object relation CellRangeAddress not found"));
54 if (subaddress
== null)
55 throw new StatusException(Status
.failed("Object relation CellRangeSubAddress not found"));
58 public void _getPrintAreas() {
59 requiredMethod("getPrintTitleColumns()");
60 requiredMethod("getPrintTitleRows()");
61 executeMethod("getTitleColumns()");
62 executeMethod("getTitleRows()");
63 CellRangeAddress
[] printAreas
= oObj
.getPrintAreas();
64 CellRangeAddress
[] setValue
= new CellRangeAddress
[]{address
};
65 boolean ret
= ValueComparer
.equalValue(printAreas
, setValue
);
66 // delete the print area
67 oObj
.setPrintAreas(null);
68 printAreas
= oObj
.getPrintAreas();
69 ret
&= printAreas
.length
== 0;
71 tRes
.tested("getPrintAreas()", ret
);
74 public void _getPrintTitleColumns() {
75 requiredMethod("setPrintTitleColumns()");
76 tRes
.tested("getPrintTitleColumns()", !oObj
.getPrintTitleColumns());
79 public void _getPrintTitleRows() {
80 requiredMethod("setPrintTitleRows()");
81 tRes
.tested("getPrintTitleRows()", !oObj
.getPrintTitleRows());
84 public void _getTitleColumns() {
85 requiredMethod("setTitleColumns()");
86 CellRangeAddress setValue
= oObj
.getTitleColumns();
87 tRes
.tested("getTitleColumns()", ValueComparer
.equalValue(setValue
,titleColumns
));
90 public void _getTitleRows() {
91 requiredMethod("setTitleRows()");
92 CellRangeAddress setValue
= oObj
.getTitleRows();
93 tRes
.tested("getTitleRows()", ValueComparer
.equalValue(setValue
,titleRows
));
96 public void _setPrintAreas() {
98 CellRangeAddress
[]setValue
= new CellRangeAddress
[]{subaddress
};
99 oObj
.setPrintAreas(setValue
);
100 CellRangeAddress
[]newVal
= oObj
.getPrintAreas();
101 ret
= ValueComparer
.equalValue(newVal
, setValue
);
102 setValue
= new CellRangeAddress
[]{address
};
103 oObj
.setPrintAreas(setValue
);
104 newVal
= oObj
.getPrintAreas();
105 ret
&= ValueComparer
.equalValue(newVal
, setValue
);
106 tRes
.tested("setPrintAreas()", ret
);
109 public void _setPrintTitleColumns() {
110 requiredMethod("setTitleColumns()");
112 boolean value
= oObj
.getPrintTitleColumns();
113 oObj
.setPrintTitleColumns(!value
);
114 ret
= value
!= oObj
.getPrintTitleColumns();
115 oObj
.setPrintTitleColumns(false);
116 tRes
.tested("setPrintTitleColumns()", ret
);
119 public void _setPrintTitleRows() {
120 requiredMethod("setTitleRows()");
122 boolean value
= oObj
.getPrintTitleRows();
123 oObj
.setPrintTitleRows(!value
);
124 ret
= value
!= oObj
.getPrintTitleRows();
125 oObj
.setPrintTitleRows(false);
126 tRes
.tested("setPrintTitleRows()", ret
);
129 public void _setTitleColumns() {
130 requiredMethod("setPrintAreas()");
132 CellRangeAddress newVal
= oObj
.getTitleColumns();
133 ret
= ValueComparer
.equalValue(newVal
, new CellRangeAddress((short)0, 0, 0, 0, 0));
134 // use first row of range as title column
135 titleColumns
= new CellRangeAddress();
136 titleColumns
.Sheet
= address
.Sheet
;
137 titleColumns
.StartColumn
= address
.StartColumn
;
138 titleColumns
.StartRow
= address
.StartRow
;
139 titleColumns
.EndColumn
= address
.EndColumn
;
140 titleColumns
.EndRow
= address
.StartRow
;
141 oObj
.setTitleColumns(titleColumns
);
142 tRes
.tested("setTitleColumns()", ret
);
145 public void _setTitleRows() {
146 requiredMethod("setPrintAreas()");
148 CellRangeAddress newVal
= oObj
.getTitleRows();
149 ret
= ValueComparer
.equalValue(newVal
, new CellRangeAddress((short)0, 0, 0, 0, 0));
150 // use first column of range as title row
151 titleRows
= new CellRangeAddress();
152 titleRows
.Sheet
= address
.Sheet
;
153 titleRows
.StartColumn
= address
.StartColumn
;
154 titleRows
.StartRow
= address
.StartRow
;
155 titleRows
.EndColumn
= address
.StartColumn
;
156 titleRows
.EndRow
= address
.EndRow
;
157 oObj
.setTitleColumns(titleRows
);
158 tRes
.tested("setTitleRows()", ret
);