xref: /AOO41X/main/qadevOOo/tests/java/mod/_sc/ScDataPilotTableObj.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
28*cdf0e10cSrcweir package mod._sc;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import java.io.PrintWriter;
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir import lib.StatusException;
33*cdf0e10cSrcweir import lib.TestCase;
34*cdf0e10cSrcweir import lib.TestEnvironment;
35*cdf0e10cSrcweir import lib.TestParameters;
36*cdf0e10cSrcweir import util.SOfficeFactory;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
39*cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
40*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
41*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
42*cdf0e10cSrcweir import com.sun.star.sheet.TableFilterField;
43*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotDescriptor;
44*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTables;
45*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTablesSupplier;
46*cdf0e10cSrcweir import com.sun.star.sheet.XSheetFilterDescriptor;
47*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheet;
48*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheetDocument;
49*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheets;
50*cdf0e10cSrcweir import com.sun.star.table.CellAddress;
51*cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress;
52*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
53*cdf0e10cSrcweir import com.sun.star.uno.Type;
54*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
55*cdf0e10cSrcweir import com.sun.star.uno.XInterface;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /**
58*cdf0e10cSrcweir * Test for object which is represented by service
59*cdf0e10cSrcweir * <code>com.sun.star.sheet.DataPilotTable</code>. <p>
60*cdf0e10cSrcweir * Object implements the following interfaces :
61*cdf0e10cSrcweir * <ul>
62*cdf0e10cSrcweir *  <li> <code>com::sun::star::container::XNamed</code></li>
63*cdf0e10cSrcweir *  <li> <code>com::sun::star::sheet::XDataPilotTable</code></li>
64*cdf0e10cSrcweir *  <li> <code>com::sun::star::sheet::XDataPilotDescriptor</code></li>
65*cdf0e10cSrcweir * </ul>
66*cdf0e10cSrcweir * @see com.sun.star.sheet.DataPilotTable
67*cdf0e10cSrcweir * @see com.sun.star.container.XNamed
68*cdf0e10cSrcweir * @see com.sun.star.sheet.XDataPilotTable
69*cdf0e10cSrcweir * @see com.sun.star.sheet.XDataPilotDescriptor
70*cdf0e10cSrcweir * @see ifc.container._XNamed
71*cdf0e10cSrcweir * @see ifc.sheet._XDataPilotTable
72*cdf0e10cSrcweir * @see ifc.sheet._XDataPilotDescriptor
73*cdf0e10cSrcweir */
74*cdf0e10cSrcweir public class ScDataPilotTableObj extends TestCase {
75*cdf0e10cSrcweir     static XSpreadsheetDocument xSheetDoc = null;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     /**
78*cdf0e10cSrcweir     * Creates Spreadsheet document.
79*cdf0e10cSrcweir     */
80*cdf0e10cSrcweir     protected void initialize( TestParameters tParam, PrintWriter log ) {
81*cdf0e10cSrcweir         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir         try {
84*cdf0e10cSrcweir             log.println( "creating a Spreadsheet document" );
85*cdf0e10cSrcweir             xSheetDoc = SOF.createCalcDoc(null);
86*cdf0e10cSrcweir         } catch ( com.sun.star.uno.Exception e ) {
87*cdf0e10cSrcweir             // Some exception occures.FAILED
88*cdf0e10cSrcweir             e.printStackTrace( log );
89*cdf0e10cSrcweir             throw new StatusException( "Couldn't create document", e );
90*cdf0e10cSrcweir         }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     /**
95*cdf0e10cSrcweir     * Disposes Spreadsheet document.
96*cdf0e10cSrcweir     */
97*cdf0e10cSrcweir     protected void cleanup( TestParameters tParam, PrintWriter log ) {
98*cdf0e10cSrcweir         log.println( "    disposing xSheetDoc " );
99*cdf0e10cSrcweir         XComponent oComp = (XComponent)
100*cdf0e10cSrcweir             UnoRuntime.queryInterface(XComponent.class, xSheetDoc) ;
101*cdf0e10cSrcweir         util.DesktopTools.closeDoc(oComp);
102*cdf0e10cSrcweir     }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     /**
105*cdf0e10cSrcweir     * Creating a Testenvironment for the interfaces to be tested.
106*cdf0e10cSrcweir     * Retrieves a collection of spreadsheets from a document
107*cdf0e10cSrcweir     * and takes one of them. Fills some table in the spreadsheet.
108*cdf0e10cSrcweir     * Obtains the collection of data pilot tables using the interface
109*cdf0e10cSrcweir     * <code>XDataPilotTablesSupplier</code>. Creates a data pilot descriptor
110*cdf0e10cSrcweir     * for the filled table. Obtains the collection of all the data pilot fields
111*cdf0e10cSrcweir     * using the interface <code>XDataPilotDescriptor</code>. Sets field
112*cdf0e10cSrcweir     * orientation for every of the data pilot fields. Sets the definitions of
113*cdf0e10cSrcweir     * the filter fields for the created description. Inserts new data pilot
114*cdf0e10cSrcweir     * table with this descriptor to the collection.
115*cdf0e10cSrcweir     * This new data pilot table is the instance of the service
116*cdf0e10cSrcweir     * <code>com.sun.star.sheet.DataPilotTable</code>.
117*cdf0e10cSrcweir     * Object relations created :
118*cdf0e10cSrcweir     * <ul>
119*cdf0e10cSrcweir     *  <li> <code>'OUTPUTRANGE'</code> for
120*cdf0e10cSrcweir     *      {@link ifc.sheet._XDataPilotTable}(the cell range address of the
121*cdf0e10cSrcweir     *      created data pilot table) </li>
122*cdf0e10cSrcweir     * <li> <code>'FIELDSAMOUNT'</code> for
123*cdf0e10cSrcweir     *      {@link ifc.sheet._XDataPilotDescriptor}(the number of filled fields
124*cdf0e10cSrcweir     *      which descriptor was created for) </li>
125*cdf0e10cSrcweir     *  <li> <code>'CELLFORCHANGE'</code> for
126*cdf0e10cSrcweir     *      {@link ifc.sheet._XDataPilotTable}(value of this cell will be changed)</li>
127*cdf0e10cSrcweir     *  <li> <code>'CELLFORCHECK'</code> for
128*cdf0e10cSrcweir     *      {@link ifc.sheet._XDataPilotTable}(value of this cell must be changed
129*cdf0e10cSrcweir     *      after refresh call)</li>
130*cdf0e10cSrcweir     * </ul>
131*cdf0e10cSrcweir     * @see com.sun.star.sheet.DataPilotTable
132*cdf0e10cSrcweir     * @see com.sun.star.sheet.XDataPilotTablesSupplier
133*cdf0e10cSrcweir     * @see com.sun.star.sheet.XDataPilotDescriptor
134*cdf0e10cSrcweir     */
135*cdf0e10cSrcweir     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         XInterface oObj = null;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir         CellAddress sCellAddress = new CellAddress();
140*cdf0e10cSrcweir         sCellAddress.Sheet = 0;
141*cdf0e10cSrcweir         sCellAddress.Column = 7;
142*cdf0e10cSrcweir         sCellAddress.Row = 8;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         // creation of testobject here
145*cdf0e10cSrcweir         // first we write what we are intend to do to log file
146*cdf0e10cSrcweir         log.println( "Creating a test environment" );
147*cdf0e10cSrcweir         log.println("getting sheets");
148*cdf0e10cSrcweir         XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
149*cdf0e10cSrcweir         XIndexAccess oIndexAccess = (XIndexAccess)
150*cdf0e10cSrcweir             UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
151*cdf0e10cSrcweir         XSpreadsheet oSheet = null;
152*cdf0e10cSrcweir         Object oChangeCell = null;
153*cdf0e10cSrcweir         Object oCheckCell = null;
154*cdf0e10cSrcweir         try {
155*cdf0e10cSrcweir             oSheet = (XSpreadsheet) AnyConverter.toObject(
156*cdf0e10cSrcweir                     new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
157*cdf0e10cSrcweir             oChangeCell = oSheet.getCellByPosition(1, 5);
158*cdf0e10cSrcweir             oCheckCell = oSheet.getCellByPosition(
159*cdf0e10cSrcweir                 sCellAddress.Column, sCellAddress.Row + 3);
160*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
161*cdf0e10cSrcweir             e.printStackTrace(log);
162*cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
163*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
164*cdf0e10cSrcweir             e.printStackTrace(log);
165*cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
166*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
167*cdf0e10cSrcweir             e.printStackTrace(log);
168*cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
169*cdf0e10cSrcweir         }
170*cdf0e10cSrcweir         log.println("Getting sheet - " + (oSheet == null ? "FAILED" : "OK"));
171*cdf0e10cSrcweir         try {
172*cdf0e10cSrcweir             log.println("Filing a table");
173*cdf0e10cSrcweir             for (int i = 1; i < 6; i++) {
174*cdf0e10cSrcweir                 oSheet.getCellByPosition(0, i).setFormula("Row" + i);
175*cdf0e10cSrcweir                 oSheet.getCellByPosition(i, 0).setFormula("Col" + i);
176*cdf0e10cSrcweir             }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir             for (int i = 1; i < 6; i++)
179*cdf0e10cSrcweir                 for (int j = 1; j < 6; j++) {
180*cdf0e10cSrcweir                     oSheet.getCellByPosition(i, j).setValue(2.5 * j + i);
181*cdf0e10cSrcweir                 }
182*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
183*cdf0e10cSrcweir             e.printStackTrace(log);
184*cdf0e10cSrcweir             throw new StatusException("Couldn't fill some cells", e);
185*cdf0e10cSrcweir         }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         CellRangeAddress sCellRangeAddress = new CellRangeAddress();
188*cdf0e10cSrcweir         sCellRangeAddress.Sheet = 0;
189*cdf0e10cSrcweir         sCellRangeAddress.StartColumn = 1;
190*cdf0e10cSrcweir         sCellRangeAddress.StartRow = 0;
191*cdf0e10cSrcweir         sCellRangeAddress.EndColumn = 5;
192*cdf0e10cSrcweir         sCellRangeAddress.EndRow = 5;
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir         TableFilterField[] filterFields = new TableFilterField[2];
195*cdf0e10cSrcweir         filterFields[0] = new TableFilterField();
196*cdf0e10cSrcweir         filterFields[0].Connection = com.sun.star.sheet.FilterConnection.AND;
197*cdf0e10cSrcweir         filterFields[0].Field = 1;
198*cdf0e10cSrcweir         filterFields[0].IsNumeric = true;
199*cdf0e10cSrcweir         filterFields[0].NumericValue = 4;
200*cdf0e10cSrcweir         filterFields[0].Operator = com.sun.star.sheet.FilterOperator.GREATER;
201*cdf0e10cSrcweir         filterFields[1] = new TableFilterField();
202*cdf0e10cSrcweir         filterFields[1].Connection = com.sun.star.sheet.FilterConnection.AND;
203*cdf0e10cSrcweir         filterFields[1].Field = 1;
204*cdf0e10cSrcweir         filterFields[1].IsNumeric = true;
205*cdf0e10cSrcweir         filterFields[1].NumericValue = 12;
206*cdf0e10cSrcweir         filterFields[1].Operator = com.sun.star.sheet.FilterOperator.LESS_EQUAL;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir         XDataPilotTablesSupplier DPTS = (XDataPilotTablesSupplier)
209*cdf0e10cSrcweir             UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet);
210*cdf0e10cSrcweir         log.println("Getting test object");
211*cdf0e10cSrcweir         XDataPilotTables DPT = DPTS.getDataPilotTables();
212*cdf0e10cSrcweir         XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor();
213*cdf0e10cSrcweir         DPDsc.setSourceRange(sCellRangeAddress);
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir         XSheetFilterDescriptor SFD = DPDsc.getFilterDescriptor();
216*cdf0e10cSrcweir         SFD.setFilterFields(filterFields);
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         XPropertySet fieldPropSet = null;
219*cdf0e10cSrcweir         try {
220*cdf0e10cSrcweir             Object oDataPilotField = DPDsc.getDataPilotFields().getByIndex(0);
221*cdf0e10cSrcweir             fieldPropSet = (XPropertySet)
222*cdf0e10cSrcweir                 UnoRuntime.queryInterface(XPropertySet.class, oDataPilotField);
223*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
224*cdf0e10cSrcweir             e.printStackTrace(log);
225*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
226*cdf0e10cSrcweir         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
227*cdf0e10cSrcweir             e.printStackTrace(log);
228*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
229*cdf0e10cSrcweir         }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         try {
232*cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Function",
233*cdf0e10cSrcweir                 com.sun.star.sheet.GeneralFunction.SUM);
234*cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Orientation",
235*cdf0e10cSrcweir                 com.sun.star.sheet.DataPilotFieldOrientation.DATA);
236*cdf0e10cSrcweir         } catch(com.sun.star.lang.WrappedTargetException e) {
237*cdf0e10cSrcweir             e.printStackTrace(log);
238*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
239*cdf0e10cSrcweir         } catch(com.sun.star.lang.IllegalArgumentException e) {
240*cdf0e10cSrcweir             e.printStackTrace(log);
241*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
242*cdf0e10cSrcweir         } catch(com.sun.star.beans.PropertyVetoException e) {
243*cdf0e10cSrcweir             e.printStackTrace(log);
244*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
245*cdf0e10cSrcweir         } catch(com.sun.star.beans.UnknownPropertyException e) {
246*cdf0e10cSrcweir             e.printStackTrace(log);
247*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
248*cdf0e10cSrcweir         }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir         if (DPT.hasByName("DataPilotTable")) {
251*cdf0e10cSrcweir             DPT.removeByName("DataPilotTable");
252*cdf0e10cSrcweir         }
253*cdf0e10cSrcweir         DPT.insertNewByName("DataPilotTable", sCellAddress, DPDsc);
254*cdf0e10cSrcweir         try {
255*cdf0e10cSrcweir             oObj = (XInterface) AnyConverter.toObject(
256*cdf0e10cSrcweir                 new Type(XInterface.class),DPT.getByName(DPT.getElementNames()[0]));
257*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
258*cdf0e10cSrcweir             e.printStackTrace(log);
259*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
260*cdf0e10cSrcweir         } catch (com.sun.star.container.NoSuchElementException e) {
261*cdf0e10cSrcweir             e.printStackTrace(log);
262*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
263*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
264*cdf0e10cSrcweir             e.printStackTrace(log);
265*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
266*cdf0e10cSrcweir         }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir         log.println("Creating object - " +
269*cdf0e10cSrcweir                                     ((oObj == null) ? "FAILED" : "OK"));
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment( oObj );
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         // Other parameters required for interface tests
274*cdf0e10cSrcweir         tEnv.addObjRelation("OUTPUTRANGE", sCellAddress);
275*cdf0e10cSrcweir         tEnv.addObjRelation("CELLFORCHANGE", oChangeCell);
276*cdf0e10cSrcweir         tEnv.addObjRelation("CELLFORCHECK", oCheckCell);
277*cdf0e10cSrcweir         tEnv.addObjRelation("FIELDSAMOUNT", new Integer(5));
278*cdf0e10cSrcweir         tEnv.addObjRelation("SHEETDOCUMENT", xSheetDoc);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         createTable2(oSheet, sCellRangeAddress, tEnv);
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         return tEnv;
283*cdf0e10cSrcweir     }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir     /**
286*cdf0e10cSrcweir      * Create a new DataPilot table output for use with testing XDataPilotTable2
287*cdf0e10cSrcweir      * interface.
288*cdf0e10cSrcweir      *
289*cdf0e10cSrcweir      * @param oSheet current sheet instance
290*cdf0e10cSrcweir      * @param srcRange source range
291*cdf0e10cSrcweir      * @param tEnv test environment instance
292*cdf0e10cSrcweir      */
293*cdf0e10cSrcweir     private void createTable2(XSpreadsheet oSheet, CellRangeAddress srcRange, TestEnvironment tEnv)
294*cdf0e10cSrcweir     {
295*cdf0e10cSrcweir         XDataPilotTablesSupplier DPTS = (XDataPilotTablesSupplier)
296*cdf0e10cSrcweir             UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet);
297*cdf0e10cSrcweir         log.println("Creating test table object");
298*cdf0e10cSrcweir         XDataPilotTables DPT = DPTS.getDataPilotTables();
299*cdf0e10cSrcweir         XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor();
300*cdf0e10cSrcweir         DPDsc.setSourceRange(srcRange);
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         XIndexAccess xIA = DPDsc.getDataPilotFields();
303*cdf0e10cSrcweir         int fieldCount = xIA.getCount() - 1; // skip the last field because it's always hidden.
304*cdf0e10cSrcweir         try
305*cdf0e10cSrcweir         {
306*cdf0e10cSrcweir             for (int i = 0; i < fieldCount; ++i)
307*cdf0e10cSrcweir             {
308*cdf0e10cSrcweir                 Object o = xIA.getByIndex(i);
309*cdf0e10cSrcweir                 XPropertySet fieldPropSet = (XPropertySet)UnoRuntime.queryInterface(
310*cdf0e10cSrcweir                     XPropertySet.class, o);
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir                 if (i == fieldCount - 1)
313*cdf0e10cSrcweir                 {
314*cdf0e10cSrcweir                     // last field
315*cdf0e10cSrcweir                     fieldPropSet.setPropertyValue(
316*cdf0e10cSrcweir                         "Function", com.sun.star.sheet.GeneralFunction.SUM);
317*cdf0e10cSrcweir                     fieldPropSet.setPropertyValue(
318*cdf0e10cSrcweir                         "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA);
319*cdf0e10cSrcweir                 }
320*cdf0e10cSrcweir                 else if (i%2 == 0)
321*cdf0e10cSrcweir                 {
322*cdf0e10cSrcweir                     // even number fields
323*cdf0e10cSrcweir                     fieldPropSet.setPropertyValue(
324*cdf0e10cSrcweir                         "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.COLUMN);
325*cdf0e10cSrcweir                 }
326*cdf0e10cSrcweir                 else if (i%2 == 1)
327*cdf0e10cSrcweir                 {
328*cdf0e10cSrcweir                     // odd number fields
329*cdf0e10cSrcweir                     fieldPropSet.setPropertyValue(
330*cdf0e10cSrcweir                         "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.ROW);
331*cdf0e10cSrcweir                 }
332*cdf0e10cSrcweir             }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir             if (DPT.hasByName("DataPilotTable2"))
335*cdf0e10cSrcweir                 DPT.removeByName("DataPilotTable2");
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir             CellAddress destAddr = new CellAddress();
338*cdf0e10cSrcweir             destAddr.Sheet = 0;
339*cdf0e10cSrcweir             destAddr.Column = 0;
340*cdf0e10cSrcweir             destAddr.Row = 14;
341*cdf0e10cSrcweir             DPT.insertNewByName("DataPilotTable2", destAddr, DPDsc);
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir             Object o = DPT.getByName("DataPilotTable2");
344*cdf0e10cSrcweir             tEnv.addObjRelation("DATAPILOTTABLE2", o);
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
347*cdf0e10cSrcweir         {
348*cdf0e10cSrcweir             e.printStackTrace(log);
349*cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
350*cdf0e10cSrcweir         }
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 
356