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