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