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