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.container.XIndexAccess;
26 import com.sun.star.sheet.XDataPilotField;
27 
28 import lib.MultiMethodTest;
29 
30 
31 public class _XDataPilotField extends MultiMethodTest {
32     public XDataPilotField oObj = null;
33 
_getItems()34     public void _getItems() {
35         XIndexAccess xIA = oObj.getItems();
36         tRes.tested("getItems()", checkIndexAccess(xIA));
37     }
38 
39     /**
40      * calls the method getCount at the IndexAccess, returns true is it is >0
41      * and getByIndex() doesn't throw an exception for Indexes between 0 and count
42      */
checkIndexAccess(XIndexAccess xIA)43     protected boolean checkIndexAccess(XIndexAccess xIA) {
44         boolean res = true;
45         int count = xIA.getCount();
46         log.println("Found " + count + " Elements");
47         res &= (count > 0);
48 
49         for (int k = 0; k < count; k++) {
50             try {
51                 Object element = xIA.getByIndex(k);
52                 log.println("Element " + k + " = " + element);
53             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
54                 log.println("Unexpected Exception while getting by Index (" + k +
55                             ")" + e.getMessage());
56                 res &= false;
57             } catch (com.sun.star.lang.WrappedTargetException e) {
58                 log.println("Unexpected Exception while getting by Index (" + k +
59                             ")" + e.getMessage());
60                 res &= false;
61             }
62         }
63 
64         return res;
65     }
66 }