1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir package mod._sc;
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
30*cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
31*cdf0e10cSrcweir import com.sun.star.container.XNamed;
32*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
33*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
34*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldGroupInfo;
35*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotDescriptor;
36*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotFieldGrouping;
37*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTables;
38*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTablesSupplier;
39*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheet;
40*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheetDocument;
41*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheets;
42*cdf0e10cSrcweir import com.sun.star.table.CellAddress;
43*cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress;
44*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
45*cdf0e10cSrcweir import com.sun.star.uno.Type;
46*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
47*cdf0e10cSrcweir import com.sun.star.uno.XInterface;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir import java.io.PrintWriter;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir import lib.StatusException;
52*cdf0e10cSrcweir import lib.TestCase;
53*cdf0e10cSrcweir import lib.TestEnvironment;
54*cdf0e10cSrcweir import lib.TestParameters;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir import util.SOfficeFactory;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir public class ScDataPilotFieldGroupObj extends TestCase
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     static XSpreadsheetDocument xSheetDoc = null;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     /**
65*cdf0e10cSrcweir      * A field is filled some values. This integer determines the size of the
66*cdf0e10cSrcweir      * field in x and y direction.
67*cdf0e10cSrcweir      */
68*cdf0e10cSrcweir     private int mMaxFieldIndex = 6;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     /**
71*cdf0e10cSrcweir      * Creates Spreadsheet document.
72*cdf0e10cSrcweir      */
73*cdf0e10cSrcweir     protected void initialize (TestParameters tParam, PrintWriter log)
74*cdf0e10cSrcweir     {
75*cdf0e10cSrcweir         SOfficeFactory SOF = SOfficeFactory.getFactory (
76*cdf0e10cSrcweir             (XMultiServiceFactory) tParam.getMSF ());
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         try
79*cdf0e10cSrcweir         {
80*cdf0e10cSrcweir             log.println ("creating a Spreadsheet document");
81*cdf0e10cSrcweir             xSheetDoc = SOF.createCalcDoc (null);
82*cdf0e10cSrcweir         }
83*cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
84*cdf0e10cSrcweir         {
85*cdf0e10cSrcweir             // Some exception occures.FAILED
86*cdf0e10cSrcweir             e.printStackTrace (log);
87*cdf0e10cSrcweir             throw new StatusException ("Couldn't create document", e);
88*cdf0e10cSrcweir         }
89*cdf0e10cSrcweir     }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     /**
92*cdf0e10cSrcweir      * Disposes Spreadsheet document.
93*cdf0e10cSrcweir      */
94*cdf0e10cSrcweir     protected void cleanup (TestParameters tParam, PrintWriter log)
95*cdf0e10cSrcweir     {
96*cdf0e10cSrcweir         log.println ("    disposing xSheetDoc ");
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         XComponent oComp = (XComponent) UnoRuntime.queryInterface (
99*cdf0e10cSrcweir             XComponent.class, xSheetDoc);
100*cdf0e10cSrcweir         util.DesktopTools.closeDoc (oComp);
101*cdf0e10cSrcweir     }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     protected synchronized TestEnvironment createTestEnvironment (TestParameters Param,
104*cdf0e10cSrcweir         PrintWriter log)
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         XInterface oObj = null;
107*cdf0e10cSrcweir         XInterface datapilotfield = null;
108*cdf0e10cSrcweir         XInterface groups = null;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         // creation of testobject here
111*cdf0e10cSrcweir         // first we write what we are intend to do to log file
112*cdf0e10cSrcweir         log.println ("Creating a test environment");
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         // the cell range
115*cdf0e10cSrcweir         CellRangeAddress sCellRangeAdress = new CellRangeAddress ();
116*cdf0e10cSrcweir         sCellRangeAdress.Sheet = 0;
117*cdf0e10cSrcweir         sCellRangeAdress.StartColumn = 1;
118*cdf0e10cSrcweir         sCellRangeAdress.StartRow = 0;
119*cdf0e10cSrcweir         sCellRangeAdress.EndColumn = mMaxFieldIndex - 1;
120*cdf0e10cSrcweir         sCellRangeAdress.EndRow = mMaxFieldIndex - 1;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         // position of the data pilot table
123*cdf0e10cSrcweir         CellAddress sCellAdress = new CellAddress ();
124*cdf0e10cSrcweir         sCellAdress.Sheet = 0;
125*cdf0e10cSrcweir         sCellAdress.Column = 7;
126*cdf0e10cSrcweir         sCellAdress.Row = 8;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         log.println ("Getting a sheet");
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir         XSpreadsheets xSpreadsheets = (XSpreadsheets) xSheetDoc.getSheets ();
131*cdf0e10cSrcweir         XSpreadsheet oSheet = null;
132*cdf0e10cSrcweir         XSpreadsheet oSheet2 = null;
133*cdf0e10cSrcweir         XIndexAccess oIndexAccess = (XIndexAccess) UnoRuntime.queryInterface (
134*cdf0e10cSrcweir             XIndexAccess.class, xSpreadsheets);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         try
137*cdf0e10cSrcweir         {
138*cdf0e10cSrcweir             oSheet = (XSpreadsheet) AnyConverter.toObject (
139*cdf0e10cSrcweir                 new Type (XSpreadsheet.class),
140*cdf0e10cSrcweir                 oIndexAccess.getByIndex (0));
141*cdf0e10cSrcweir             oSheet2 = (XSpreadsheet) AnyConverter.toObject (
142*cdf0e10cSrcweir                 new Type (XSpreadsheet.class),
143*cdf0e10cSrcweir                 oIndexAccess.getByIndex (1));
144*cdf0e10cSrcweir         }
145*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
146*cdf0e10cSrcweir         {
147*cdf0e10cSrcweir             e.printStackTrace ();
148*cdf0e10cSrcweir             throw new StatusException ("Couldn't get a spreadsheet", e);
149*cdf0e10cSrcweir         }
150*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
151*cdf0e10cSrcweir         {
152*cdf0e10cSrcweir             e.printStackTrace ();
153*cdf0e10cSrcweir             throw new StatusException ("Couldn't get a spreadsheet", e);
154*cdf0e10cSrcweir         }
155*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
156*cdf0e10cSrcweir         {
157*cdf0e10cSrcweir             e.printStackTrace ();
158*cdf0e10cSrcweir             throw new StatusException ("Couldn't get a spreadsheet", e);
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         try
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             log.println ("Filling a table");
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++)
166*cdf0e10cSrcweir             {
167*cdf0e10cSrcweir                 oSheet.getCellByPosition (i, 0).setFormula ("Col" + i);
168*cdf0e10cSrcweir                 oSheet.getCellByPosition (0, i).setFormula ("Row" + i);
169*cdf0e10cSrcweir                 oSheet2.getCellByPosition (i, 0).setFormula ("Col" + i);
170*cdf0e10cSrcweir                 oSheet2.getCellByPosition (0, i).setFormula ("Row" + i);
171*cdf0e10cSrcweir             }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++)
174*cdf0e10cSrcweir             {
175*cdf0e10cSrcweir                 for (int j = 1; j < mMaxFieldIndex; j++)
176*cdf0e10cSrcweir                 {
177*cdf0e10cSrcweir                     oSheet.getCellByPosition (i, j).setValue (i * (j + 1));
178*cdf0e10cSrcweir                     oSheet2.getCellByPosition (i, j).setValue (i * (j + 2));
179*cdf0e10cSrcweir                 }
180*cdf0e10cSrcweir             }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir             oSheet.getCellByPosition (1, 1).setFormula ("aName");
183*cdf0e10cSrcweir             oSheet.getCellByPosition (1, 2).setFormula ("otherName");
184*cdf0e10cSrcweir             oSheet.getCellByPosition (1, 3).setFormula ("una");
185*cdf0e10cSrcweir             oSheet.getCellByPosition (1, 4).setFormula ("otherName");
186*cdf0e10cSrcweir             oSheet.getCellByPosition (1, 5).setFormula ("somethingelse");
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir         }
189*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
190*cdf0e10cSrcweir         {
191*cdf0e10cSrcweir             e.printStackTrace ();
192*cdf0e10cSrcweir             throw new StatusException ("Couldn't fill some cells", e);
193*cdf0e10cSrcweir         }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         // change a value of a cell and check the change in the data pilot
196*cdf0e10cSrcweir         // (for the XDataPilotTable.refresh() test)
197*cdf0e10cSrcweir         Object oChangeCell = null;
198*cdf0e10cSrcweir         Object oCheckCell = null;
199*cdf0e10cSrcweir         Integer aChangeValue = null;
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         try
202*cdf0e10cSrcweir         {
203*cdf0e10cSrcweir             // cell of data
204*cdf0e10cSrcweir             oChangeCell = oSheet.getCellByPosition (1, 5);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir             int x = sCellAdress.Column;
207*cdf0e10cSrcweir             int y = sCellAdress.Row + 3;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir             // cell of the data pilot output
211*cdf0e10cSrcweir             oCheckCell = oSheet.getCellByPosition (x, y);
212*cdf0e10cSrcweir             aChangeValue = new Integer (27);
213*cdf0e10cSrcweir         }
214*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             e.printStackTrace ();
217*cdf0e10cSrcweir             throw new StatusException ("Couldn't get cells for changeing.", e);
218*cdf0e10cSrcweir         }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir         // create the test objects
222*cdf0e10cSrcweir         log.println ("Getting test objects");
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir         XDataPilotTablesSupplier DPTS = (XDataPilotTablesSupplier) UnoRuntime.queryInterface (
225*cdf0e10cSrcweir             XDataPilotTablesSupplier.class,
226*cdf0e10cSrcweir             oSheet);
227*cdf0e10cSrcweir         XDataPilotTables DPT = DPTS.getDataPilotTables ();
228*cdf0e10cSrcweir         XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor ();
229*cdf0e10cSrcweir         DPDsc.setSourceRange (sCellRangeAdress);
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         XPropertySet fieldPropSet = null;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir         try
234*cdf0e10cSrcweir         {
235*cdf0e10cSrcweir             Object oDataPilotField = DPDsc.getDataPilotFields ().getByIndex (0);
236*cdf0e10cSrcweir             fieldPropSet = (XPropertySet) UnoRuntime.queryInterface (
237*cdf0e10cSrcweir                 XPropertySet.class, oDataPilotField);
238*cdf0e10cSrcweir             fieldPropSet.setPropertyValue ("Orientation",
239*cdf0e10cSrcweir                 com.sun.star.sheet.DataPilotFieldOrientation.ROW);
240*cdf0e10cSrcweir             oDataPilotField = DPDsc.getDataPilotFields ().getByIndex (1);
241*cdf0e10cSrcweir             fieldPropSet = (XPropertySet) UnoRuntime.queryInterface (
242*cdf0e10cSrcweir                 XPropertySet.class, oDataPilotField);
243*cdf0e10cSrcweir             fieldPropSet.setPropertyValue ("Function",
244*cdf0e10cSrcweir                 com.sun.star.sheet.GeneralFunction.SUM);
245*cdf0e10cSrcweir             fieldPropSet.setPropertyValue ("Orientation",
246*cdf0e10cSrcweir                 com.sun.star.sheet.DataPilotFieldOrientation.DATA);
247*cdf0e10cSrcweir             oDataPilotField = DPDsc.getDataPilotFields ().getByIndex (2);
248*cdf0e10cSrcweir             fieldPropSet = (XPropertySet) UnoRuntime.queryInterface (
249*cdf0e10cSrcweir                 XPropertySet.class, oDataPilotField);
250*cdf0e10cSrcweir             fieldPropSet.setPropertyValue ("Orientation",
251*cdf0e10cSrcweir                 com.sun.star.sheet.DataPilotFieldOrientation.COLUMN);
252*cdf0e10cSrcweir         }
253*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
254*cdf0e10cSrcweir         {
255*cdf0e10cSrcweir             e.printStackTrace ();
256*cdf0e10cSrcweir             throw new StatusException ("Couldn't create a test environment", e);
257*cdf0e10cSrcweir         }
258*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
259*cdf0e10cSrcweir         {
260*cdf0e10cSrcweir             e.printStackTrace ();
261*cdf0e10cSrcweir             throw new StatusException ("Couldn't create a test environment", e);
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir         catch (com.sun.star.beans.PropertyVetoException e)
264*cdf0e10cSrcweir         {
265*cdf0e10cSrcweir             e.printStackTrace ();
266*cdf0e10cSrcweir             throw new StatusException ("Couldn't create a test environment", e);
267*cdf0e10cSrcweir         }
268*cdf0e10cSrcweir         catch (com.sun.star.beans.UnknownPropertyException e)
269*cdf0e10cSrcweir         {
270*cdf0e10cSrcweir             e.printStackTrace ();
271*cdf0e10cSrcweir             throw new StatusException ("Couldn't create a test environment", e);
272*cdf0e10cSrcweir         }
273*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
274*cdf0e10cSrcweir         {
275*cdf0e10cSrcweir             e.printStackTrace ();
276*cdf0e10cSrcweir             throw new StatusException ("Couldn't create a test environment", e);
277*cdf0e10cSrcweir         }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir         log.println ("Insert the DataPilotTable");
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir         if (DPT.hasByName ("DataPilotTable"))
282*cdf0e10cSrcweir         {
283*cdf0e10cSrcweir             DPT.removeByName ("DataPilotTable");
284*cdf0e10cSrcweir         }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir         DPT.insertNewByName ("DataPilotTable", sCellAdress, DPDsc);
287*cdf0e10cSrcweir         XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface (XIndexAccess.class,DPTS.getDataPilotTables ());
288*cdf0e10cSrcweir         XIndexAccess IA = null;
289*cdf0e10cSrcweir         try
290*cdf0e10cSrcweir         {
291*cdf0e10cSrcweir             XDataPilotDescriptor xDPT = (XDataPilotDescriptor) UnoRuntime.queryInterface (XDataPilotDescriptor.class,xIA.getByIndex (0));
292*cdf0e10cSrcweir             IA = xDPT.getRowFields ();
293*cdf0e10cSrcweir             //getSRange(IA);
294*cdf0e10cSrcweir             System.out.println ("COUNT: "+IA.getCount ());
295*cdf0e10cSrcweir             datapilotfield = (XInterface) AnyConverter.toObject (
296*cdf0e10cSrcweir                 new Type (XInterface.class), IA.getByIndex (0));
297*cdf0e10cSrcweir         }
298*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
299*cdf0e10cSrcweir         {
300*cdf0e10cSrcweir             e.printStackTrace ();
301*cdf0e10cSrcweir             throw new StatusException ("Couldn't get data pilot field", e);
302*cdf0e10cSrcweir         }
303*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
304*cdf0e10cSrcweir         {
305*cdf0e10cSrcweir             e.printStackTrace ();
306*cdf0e10cSrcweir             throw new StatusException ("Couldn't get data pilot field", e);
307*cdf0e10cSrcweir         }
308*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
309*cdf0e10cSrcweir         {
310*cdf0e10cSrcweir             e.printStackTrace ();
311*cdf0e10cSrcweir             throw new StatusException ("Couldn't get data pilot field", e);
312*cdf0e10cSrcweir         }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         try
315*cdf0e10cSrcweir         {
316*cdf0e10cSrcweir             XDataPilotFieldGrouping  dpfg = (XDataPilotFieldGrouping) UnoRuntime.queryInterface (XDataPilotFieldGrouping.class, datapilotfield);
317*cdf0e10cSrcweir             String[] elements = new String[]{"aName","otherName"};
318*cdf0e10cSrcweir             dpfg.createNameGroup (elements);
319*cdf0e10cSrcweir             DataPilotFieldGroupInfo dpgi=null;
320*cdf0e10cSrcweir             xIA = (XIndexAccess) UnoRuntime.queryInterface (XIndexAccess.class,DPTS.getDataPilotTables ());
321*cdf0e10cSrcweir         try
322*cdf0e10cSrcweir         {
323*cdf0e10cSrcweir             XDataPilotDescriptor xDPT = (XDataPilotDescriptor) UnoRuntime.queryInterface (XDataPilotDescriptor.class,xIA.getByIndex (0));
324*cdf0e10cSrcweir             IA = xDPT.getRowFields ();
325*cdf0e10cSrcweir         }
326*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
327*cdf0e10cSrcweir         {
328*cdf0e10cSrcweir             e.printStackTrace ();
329*cdf0e10cSrcweir             throw new StatusException ("Couldn't get data pilot field", e);
330*cdf0e10cSrcweir         }
331*cdf0e10cSrcweir         catch (com.sun.star.lang.IndexOutOfBoundsException e)
332*cdf0e10cSrcweir         {
333*cdf0e10cSrcweir             e.printStackTrace ();
334*cdf0e10cSrcweir             throw new StatusException ("Couldn't get data pilot field", e);
335*cdf0e10cSrcweir         }
336*cdf0e10cSrcweir             for (int i=0;i<IA.getCount ();i++)
337*cdf0e10cSrcweir             {
338*cdf0e10cSrcweir                 datapilotfield = (XInterface) AnyConverter.toObject (
339*cdf0e10cSrcweir                     new Type (XInterface.class), IA.getByIndex (i));
340*cdf0e10cSrcweir                 XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface (XPropertySet.class, IA.getByIndex (i));
341*cdf0e10cSrcweir                 if (((Boolean)xPropertySet.getPropertyValue ("IsGroupField")).booleanValue ())
342*cdf0e10cSrcweir                 {
343*cdf0e10cSrcweir                     xPropertySet = (XPropertySet) UnoRuntime.queryInterface (XPropertySet.class, datapilotfield);
344*cdf0e10cSrcweir                     XNamed xNamed = (XNamed) UnoRuntime.queryInterface (XNamed.class, IA.getByIndex (i));
345*cdf0e10cSrcweir                     System.out.println ("name: "+xNamed.getName ());
346*cdf0e10cSrcweir                     dpgi = (DataPilotFieldGroupInfo) xPropertySet.getPropertyValue ("GroupInfo");
347*cdf0e10cSrcweir                 }
348*cdf0e10cSrcweir             }
349*cdf0e10cSrcweir             groups = dpgi.Groups;
350*cdf0e10cSrcweir             XIndexAccess groupAccess = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, groups);
351*cdf0e10cSrcweir             oObj = (XInterface) UnoRuntime.queryInterface(XInterface.class, groupAccess.getByIndex(0));
352*cdf0e10cSrcweir         }
353*cdf0e10cSrcweir         catch (Exception e)
354*cdf0e10cSrcweir         {
355*cdf0e10cSrcweir             e.printStackTrace ();
356*cdf0e10cSrcweir         }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         log.println ("Creating object - " +
359*cdf0e10cSrcweir             ((oObj == null) ? "FAILED" : "OK"));
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment (oObj);
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         log.println ("Implementationname: " + util.utils.getImplName (oObj));
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         // Other parameters required for interface tests
366*cdf0e10cSrcweir         return tEnv;
367*cdf0e10cSrcweir     }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir }
370