1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir package mod._sc;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
26cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
27cdf0e10cSrcweir import com.sun.star.container.XNamed;
28cdf0e10cSrcweir import com.sun.star.lang.XComponent;
29cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
30cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldOrientation;
31cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotDescriptor;
32cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotField;
33cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTables;
34cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTablesSupplier;
35cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheet;
36cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheetDocument;
37cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheets;
38cdf0e10cSrcweir import com.sun.star.table.CellAddress;
39cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress;
40cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
41cdf0e10cSrcweir import com.sun.star.uno.Type;
42cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
43cdf0e10cSrcweir import com.sun.star.uno.XInterface;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir import java.io.PrintWriter;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir import lib.StatusException;
48cdf0e10cSrcweir import lib.TestCase;
49cdf0e10cSrcweir import lib.TestEnvironment;
50cdf0e10cSrcweir import lib.TestParameters;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir import util.SOfficeFactory;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /**
56cdf0e10cSrcweir * Test for object which is represented by service
57cdf0e10cSrcweir * <code>com.sun.star.sheet.DataPilotField</code>. <p>
58cdf0e10cSrcweir * Object implements the following interfaces :
59cdf0e10cSrcweir * <ul>
60cdf0e10cSrcweir *  <li> <code>com::sun::star::container::XNamed</code></li>
61cdf0e10cSrcweir *  <li> <code>com::sun::star::sheet::DataPilotField</code></li>
62cdf0e10cSrcweir *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
63cdf0e10cSrcweir * </ul>
64cdf0e10cSrcweir * @see com.sun.star.sheet.DataPilotField
65cdf0e10cSrcweir * @see com.sun.star.container.XNamed
66cdf0e10cSrcweir * @see com.sun.star.sheet.DataPilotField
67cdf0e10cSrcweir * @see com.sun.star.beans.XPropertySet
68cdf0e10cSrcweir * @see ifc.container._XNamed
69cdf0e10cSrcweir * @see ifc.sheet._DataPilotField
70cdf0e10cSrcweir * @see ifc.beans._XPropertySet
71cdf0e10cSrcweir */
72cdf0e10cSrcweir public class ScDataPilotItemObj extends TestCase {
73cdf0e10cSrcweir     static XSpreadsheetDocument xSheetDoc = null;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     /**
76cdf0e10cSrcweir      * A field is filled some values. This integer determines the size of the
77cdf0e10cSrcweir      * field in x and y direction.
78cdf0e10cSrcweir      */
79cdf0e10cSrcweir     private int mMaxFieldIndex = 6;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     /**
82cdf0e10cSrcweir     * Creates Spreadsheet document.
83cdf0e10cSrcweir     */
initialize(TestParameters tParam, PrintWriter log)84cdf0e10cSrcweir     protected void initialize(TestParameters tParam, PrintWriter log) {
85cdf0e10cSrcweir         SOfficeFactory SOF = SOfficeFactory.getFactory(
86cdf0e10cSrcweir                                      (XMultiServiceFactory) tParam.getMSF());
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         try {
89cdf0e10cSrcweir             log.println("creating a Spreadsheet document");
90cdf0e10cSrcweir             xSheetDoc = SOF.createCalcDoc(null);
91cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
92cdf0e10cSrcweir             // Some exception occures.FAILED
93cdf0e10cSrcweir             e.printStackTrace(log);
94cdf0e10cSrcweir             throw new StatusException("Couldn't create document", e);
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     /**
99cdf0e10cSrcweir     * Disposes Spreadsheet document.
100cdf0e10cSrcweir     */
cleanup(TestParameters tParam, PrintWriter log)101cdf0e10cSrcweir     protected void cleanup(TestParameters tParam, PrintWriter log) {
102cdf0e10cSrcweir         log.println("    disposing xSheetDoc ");
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         XComponent oComp = (XComponent) UnoRuntime.queryInterface(
105cdf0e10cSrcweir                                    XComponent.class, xSheetDoc);
106cdf0e10cSrcweir         util.DesktopTools.closeDoc(oComp);
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /**
110cdf0e10cSrcweir     * Creating a Testenvironment for the interfaces to be tested.
111cdf0e10cSrcweir     * Retrieves a collection of spreadsheets from a document
112cdf0e10cSrcweir     * and takes one of them. Fills some table in the spreadsheet.
113cdf0e10cSrcweir     * Obtains the collection of data pilot tables using the interface
114cdf0e10cSrcweir     * <code>XDataPilotTablesSupplier</code>. Creates a data pilot descriptor
115cdf0e10cSrcweir     * for the filled table and inserts new data pilot table with this descriptor
116cdf0e10cSrcweir     * to the collection. Obtains the collection of all the data pilot fields
117cdf0e10cSrcweir     * using the interface <code>XDataPilotDescriptor</code>. Retrieves from
118cdf0e10cSrcweir     * the collection the data pilot field with index 0. This data pilot field
119cdf0e10cSrcweir     * is the instance of the service <code>com.sun.star.sheet.DataPilotField</code>.
120cdf0e10cSrcweir     * @see com.sun.star.sheet.DataPilotField
121cdf0e10cSrcweir     * @see com.sun.star.sheet.XDataPilotTablesSupplier
122cdf0e10cSrcweir     * @see com.sun.star.sheet.XDataPilotDescriptor
123cdf0e10cSrcweir     */
createTestEnvironment(TestParameters Param, PrintWriter log)124cdf0e10cSrcweir     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
125cdf0e10cSrcweir                                                                  PrintWriter log) {
126cdf0e10cSrcweir         XInterface oObj = null;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         // creation of testobject here
130cdf0e10cSrcweir         // first we write what we are intend to do to log file
131cdf0e10cSrcweir         log.println("Creating a test environment");
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         // the cell range
134cdf0e10cSrcweir         CellRangeAddress sCellRangeAdress = new CellRangeAddress();
135cdf0e10cSrcweir         sCellRangeAdress.Sheet = 0;
136cdf0e10cSrcweir         sCellRangeAdress.StartColumn = 1;
137cdf0e10cSrcweir         sCellRangeAdress.StartRow = 0;
138cdf0e10cSrcweir         sCellRangeAdress.EndColumn = mMaxFieldIndex - 1;
139cdf0e10cSrcweir         sCellRangeAdress.EndRow = mMaxFieldIndex - 1;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         // position of the data pilot table
142cdf0e10cSrcweir         CellAddress sCellAdress = new CellAddress();
143cdf0e10cSrcweir         sCellAdress.Sheet = 0;
144cdf0e10cSrcweir         sCellAdress.Column = 7;
145cdf0e10cSrcweir         sCellAdress.Row = 8;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         log.println("Getting a sheet");
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         XSpreadsheets xSpreadsheets = (XSpreadsheets) xSheetDoc.getSheets();
150cdf0e10cSrcweir         XSpreadsheet oSheet = null;
151cdf0e10cSrcweir         XSpreadsheet oSheet2 = null;
152cdf0e10cSrcweir         XIndexAccess oIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
153cdf0e10cSrcweir                                             XIndexAccess.class, xSpreadsheets);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         try {
156cdf0e10cSrcweir             oSheet = (XSpreadsheet) AnyConverter.toObject(
157cdf0e10cSrcweir                              new Type(XSpreadsheet.class),
158cdf0e10cSrcweir                              oIndexAccess.getByIndex(0));
159cdf0e10cSrcweir             oSheet2 = (XSpreadsheet) AnyConverter.toObject(
160cdf0e10cSrcweir                               new Type(XSpreadsheet.class),
161cdf0e10cSrcweir                               oIndexAccess.getByIndex(1));
162cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
163cdf0e10cSrcweir             e.printStackTrace();
164cdf0e10cSrcweir             throw new StatusException("Couldn't get a spreadsheet", e);
165cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
166cdf0e10cSrcweir             e.printStackTrace();
167cdf0e10cSrcweir             throw new StatusException("Couldn't get a spreadsheet", e);
168cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
169cdf0e10cSrcweir             e.printStackTrace();
170cdf0e10cSrcweir             throw new StatusException("Couldn't get a spreadsheet", e);
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         try {
174cdf0e10cSrcweir             log.println("Filling a table");
175cdf0e10cSrcweir 
176cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++) {
177cdf0e10cSrcweir                 oSheet.getCellByPosition(i, 0).setFormula("Col" + i);
178cdf0e10cSrcweir                 oSheet.getCellByPosition(0, i).setFormula("Row" + i);
179cdf0e10cSrcweir                 oSheet2.getCellByPosition(i, 0).setFormula("Col" + i);
180cdf0e10cSrcweir                 oSheet2.getCellByPosition(0, i).setFormula("Row" + i);
181cdf0e10cSrcweir             }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++)
184cdf0e10cSrcweir                 for (int j = 1; j < mMaxFieldIndex; j++) {
185cdf0e10cSrcweir                     oSheet.getCellByPosition(i, j).setValue(i * (j + 1));
186cdf0e10cSrcweir                     oSheet2.getCellByPosition(i, j).setValue(i * (j + 2));
187cdf0e10cSrcweir                 }
188cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
189cdf0e10cSrcweir             e.printStackTrace();
190cdf0e10cSrcweir             throw new StatusException("Couldn't fill some cells", e);
191cdf0e10cSrcweir         }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir         // change a value of a cell and check the change in the data pilot
194cdf0e10cSrcweir         // (for the XDataPilotTable.refresh() test)
195cdf0e10cSrcweir         Object oChangeCell = null;
196cdf0e10cSrcweir         Object oCheckCell = null;
197cdf0e10cSrcweir         Integer aChangeValue = null;
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         try {
200cdf0e10cSrcweir             // cell of data
201cdf0e10cSrcweir             oChangeCell = oSheet.getCellByPosition(1, 5);
202cdf0e10cSrcweir 
203cdf0e10cSrcweir             int x = sCellAdress.Column;
204cdf0e10cSrcweir             int y = sCellAdress.Row + 3;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             // cell of the data pilot output
208cdf0e10cSrcweir             oCheckCell = oSheet.getCellByPosition(x, y);
209cdf0e10cSrcweir             aChangeValue = new Integer(27);
210cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
211cdf0e10cSrcweir             e.printStackTrace();
212cdf0e10cSrcweir             throw new StatusException("Couldn't get cells for changeing.", e);
213cdf0e10cSrcweir         }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 
216cdf0e10cSrcweir         // create the test objects
217cdf0e10cSrcweir         log.println("Getting test objects");
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         XDataPilotTablesSupplier DPTS = (XDataPilotTablesSupplier) UnoRuntime.queryInterface(
220cdf0e10cSrcweir                                                 XDataPilotTablesSupplier.class,
221cdf0e10cSrcweir                                                 oSheet);
222cdf0e10cSrcweir         XDataPilotTables DPT = DPTS.getDataPilotTables();
223cdf0e10cSrcweir         XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor();
224cdf0e10cSrcweir         DPDsc.setSourceRange(sCellRangeAdress);
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         XPropertySet fieldPropSet = null;
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         try {
229cdf0e10cSrcweir             Object oDataPilotField = DPDsc.getDataPilotFields().getByIndex(0);
230cdf0e10cSrcweir             fieldPropSet = (XPropertySet) UnoRuntime.queryInterface(
231cdf0e10cSrcweir                                    XPropertySet.class, oDataPilotField);
232cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
233cdf0e10cSrcweir             e.printStackTrace();
234cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
235cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
236cdf0e10cSrcweir             e.printStackTrace();
237cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         try {
241cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Function",
242cdf0e10cSrcweir                                           com.sun.star.sheet.GeneralFunction.SUM);
243cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Orientation",
244cdf0e10cSrcweir                                           com.sun.star.sheet.DataPilotFieldOrientation.DATA);
245cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
246cdf0e10cSrcweir             e.printStackTrace();
247cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
248cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
249cdf0e10cSrcweir             e.printStackTrace();
250cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
251cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e) {
252cdf0e10cSrcweir             e.printStackTrace();
253cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
254cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException e) {
255cdf0e10cSrcweir             e.printStackTrace();
256cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         log.println("Insert the DataPilotTable");
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         if (DPT.hasByName("DataPilotTable")) {
262cdf0e10cSrcweir             DPT.removeByName("DataPilotTable");
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         XIndexAccess IA = DPDsc.getDataPilotFields();
266cdf0e10cSrcweir         getSRange(IA);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         DPT.insertNewByName("DataPilotTable", sCellAdress, DPDsc);
269cdf0e10cSrcweir 
270cdf0e10cSrcweir         try {
271cdf0e10cSrcweir             oObj = (XInterface) AnyConverter.toObject(
272cdf0e10cSrcweir                            new Type(XInterface.class), IA.getByIndex(0));
273cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
274cdf0e10cSrcweir             e.printStackTrace();
275cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
276cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
277cdf0e10cSrcweir             e.printStackTrace();
278cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
279cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
280cdf0e10cSrcweir             e.printStackTrace();
281cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         log.println("Creating object - " +
285cdf0e10cSrcweir                     ((oObj == null) ? "FAILED" : "OK"));
286cdf0e10cSrcweir 
287cdf0e10cSrcweir         XDataPilotField xDataPilotField = (XDataPilotField) UnoRuntime.queryInterface(
288cdf0e10cSrcweir                                                   XDataPilotField.class, oObj);
289cdf0e10cSrcweir 
290cdf0e10cSrcweir         XIndexAccess xIA = xDataPilotField.getItems();
291cdf0e10cSrcweir 
292cdf0e10cSrcweir         try {
293cdf0e10cSrcweir             oObj = (XInterface) UnoRuntime.queryInterface(XInterface.class,
294cdf0e10cSrcweir                                                           xIA.getByIndex(0));
295cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
296cdf0e10cSrcweir             log.println("Couldn't get DataPilotItemObj");
297cdf0e10cSrcweir             e.printStackTrace(log);
298cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
299cdf0e10cSrcweir             log.println("Couldn't get DataPilotItemObj");
300cdf0e10cSrcweir             e.printStackTrace(log);
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment(oObj);
304cdf0e10cSrcweir 
305cdf0e10cSrcweir         log.println("Implementationname: " + util.utils.getImplName(oObj));
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         // Other parameters required for interface tests
308cdf0e10cSrcweir         tEnv.addObjRelation("NoSetName",  "ScDataPilotItemObj");
309cdf0e10cSrcweir         return tEnv;
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir 
getSRange(XIndexAccess IA)312cdf0e10cSrcweir     private void getSRange(XIndexAccess IA) {
313cdf0e10cSrcweir         int fieldsAmount = IA.getCount() + 1;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         String[] fieldsNames = new String[fieldsAmount];
316cdf0e10cSrcweir 
317cdf0e10cSrcweir         int i = -1;
318cdf0e10cSrcweir         int cnt = 0;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         while ((++i) < fieldsAmount) {
321cdf0e10cSrcweir             Object field;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir             try {
324cdf0e10cSrcweir                 field = IA.getByIndex(i);
325cdf0e10cSrcweir             } catch (com.sun.star.lang.WrappedTargetException e) {
326cdf0e10cSrcweir                 e.printStackTrace(log);
327cdf0e10cSrcweir 
328cdf0e10cSrcweir                 return;
329cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
330cdf0e10cSrcweir                 e.printStackTrace(log);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir                 return;
333cdf0e10cSrcweir             }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir             XNamed named = (XNamed) UnoRuntime.queryInterface(XNamed.class,
336cdf0e10cSrcweir                                                               field);
337cdf0e10cSrcweir             String name = named.getName();
338cdf0e10cSrcweir 
339cdf0e10cSrcweir             log.println("**Field : '" + name + "' ... ");
340cdf0e10cSrcweir 
341cdf0e10cSrcweir             if (!name.equals("Data")) {
342cdf0e10cSrcweir                 fieldsNames[cnt] = name;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir                 XPropertySet props = (XPropertySet) UnoRuntime.queryInterface(
345cdf0e10cSrcweir                                              XPropertySet.class, field);
346cdf0e10cSrcweir 
347cdf0e10cSrcweir                 try {
348cdf0e10cSrcweir                     switch (cnt % 5) {
349cdf0e10cSrcweir                     case 0:
350cdf0e10cSrcweir                         props.setPropertyValue("Orientation",
351cdf0e10cSrcweir                                                DataPilotFieldOrientation.COLUMN);
352cdf0e10cSrcweir                         log.println("  Column");
353cdf0e10cSrcweir 
354cdf0e10cSrcweir                         break;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir                     case 1:
357cdf0e10cSrcweir                         props.setPropertyValue("Orientation",
358cdf0e10cSrcweir                                                DataPilotFieldOrientation.ROW);
359cdf0e10cSrcweir                         log.println("  Row");
360cdf0e10cSrcweir 
361cdf0e10cSrcweir                         break;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir                     case 2:
364cdf0e10cSrcweir                         props.setPropertyValue("Orientation",
365cdf0e10cSrcweir                                                DataPilotFieldOrientation.DATA);
366cdf0e10cSrcweir                         log.println("  Data");
367cdf0e10cSrcweir 
368cdf0e10cSrcweir                         break;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir                     case 3:
371cdf0e10cSrcweir                         props.setPropertyValue("Orientation",
372cdf0e10cSrcweir                                                DataPilotFieldOrientation.HIDDEN);
373cdf0e10cSrcweir                         log.println("  Hidden");
374cdf0e10cSrcweir 
375cdf0e10cSrcweir                         break;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir                     case 4:
378cdf0e10cSrcweir                         props.setPropertyValue("Orientation",
379cdf0e10cSrcweir                                                DataPilotFieldOrientation.PAGE);
380cdf0e10cSrcweir                         log.println("  Page");
381cdf0e10cSrcweir 
382cdf0e10cSrcweir                         break;
383cdf0e10cSrcweir                     }
384cdf0e10cSrcweir                 } catch (com.sun.star.lang.WrappedTargetException e) {
385cdf0e10cSrcweir                     e.printStackTrace(log);
386cdf0e10cSrcweir 
387cdf0e10cSrcweir                     return;
388cdf0e10cSrcweir                 } catch (com.sun.star.lang.IllegalArgumentException e) {
389cdf0e10cSrcweir                     e.printStackTrace(log);
390cdf0e10cSrcweir 
391cdf0e10cSrcweir                     return;
392cdf0e10cSrcweir                 } catch (com.sun.star.beans.PropertyVetoException e) {
393cdf0e10cSrcweir                     e.printStackTrace(log);
394cdf0e10cSrcweir 
395cdf0e10cSrcweir                     return;
396cdf0e10cSrcweir                 } catch (com.sun.star.beans.UnknownPropertyException e) {
397cdf0e10cSrcweir                     e.printStackTrace(log);
398cdf0e10cSrcweir 
399cdf0e10cSrcweir                     return;
400cdf0e10cSrcweir                 }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir                 if ((++cnt) > 4) {
403cdf0e10cSrcweir                     break;
404cdf0e10cSrcweir                 }
405cdf0e10cSrcweir             } else {
406cdf0e10cSrcweir                 return;
407cdf0e10cSrcweir             }
408cdf0e10cSrcweir         }
409cdf0e10cSrcweir     }
410cdf0e10cSrcweir }
411