1*15ab5183SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*15ab5183SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*15ab5183SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*15ab5183SAndrew Rist  * distributed with this work for additional information
6*15ab5183SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*15ab5183SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*15ab5183SAndrew Rist  * "License"); you may not use this file except in compliance
9*15ab5183SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*15ab5183SAndrew Rist  *
11*15ab5183SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*15ab5183SAndrew Rist  *
13*15ab5183SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*15ab5183SAndrew Rist  * software distributed under the License is distributed on an
15*15ab5183SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*15ab5183SAndrew Rist  * KIND, either express or implied.  See the License for the
17*15ab5183SAndrew Rist  * specific language governing permissions and limitations
18*15ab5183SAndrew Rist  * under the License.
19*15ab5183SAndrew Rist  *
20*15ab5183SAndrew Rist  *************************************************************/
21*15ab5183SAndrew Rist 
22*15ab5183SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package complex.dataPilot;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
27cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
28cdf0e10cSrcweir import com.sun.star.container.XNamed;
29cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
30cdf0e10cSrcweir // import com.sun.star.sheet.TableFilterField;
31cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotDescriptor;
32cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTable;
33cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTables;
34cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTablesSupplier;
35cdf0e10cSrcweir // import com.sun.star.sheet.XSheetFilterDescriptor;
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 import com.sun.star.util.XCloseable;
46cdf0e10cSrcweir import complex.dataPilot._XPropertySet;
47cdf0e10cSrcweir import complex.dataPilot._XNamed;
48cdf0e10cSrcweir import complex.dataPilot._XDataPilotDescriptor;
49cdf0e10cSrcweir import complex.dataPilot._XDataPilotTable;
50cdf0e10cSrcweir // import complexlib.ComplexTestCase;
51cdf0e10cSrcweir import lib.StatusException;
52cdf0e10cSrcweir import lib.TestParameters;
53cdf0e10cSrcweir import util.SOfficeFactory;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir import org.junit.After;
56cdf0e10cSrcweir import org.junit.AfterClass;
57cdf0e10cSrcweir import org.junit.Before;
58cdf0e10cSrcweir import org.junit.BeforeClass;
59cdf0e10cSrcweir import org.junit.Test;
60cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
61cdf0e10cSrcweir import static org.junit.Assert.*;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /**
65cdf0e10cSrcweir  * check the DataPilot of Calc.
66cdf0e10cSrcweir  */
67cdf0e10cSrcweir public class CheckDataPilot {
68cdf0e10cSrcweir     /** The data pilot field object **/
69cdf0e10cSrcweir     private XInterface mDataPilotFieldObject = null;
70cdf0e10cSrcweir     /** The data pilot table object **/
71cdf0e10cSrcweir     private XInterface mDataPilotTableObject = null;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     private XSpreadsheetDocument xSheetDoc = null;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /**
77cdf0e10cSrcweir      * A field is filled some values. This integer determines the size of the
78cdf0e10cSrcweir      * field in x and y direction.
79cdf0e10cSrcweir      */
80cdf0e10cSrcweir     private int mMaxFieldIndex = 6;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /**
83cdf0e10cSrcweir      * The test parameters
84cdf0e10cSrcweir      */
85cdf0e10cSrcweir     private static TestParameters param = null;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     /**
88cdf0e10cSrcweir      * Get all test methods
89cdf0e10cSrcweir      * @return The test methods
90cdf0e10cSrcweir      */
getTestMethodNames()91cdf0e10cSrcweir     public String[] getTestMethodNames() {
92cdf0e10cSrcweir         return new String[]{"testDataPilotTableObject",
93cdf0e10cSrcweir                             "testDataPilotFieldObject"};
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     /**
97cdf0e10cSrcweir      * Test the data pilot field object:
98cdf0e10cSrcweir      * simply execute the interface tests in a row
99cdf0e10cSrcweir      */
testDataPilotFieldObject()100cdf0e10cSrcweir     @Test public void testDataPilotFieldObject() {
101cdf0e10cSrcweir         System.out.println("Starting 'testDataPilotFieldObject'");
102cdf0e10cSrcweir         // _XNamed
103cdf0e10cSrcweir         XNamed xNamed = UnoRuntime.queryInterface(
104cdf0e10cSrcweir                                     XNamed.class, mDataPilotFieldObject);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         _XNamed _xNamed = new _XNamed(xNamed/*, log*/, param);
107cdf0e10cSrcweir         assertTrue("_getName failed.",_xNamed._getName());
108cdf0e10cSrcweir         assertTrue("_setName failed.",_xNamed._setName());
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         // _XPropertySet
111cdf0e10cSrcweir         XPropertySet xProp = UnoRuntime.queryInterface(
112cdf0e10cSrcweir                                     XPropertySet.class, mDataPilotFieldObject);
113cdf0e10cSrcweir         _XPropertySet _xProp = new _XPropertySet(xProp/*, log*/, param);
114cdf0e10cSrcweir         assertTrue("_getPropertySetInfo failed.",_xProp._getPropertySetInfo());
115cdf0e10cSrcweir         assertTrue("_addPropertyChangeListener failed.",_xProp._addPropertyChangeListener());
116cdf0e10cSrcweir         assertTrue("_addVetoableChangeListener failed.",_xProp._addVetoableChangeListener());
117cdf0e10cSrcweir         assertTrue("_setPropertyValue failed.",_xProp._setPropertyValue());
118cdf0e10cSrcweir         assertTrue("_getPropertyValue failed.",_xProp._getPropertyValue());
119cdf0e10cSrcweir         assertTrue("_removePropertyChangeListener failed.",_xProp._removePropertyChangeListener());
120cdf0e10cSrcweir         assertTrue("_removeVetoableChangeListener failed.",_xProp._removeVetoableChangeListener());
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     /**
125cdf0e10cSrcweir      * Test the data pilot table object:
126cdf0e10cSrcweir      * simply execute the interface tests in a row
127cdf0e10cSrcweir      */
testDataPilotTableObject()128cdf0e10cSrcweir     @Test public void testDataPilotTableObject() {
129cdf0e10cSrcweir         System.out.println("Starting 'testDataPilotTableObject'");
130cdf0e10cSrcweir         // _XNamed
131cdf0e10cSrcweir         XNamed xNamed = UnoRuntime.queryInterface(
132cdf0e10cSrcweir                                     XNamed.class, mDataPilotTableObject);
133cdf0e10cSrcweir         _XNamed _xNamed = new _XNamed(xNamed/*, log*/, param);
134cdf0e10cSrcweir         assertTrue("_getName failed.",_xNamed._getName());
135cdf0e10cSrcweir         assertTrue("_setName failed.",_xNamed._setName());
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         // _XDataPilotTable
138cdf0e10cSrcweir         XDataPilotTable xDataPilotTable =
139cdf0e10cSrcweir                     UnoRuntime.queryInterface(XDataPilotTable.class,
140cdf0e10cSrcweir                     mDataPilotTableObject);
141cdf0e10cSrcweir         _XDataPilotTable _xDataPilotTable =
142cdf0e10cSrcweir                     new _XDataPilotTable(xDataPilotTable/*, log*/, param);
143cdf0e10cSrcweir         assertTrue("before failed.", _xDataPilotTable.before());
144cdf0e10cSrcweir         assertTrue("_getOutputRange failed.", _xDataPilotTable._getOutputRange()) ;
145cdf0e10cSrcweir //        assertTrue("_refresh failed.", _xDataPilotTable._refresh()) ;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         // _XDataPilotDescriptor
148cdf0e10cSrcweir         XDataPilotDescriptor xDataPilotDescriptor =
149cdf0e10cSrcweir                     UnoRuntime.queryInterface(XDataPilotDescriptor.class,
150cdf0e10cSrcweir                     mDataPilotTableObject);
151cdf0e10cSrcweir         _XDataPilotDescriptor _xDataPilotDescriptor =
152cdf0e10cSrcweir                     new _XDataPilotDescriptor(xDataPilotDescriptor/*, log*/, param);
153cdf0e10cSrcweir         assertTrue("before failed.", _xDataPilotDescriptor.before());
154cdf0e10cSrcweir         assertTrue("_setTag failed.", _xDataPilotDescriptor._setTag()) ;
155cdf0e10cSrcweir         assertTrue("_getTag failed.", _xDataPilotDescriptor._getTag()) ;
156cdf0e10cSrcweir         assertTrue("_getFilterDescriptor failed.", _xDataPilotDescriptor._getFilterDescriptor()) ;
157cdf0e10cSrcweir         assertTrue("_getDataPilotFields failed.", _xDataPilotDescriptor._getDataPilotFields()) ;
158cdf0e10cSrcweir         assertTrue("_getColumnFields failed.", _xDataPilotDescriptor._getColumnFields()) ;
159cdf0e10cSrcweir         assertTrue("_getRowFields failed.", _xDataPilotDescriptor._getRowFields()) ;
160cdf0e10cSrcweir         assertTrue("_getDataFields failed.", _xDataPilotDescriptor._getDataFields()) ;
161cdf0e10cSrcweir         assertTrue("_getHiddenFields failed.", _xDataPilotDescriptor._getHiddenFields()) ;
162cdf0e10cSrcweir         assertTrue("_getPageFields failed.", _xDataPilotDescriptor._getPageFields()) ;
163cdf0e10cSrcweir         assertTrue("_setSourceRange failed.", _xDataPilotDescriptor._setSourceRange()) ;
164cdf0e10cSrcweir         assertTrue("_getSourceRange failed.", _xDataPilotDescriptor._getSourceRange()) ;
165cdf0e10cSrcweir     }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     /**
168cdf0e10cSrcweir      * create an environment for the test
169cdf0e10cSrcweir      */
before()170cdf0e10cSrcweir     @Before public void before() {
171cdf0e10cSrcweir //        Object oInterface = null;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         // SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)param.getMSF() );
174cdf0e10cSrcweir         final XMultiServiceFactory xMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
175cdf0e10cSrcweir         SOfficeFactory SOF = SOfficeFactory.getFactory(xMsf);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir         param = new TestParameters();
178cdf0e10cSrcweir         param.put("ServiceFactory", xMsf);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir         // the cell range
181cdf0e10cSrcweir         CellRangeAddress sCellRangeAdress = new CellRangeAddress();
182cdf0e10cSrcweir         sCellRangeAdress.Sheet = 0;
183cdf0e10cSrcweir         sCellRangeAdress.StartColumn = 1;
184cdf0e10cSrcweir         sCellRangeAdress.StartRow = 0;
185cdf0e10cSrcweir         sCellRangeAdress.EndColumn = mMaxFieldIndex-1;
186cdf0e10cSrcweir         sCellRangeAdress.EndRow = mMaxFieldIndex - 1;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         // position of the data pilot table
189cdf0e10cSrcweir         CellAddress sCellAdress = new CellAddress();
190cdf0e10cSrcweir         sCellAdress.Sheet = 0;
191cdf0e10cSrcweir         sCellAdress.Column = 7;
192cdf0e10cSrcweir         sCellAdress.Row = 8;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         try {
195cdf0e10cSrcweir             System.out.println( "Creating a Spreadsheet document" );
196cdf0e10cSrcweir             xSheetDoc = SOF.createCalcDoc(null);
197cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
198cdf0e10cSrcweir             // Some exception occures.FAILED
199cdf0e10cSrcweir             e.printStackTrace();
200cdf0e10cSrcweir             throw new StatusException( "Couldn't create document", e );
201cdf0e10cSrcweir         }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir         System.out.println("Getting a sheet");
204cdf0e10cSrcweir         XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
205cdf0e10cSrcweir         XSpreadsheet oSheet = null;
206cdf0e10cSrcweir         XSpreadsheet oSheet2 = null;
207cdf0e10cSrcweir         XIndexAccess oIndexAccess =
208cdf0e10cSrcweir             UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         try {
211cdf0e10cSrcweir             oSheet = (XSpreadsheet) AnyConverter.toObject(
212cdf0e10cSrcweir                     new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
213cdf0e10cSrcweir             oSheet2 = (XSpreadsheet) AnyConverter.toObject(
214cdf0e10cSrcweir                     new Type(XSpreadsheet.class),oIndexAccess.getByIndex(1));
215cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
216cdf0e10cSrcweir             e.printStackTrace();
217cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
218cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
219cdf0e10cSrcweir             e.printStackTrace();
220cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
221cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
222cdf0e10cSrcweir             e.printStackTrace();
223cdf0e10cSrcweir             throw new StatusException( "Couldn't get a spreadsheet", e);
224cdf0e10cSrcweir         }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         try {
227cdf0e10cSrcweir             System.out.println("Filling a table");
228cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++) {
229cdf0e10cSrcweir                 oSheet.getCellByPosition(i, 0).setFormula("Col" + i);
230cdf0e10cSrcweir                 oSheet.getCellByPosition(0, i).setFormula("Row" + i);
231cdf0e10cSrcweir                 oSheet2.getCellByPosition(i, 0).setFormula("Col" + i);
232cdf0e10cSrcweir                 oSheet2.getCellByPosition(0, i).setFormula("Row" + i);
233cdf0e10cSrcweir             }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir             for (int i = 1; i < mMaxFieldIndex; i++)
236cdf0e10cSrcweir             {
237cdf0e10cSrcweir                 for (int j = 1; j < mMaxFieldIndex; j++)
238cdf0e10cSrcweir                 {
239cdf0e10cSrcweir                     oSheet.getCellByPosition(i, j).setValue(i * (j + 1));
240cdf0e10cSrcweir                     oSheet2.getCellByPosition(i, j).setValue(i * (j + 2));
241cdf0e10cSrcweir                 }
242cdf0e10cSrcweir             }
243cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
244cdf0e10cSrcweir             e.printStackTrace();
245cdf0e10cSrcweir             throw new StatusException("Couldn't fill some cells", e);
246cdf0e10cSrcweir         }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir         // change a value of a cell and check the change in the data pilot
249cdf0e10cSrcweir         // (for the XDataPilotTable.refresh() test)
250cdf0e10cSrcweir         Object oChangeCell = null;
251cdf0e10cSrcweir         Object oCheckCell = null;
252cdf0e10cSrcweir         Integer aChangeValue = null;
253cdf0e10cSrcweir         try {
254cdf0e10cSrcweir             // cell of data
255cdf0e10cSrcweir             oChangeCell = oSheet.getCellByPosition(1, 5);
256cdf0e10cSrcweir             int x = sCellAdress.Column;
257cdf0e10cSrcweir             int y = sCellAdress.Row + 3;
258cdf0e10cSrcweir             // cell of the data pilot output
259cdf0e10cSrcweir             oCheckCell = oSheet.getCellByPosition(x, y);
260cdf0e10cSrcweir             aChangeValue = new Integer(27);
261cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
262cdf0e10cSrcweir             e.printStackTrace();
263cdf0e10cSrcweir             throw new StatusException( "Couldn't get cells for changeing.", e);
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 
267cdf0e10cSrcweir         // create the test objects
268cdf0e10cSrcweir         System.out.println("Getting test objects") ;
269cdf0e10cSrcweir         XDataPilotTablesSupplier DPTS =
270cdf0e10cSrcweir             UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet);
271cdf0e10cSrcweir         XDataPilotTables DPT = DPTS.getDataPilotTables();
272cdf0e10cSrcweir         XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor();
273cdf0e10cSrcweir         DPDsc.setSourceRange(sCellRangeAdress);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         XPropertySet fieldPropSet = null;
276cdf0e10cSrcweir         try {
277cdf0e10cSrcweir             Object oDataPilotField = DPDsc.getDataPilotFields().getByIndex(0);
278cdf0e10cSrcweir             fieldPropSet =
279cdf0e10cSrcweir                 UnoRuntime.queryInterface(XPropertySet.class, oDataPilotField);
280cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
281cdf0e10cSrcweir             e.printStackTrace();
282cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
283cdf0e10cSrcweir         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
284cdf0e10cSrcweir             e.printStackTrace();
285cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir         try {
289cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Function",
290cdf0e10cSrcweir                 com.sun.star.sheet.GeneralFunction.SUM);
291cdf0e10cSrcweir             fieldPropSet.setPropertyValue("Orientation",
292cdf0e10cSrcweir                 com.sun.star.sheet.DataPilotFieldOrientation.DATA);
293cdf0e10cSrcweir         } catch(com.sun.star.lang.WrappedTargetException e) {
294cdf0e10cSrcweir             e.printStackTrace();
295cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
296cdf0e10cSrcweir         } catch(com.sun.star.lang.IllegalArgumentException e) {
297cdf0e10cSrcweir             e.printStackTrace();
298cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
299cdf0e10cSrcweir         } catch(com.sun.star.beans.PropertyVetoException e) {
300cdf0e10cSrcweir             e.printStackTrace();
301cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
302cdf0e10cSrcweir         } catch(com.sun.star.beans.UnknownPropertyException e) {
303cdf0e10cSrcweir             e.printStackTrace();
304cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
305cdf0e10cSrcweir         }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         System.out.println("Insert the DataPilotTable");
308cdf0e10cSrcweir         if (DPT.hasByName("DataPilotTable")) {
309cdf0e10cSrcweir             DPT.removeByName("DataPilotTable");
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir         DPT.insertNewByName("DataPilotTable", sCellAdress, DPDsc);
312cdf0e10cSrcweir         try {
313cdf0e10cSrcweir             mDataPilotTableObject = (XInterface) AnyConverter.toObject(
314cdf0e10cSrcweir                 new Type(XInterface.class),DPT.getByName(DPT.getElementNames()[0]));
315cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
316cdf0e10cSrcweir             e.printStackTrace();
317cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
318cdf0e10cSrcweir         } catch (com.sun.star.container.NoSuchElementException e) {
319cdf0e10cSrcweir             e.printStackTrace();
320cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
321cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
322cdf0e10cSrcweir             e.printStackTrace();
323cdf0e10cSrcweir             throw new StatusException("Couldn't create a test environment", e);
324cdf0e10cSrcweir         }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir         XIndexAccess IA = DPDsc.getDataPilotFields();
327cdf0e10cSrcweir         try {
328cdf0e10cSrcweir             mDataPilotFieldObject = (XInterface)AnyConverter.toObject(
329cdf0e10cSrcweir                                 new Type(XInterface.class),IA.getByIndex(0));
330cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
331cdf0e10cSrcweir             e.printStackTrace();
332cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
333cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
334cdf0e10cSrcweir             e.printStackTrace();
335cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
336cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
337cdf0e10cSrcweir             e.printStackTrace();
338cdf0e10cSrcweir             throw new StatusException("Couldn't get data pilot field", e);
339cdf0e10cSrcweir         }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir         // Other parameters required for interface tests
342cdf0e10cSrcweir         param.put("OUTPUTRANGE", sCellAdress);
343cdf0e10cSrcweir         param.put("CELLFORCHANGE", oChangeCell);
344cdf0e10cSrcweir         param.put("CELLFORCHECK", oCheckCell);
345cdf0e10cSrcweir         param.put("CHANGEVALUE", aChangeValue);
346cdf0e10cSrcweir         param.put("FIELDSAMOUNT", new Integer(5));
347cdf0e10cSrcweir 
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir         /*
351cdf0e10cSrcweir      * this method closes a calc document and resets the corresponding class variable xSheetDoc
352cdf0e10cSrcweir      */
closeSpreadsheetDocument()353cdf0e10cSrcweir     protected boolean closeSpreadsheetDocument() {
354cdf0e10cSrcweir         boolean worked = true;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         System.out.println("    disposing xSheetDoc ");
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         try {
359cdf0e10cSrcweir             XCloseable oCloser =  UnoRuntime.queryInterface(
360cdf0e10cSrcweir                                          XCloseable.class, xSheetDoc);
361cdf0e10cSrcweir             oCloser.close(true);
362cdf0e10cSrcweir         } catch (com.sun.star.util.CloseVetoException e) {
363cdf0e10cSrcweir             worked = false;
364cdf0e10cSrcweir             System.out.println("Couldn't close document");
365cdf0e10cSrcweir         } catch (com.sun.star.lang.DisposedException e) {
366cdf0e10cSrcweir             worked = false;
367cdf0e10cSrcweir             System.out.println("Document already disposed");
368cdf0e10cSrcweir         } catch (java.lang.NullPointerException e) {
369cdf0e10cSrcweir             worked = false;
370cdf0e10cSrcweir             System.out.println("Couldn't get XCloseable");
371cdf0e10cSrcweir         }
372cdf0e10cSrcweir 
373cdf0e10cSrcweir         xSheetDoc = null;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir         return worked;
376cdf0e10cSrcweir     }
377cdf0e10cSrcweir 
after()378cdf0e10cSrcweir     @After public void after()
379cdf0e10cSrcweir         {
380cdf0e10cSrcweir             closeSpreadsheetDocument();
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
setUpConnection()384cdf0e10cSrcweir     @BeforeClass public static void setUpConnection() throws Exception {
385cdf0e10cSrcweir         System.out.println("setUpConnection()");
386cdf0e10cSrcweir         connection.setUp();
387cdf0e10cSrcweir     }
388cdf0e10cSrcweir 
tearDownConnection()389cdf0e10cSrcweir     @AfterClass public static void tearDownConnection()
390cdf0e10cSrcweir         throws InterruptedException, com.sun.star.uno.Exception
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         System.out.println("tearDownConnection()");
393cdf0e10cSrcweir         connection.tearDown();
394cdf0e10cSrcweir     }
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 
399cdf0e10cSrcweir }
400