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 24 package ifc.sheet; 25 26 import lib.MultiMethodTest; 27 28 import com.sun.star.container.XIndexAccess; 29 import com.sun.star.sheet.XUniqueCellFormatRangesSupplier; 30 31 public class _XUniqueCellFormatRangesSupplier extends MultiMethodTest { 32 33 public XUniqueCellFormatRangesSupplier oObj; 34 35 /** 36 * call the method getUniqueCellFormatRanges and returns OK result if 37 * the gained XIndexAccess isn't null and the method checkIndexAccess 38 * returns true. 39 */ 40 _getUniqueCellFormatRanges()41 public void _getUniqueCellFormatRanges() { 42 boolean res = true; 43 XIndexAccess xIA = oObj.getUniqueCellFormatRanges(); 44 if (xIA != null) { 45 res = checkIndexAccess(xIA); 46 } else { 47 log.println("The gained IndexAccess is null"); 48 res = false; 49 } 50 tRes.tested("getUniqueCellFormatRanges()",res); 51 } 52 53 /** 54 * calls the method getCount at the IndexAccess, returns true is it is >0 55 * and getByIndex() doesn't throw an exception for Indexes between 0 and count 56 */ 57 checkIndexAccess(XIndexAccess xIA)58 protected boolean checkIndexAccess(XIndexAccess xIA) { 59 boolean res = true; 60 int count = xIA.getCount(); 61 log.println("Found "+count+" Elements"); 62 res &= count>0; 63 for (int k=0; k<count; k++) { 64 try { 65 Object element = xIA.getByIndex(k); 66 log.println("Element "+k+" = "+element); 67 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 68 log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); 69 res &=false; 70 } catch (com.sun.star.lang.WrappedTargetException e) { 71 log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); 72 res &=false; 73 } 74 } 75 return res; 76 } 77 78 79 } 80