xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_XDataPilotField.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 package ifc.sheet;
28 
29 import com.sun.star.container.XIndexAccess;
30 import com.sun.star.sheet.XDataPilotField;
31 
32 import lib.MultiMethodTest;
33 
34 
35 public class _XDataPilotField extends MultiMethodTest {
36     public XDataPilotField oObj = null;
37 
38     public void _getItems() {
39         XIndexAccess xIA = oObj.getItems();
40         tRes.tested("getItems()", checkIndexAccess(xIA));
41     }
42 
43     /**
44      * calls the method getCount at the IndexAccess, returns true is it is >0
45      * and getByIndex() doesn't throw an exception for Indexes between 0 and count
46      */
47     protected boolean checkIndexAccess(XIndexAccess xIA) {
48         boolean res = true;
49         int count = xIA.getCount();
50         log.println("Found " + count + " Elements");
51         res &= (count > 0);
52 
53         for (int k = 0; k < count; k++) {
54             try {
55                 Object element = xIA.getByIndex(k);
56                 log.println("Element " + k + " = " + element);
57             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
58                 log.println("Unexpected Exception while getting by Index (" + k +
59                             ")" + e.getMessage());
60                 res &= false;
61             } catch (com.sun.star.lang.WrappedTargetException e) {
62                 log.println("Unexpected Exception while getting by Index (" + k +
63                             ")" + e.getMessage());
64                 res &= false;
65             }
66         }
67 
68         return res;
69     }
70 }