1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.sheet; 24 25 import com.sun.star.sheet.XPrintAreas; 26 import com.sun.star.table.CellRangeAddress; 27 import lib.MultiMethodTest; 28 import lib.Status; 29 import lib.StatusException; 30 import util.ValueComparer; 31 32 /** 33 * 34 */ 35 public class _XPrintAreas extends MultiMethodTest { 36 public XPrintAreas oObj = null; 37 CellRangeAddress address = null; 38 CellRangeAddress subaddress = null; 39 CellRangeAddress titleColumns; 40 CellRangeAddress titleRows; 41 before()42 public void before() { 43 address = (CellRangeAddress)tEnv.getObjRelation("CellRangeAddress"); 44 subaddress = (CellRangeAddress)tEnv.getObjRelation("CellRangeSubAddress"); 45 if (address == null) 46 throw new StatusException(Status.failed("Object relation CellRangeAddress not found")); 47 if (subaddress == null) 48 throw new StatusException(Status.failed("Object relation CellRangeSubAddress not found")); 49 } 50 _getPrintAreas()51 public void _getPrintAreas() { 52 requiredMethod("getPrintTitleColumns()"); 53 requiredMethod("getPrintTitleRows()"); 54 executeMethod("getTitleColumns()"); 55 executeMethod("getTitleRows()"); 56 CellRangeAddress[] printAreas = oObj.getPrintAreas(); 57 CellRangeAddress[] setValue = new CellRangeAddress[]{address}; 58 boolean ret = ValueComparer.equalValue(printAreas, setValue); 59 // delete the print area 60 oObj.setPrintAreas(null); 61 printAreas = oObj.getPrintAreas(); 62 ret &= printAreas.length == 0; 63 64 tRes.tested("getPrintAreas()", ret); 65 } 66 _getPrintTitleColumns()67 public void _getPrintTitleColumns() { 68 requiredMethod("setPrintTitleColumns()"); 69 tRes.tested("getPrintTitleColumns()", !oObj.getPrintTitleColumns()); 70 } 71 _getPrintTitleRows()72 public void _getPrintTitleRows() { 73 requiredMethod("setPrintTitleRows()"); 74 tRes.tested("getPrintTitleRows()", !oObj.getPrintTitleRows()); 75 } 76 _getTitleColumns()77 public void _getTitleColumns() { 78 requiredMethod("setTitleColumns()"); 79 CellRangeAddress setValue = oObj.getTitleColumns(); 80 tRes.tested("getTitleColumns()", ValueComparer.equalValue(setValue,titleColumns)); 81 } 82 _getTitleRows()83 public void _getTitleRows() { 84 requiredMethod("setTitleRows()"); 85 CellRangeAddress setValue = oObj.getTitleRows(); 86 tRes.tested("getTitleRows()", ValueComparer.equalValue(setValue,titleRows)); 87 } 88 _setPrintAreas()89 public void _setPrintAreas() { 90 boolean ret = false; 91 CellRangeAddress[]setValue = new CellRangeAddress[]{subaddress}; 92 oObj.setPrintAreas(setValue); 93 CellRangeAddress[]newVal = oObj.getPrintAreas(); 94 ret = ValueComparer.equalValue(newVal, setValue); 95 setValue = new CellRangeAddress[]{address}; 96 oObj.setPrintAreas(setValue); 97 newVal = oObj.getPrintAreas(); 98 ret &= ValueComparer.equalValue(newVal, setValue); 99 tRes.tested("setPrintAreas()", ret); 100 } 101 _setPrintTitleColumns()102 public void _setPrintTitleColumns() { 103 requiredMethod("setTitleColumns()"); 104 boolean ret = false; 105 boolean value = oObj.getPrintTitleColumns(); 106 oObj.setPrintTitleColumns(!value); 107 ret = value != oObj.getPrintTitleColumns(); 108 oObj.setPrintTitleColumns(false); 109 tRes.tested("setPrintTitleColumns()", ret); 110 } 111 _setPrintTitleRows()112 public void _setPrintTitleRows() { 113 requiredMethod("setTitleRows()"); 114 boolean ret = false; 115 boolean value = oObj.getPrintTitleRows(); 116 oObj.setPrintTitleRows(!value); 117 ret = value != oObj.getPrintTitleRows(); 118 oObj.setPrintTitleRows(false); 119 tRes.tested("setPrintTitleRows()", ret); 120 } 121 _setTitleColumns()122 public void _setTitleColumns() { 123 requiredMethod("setPrintAreas()"); 124 boolean ret = false; 125 CellRangeAddress newVal = oObj.getTitleColumns(); 126 ret = ValueComparer.equalValue(newVal, new CellRangeAddress((short)0, 0, 0, 0, 0)); 127 // use first row of range as title column 128 titleColumns = new CellRangeAddress(); 129 titleColumns.Sheet = address.Sheet; 130 titleColumns.StartColumn = address.StartColumn; 131 titleColumns.StartRow = address.StartRow; 132 titleColumns.EndColumn = address.EndColumn; 133 titleColumns.EndRow = address.StartRow; 134 oObj.setTitleColumns(titleColumns); 135 tRes.tested("setTitleColumns()", ret); 136 } 137 _setTitleRows()138 public void _setTitleRows() { 139 requiredMethod("setPrintAreas()"); 140 boolean ret = false; 141 CellRangeAddress newVal = oObj.getTitleRows(); 142 ret = ValueComparer.equalValue(newVal, new CellRangeAddress((short)0, 0, 0, 0, 0)); 143 // use first column of range as title row 144 titleRows = new CellRangeAddress(); 145 titleRows.Sheet = address.Sheet; 146 titleRows.StartColumn = address.StartColumn; 147 titleRows.StartRow = address.StartRow; 148 titleRows.EndColumn = address.StartColumn; 149 titleRows.EndRow = address.EndRow; 150 oObj.setTitleColumns(titleRows); 151 tRes.tested("setTitleRows()", ret); 152 } 153 154 } 155