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 lib.MultiMethodTest; 26 27 import com.sun.star.sheet.TableFilterField; 28 import com.sun.star.sheet.XSheetFilterDescriptor; 29 import com.sun.star.sheet.XSheetFilterable; 30 import com.sun.star.sheet.XSheetFilterableEx; 31 import com.sun.star.uno.UnoRuntime; 32 33 34 /** 35 * Inteface test for XSheetFilterableEx 36 * 37 * methods: 38 * 39 * createFilterDescriptorByObject 40 * 41 */ 42 public class _XSheetFilterableEx extends MultiMethodTest { 43 public XSheetFilterableEx oObj = null; 44 45 /** 46 * queries a XSheetFilterable from the parent Object and then creates 47 * a XSheetFilterDescriptor with it. 48 * Returns OK if the Descriptor isn't null and checkFilterDescriptor returns true 49 */ 50 _createFilterDescriptorByObject()51 public void _createFilterDescriptorByObject() { 52 boolean res = true; 53 Object parent = tEnv.getTestObject(); 54 XSheetFilterable aFilterable = (XSheetFilterable) UnoRuntime.queryInterface( 55 XSheetFilterable.class, parent); 56 XSheetFilterDescriptor desc = oObj.createFilterDescriptorByObject( 57 aFilterable); 58 59 if (desc != null) { 60 res &= checkFilterDescriptor(desc); 61 } else { 62 log.println("gained XSheetFilterDescriptor is null"); 63 res &= false; 64 } 65 tRes.tested("createFilterDescriptorByObject()",res); 66 } 67 68 /** 69 * returns true if the Method getFilterFields() returns a non empty array 70 * and all Fields can be gained without exception 71 */ 72 checkFilterDescriptor(XSheetFilterDescriptor desc)73 public boolean checkFilterDescriptor(XSheetFilterDescriptor desc) { 74 TableFilterField[] fields = desc.getFilterFields(); 75 boolean res = true; 76 77 if (fields.length == 0) { 78 log.println("The gained Descriptor is empty"); 79 res &= false; 80 } else { 81 log.println("Found "+fields.length+" TableFields"); 82 } 83 84 for (int k = 0; k < fields.length; k++) { 85 log.println("StringValue(" + k + "): " + fields[k].StringValue); 86 log.println("IsNumeric(" + k + "): " + fields[k].IsNumeric); 87 log.println("NumericValue(" + k + "): " + fields[k].NumericValue); 88 log.println("Field(" + k + "): " + fields[k].Field); 89 log.println("Connection(" + k + "): " + fields[k].Connection); 90 log.println("Operator(" + k + "): " + fields[k].Operator); 91 } 92 93 return res; 94 } 95 }