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