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 package mod._dbaccess; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir import java.io.PrintWriter; 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir import lib.Status; 32*cdf0e10cSrcweir import lib.StatusException; 33*cdf0e10cSrcweir import lib.TestCase; 34*cdf0e10cSrcweir import lib.TestEnvironment; 35*cdf0e10cSrcweir import lib.TestParameters; 36*cdf0e10cSrcweir import util.AccessibilityTools; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole; 39*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 40*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent; 41*cdf0e10cSrcweir import com.sun.star.awt.Point; 42*cdf0e10cSrcweir import com.sun.star.awt.XWindow; 43*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue; 44*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 45*cdf0e10cSrcweir import com.sun.star.container.XNameAccess; 46*cdf0e10cSrcweir import com.sun.star.container.XNameContainer; 47*cdf0e10cSrcweir import com.sun.star.frame.XModel; 48*cdf0e10cSrcweir import com.sun.star.frame.XStorable; 49*cdf0e10cSrcweir import com.sun.star.lang.XComponent; 50*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 51*cdf0e10cSrcweir import com.sun.star.sdb.XDocumentDataSource; 52*cdf0e10cSrcweir import com.sun.star.sdb.XQueryDefinitionsSupplier; 53*cdf0e10cSrcweir import com.sun.star.sdbc.XConnection; 54*cdf0e10cSrcweir import com.sun.star.sdbc.XIsolatedConnection; 55*cdf0e10cSrcweir import com.sun.star.sdbc.XStatement; 56*cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess; 57*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 58*cdf0e10cSrcweir import com.sun.star.uno.XInterface; 59*cdf0e10cSrcweir import java.awt.Robot; 60*cdf0e10cSrcweir import java.awt.event.InputEvent; 61*cdf0e10cSrcweir import util.DesktopTools; 62*cdf0e10cSrcweir import util.utils; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir /** 66*cdf0e10cSrcweir * Object implements the following interfaces : 67*cdf0e10cSrcweir * <ul> 68*cdf0e10cSrcweir * <li><code>::com::sun::star::accessibility::XAccessible</code></li> 69*cdf0e10cSrcweir * <li><code>::com::sun::star::accessibility::XAccessibleContext 70*cdf0e10cSrcweir * </code></li> 71*cdf0e10cSrcweir * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster 72*cdf0e10cSrcweir * </code></li> 73*cdf0e10cSrcweir * </ul><p> 74*cdf0e10cSrcweir * @see com.sun.star.accessibility.XAccessible 75*cdf0e10cSrcweir * @see com.sun.star.accessibility.XAccessibleContext 76*cdf0e10cSrcweir * @see com.sun.star.accessibility.XAccessibleEventBroadcaster 77*cdf0e10cSrcweir * @see ifc.accessibility._XAccessible 78*cdf0e10cSrcweir * @see ifc.accessibility._XAccessibleContext 79*cdf0e10cSrcweir * @see ifc.accessibility._XAccessibleEventBroadcaster 80*cdf0e10cSrcweir */ 81*cdf0e10cSrcweir public class TableWindowAccessibility extends TestCase { 82*cdf0e10cSrcweir XWindow xWindow = null; 83*cdf0e10cSrcweir Object oDBSource = null; 84*cdf0e10cSrcweir String aFile = ""; 85*cdf0e10cSrcweir XConnection connection = null; 86*cdf0e10cSrcweir XIsolatedConnection isolConnection = null; 87*cdf0e10cSrcweir XComponent QueryComponent = null; 88*cdf0e10cSrcweir String user = ""; 89*cdf0e10cSrcweir String password=""; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /** 92*cdf0e10cSrcweir * Creates a new DataSource and stores it. 93*cdf0e10cSrcweir * Creates a connection and using it 94*cdf0e10cSrcweir * creates two tables in database. 95*cdf0e10cSrcweir * Creates a new query and adds it to DefinitionContainer. 96*cdf0e10cSrcweir * Opens the QueryComponent.with loadComponentFromURL 97*cdf0e10cSrcweir * and gets the object with the role PANEL and the implementation 98*cdf0e10cSrcweir * name that contains TabelViewAccessibility 99*cdf0e10cSrcweir * @param Param test parameters 100*cdf0e10cSrcweir * @param log writer to log information while testing 101*cdf0e10cSrcweir * @return 102*cdf0e10cSrcweir * @throws StatusException 103*cdf0e10cSrcweir * @see TestEnvironment 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir protected TestEnvironment createTestEnvironment(TestParameters Param, 106*cdf0e10cSrcweir PrintWriter log) { 107*cdf0e10cSrcweir XInterface oObj = null; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir Object oDBContext = null; 110*cdf0e10cSrcweir Object oDBSource = null; 111*cdf0e10cSrcweir Object newQuery = null; 112*cdf0e10cSrcweir Object toolkit = null; 113*cdf0e10cSrcweir XStorable store = null; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir try { 116*cdf0e10cSrcweir oDBContext = ((XMultiServiceFactory) Param.getMSF()) 117*cdf0e10cSrcweir .createInstance("com.sun.star.sdb.DatabaseContext"); 118*cdf0e10cSrcweir oDBSource = ((XMultiServiceFactory) Param.getMSF()) 119*cdf0e10cSrcweir .createInstance("com.sun.star.sdb.DataSource"); 120*cdf0e10cSrcweir newQuery = ((XMultiServiceFactory) Param.getMSF()) 121*cdf0e10cSrcweir .createInstance("com.sun.star.sdb.QueryDefinition"); 122*cdf0e10cSrcweir toolkit = ((XMultiServiceFactory) Param.getMSF()) 123*cdf0e10cSrcweir .createInstance("com.sun.star.awt.Toolkit"); 124*cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 125*cdf0e10cSrcweir e.printStackTrace(log); 126*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't create instance")); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir String mysqlURL = (String) Param.get("mysql.url"); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if (mysqlURL == null) { 132*cdf0e10cSrcweir throw new StatusException(Status.failed( 133*cdf0e10cSrcweir "Couldn't get 'mysql.url' from ini-file")); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir user = (String) Param.get("jdbc.user"); 137*cdf0e10cSrcweir password = (String) Param.get("jdbc.password"); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir if ((user == null) || (password == null)) { 140*cdf0e10cSrcweir throw new StatusException(Status.failed( 141*cdf0e10cSrcweir "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir PropertyValue[] info = new PropertyValue[2]; 145*cdf0e10cSrcweir info[0] = new PropertyValue(); 146*cdf0e10cSrcweir info[0].Name = "user"; 147*cdf0e10cSrcweir info[0].Value = user; 148*cdf0e10cSrcweir info[1] = new PropertyValue(); 149*cdf0e10cSrcweir info[1].Name = "password"; 150*cdf0e10cSrcweir info[1].Value = password; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface( 153*cdf0e10cSrcweir XPropertySet.class, oDBSource); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir try { 156*cdf0e10cSrcweir propSetDBSource.setPropertyValue("URL", mysqlURL); 157*cdf0e10cSrcweir propSetDBSource.setPropertyValue("Info", info); 158*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 159*cdf0e10cSrcweir e.printStackTrace(log); 160*cdf0e10cSrcweir throw new StatusException(Status.failed( 161*cdf0e10cSrcweir "Couldn't set property value")); 162*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 163*cdf0e10cSrcweir e.printStackTrace(log); 164*cdf0e10cSrcweir throw new StatusException(Status.failed( 165*cdf0e10cSrcweir "Couldn't set property value")); 166*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 167*cdf0e10cSrcweir e.printStackTrace(log); 168*cdf0e10cSrcweir throw new StatusException(Status.failed( 169*cdf0e10cSrcweir "Couldn't set property value")); 170*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 171*cdf0e10cSrcweir e.printStackTrace(log); 172*cdf0e10cSrcweir throw new StatusException(Status.failed( 173*cdf0e10cSrcweir "Couldn't set property value")); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir try { 177*cdf0e10cSrcweir log.println ("writing database file ..."); 178*cdf0e10cSrcweir XDocumentDataSource xDDS = (XDocumentDataSource) 179*cdf0e10cSrcweir UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource); 180*cdf0e10cSrcweir store = (XStorable) UnoRuntime.queryInterface(XStorable.class, 181*cdf0e10cSrcweir xDDS.getDatabaseDocument()); 182*cdf0e10cSrcweir aFile = utils.getOfficeTemp ((XMultiServiceFactory) Param.getMSF ())+"TableWindow.odb"; 183*cdf0e10cSrcweir log.println("... filename will be "+aFile); 184*cdf0e10cSrcweir store.storeAsURL(aFile,new PropertyValue[]{}); 185*cdf0e10cSrcweir log.println("... done"); 186*cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 187*cdf0e10cSrcweir e.printStackTrace(log); 188*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't register object")); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface( 192*cdf0e10cSrcweir XIsolatedConnection.class, 193*cdf0e10cSrcweir oDBSource); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir XConnection connection = null; 196*cdf0e10cSrcweir XStatement statement = null; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir final String tbl_name1 = "tst_table1"; 199*cdf0e10cSrcweir final String tbl_name2 = "tst_table2"; 200*cdf0e10cSrcweir final String col_name1 = "id1"; 201*cdf0e10cSrcweir final String col_name2 = "id2"; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir try { 204*cdf0e10cSrcweir connection = isolConnection.getIsolatedConnection(user, password); 205*cdf0e10cSrcweir statement = connection.createStatement(); 206*cdf0e10cSrcweir statement.executeUpdate("drop table if exists " + tbl_name1); 207*cdf0e10cSrcweir statement.executeUpdate("drop table if exists " + tbl_name2); 208*cdf0e10cSrcweir statement.executeUpdate("create table " + tbl_name1 + " (" + 209*cdf0e10cSrcweir col_name1 + " int)"); 210*cdf0e10cSrcweir statement.executeUpdate("create table " + tbl_name2 + " (" + 211*cdf0e10cSrcweir col_name2 + " int)"); 212*cdf0e10cSrcweir } catch (com.sun.star.sdbc.SQLException e) { 213*cdf0e10cSrcweir try { 214*cdf0e10cSrcweir shortWait(); 215*cdf0e10cSrcweir connection = isolConnection.getIsolatedConnection(user, 216*cdf0e10cSrcweir password); 217*cdf0e10cSrcweir statement = connection.createStatement(); 218*cdf0e10cSrcweir statement.executeUpdate("drop table if exists " + tbl_name1); 219*cdf0e10cSrcweir statement.executeUpdate("drop table if exists " + tbl_name2); 220*cdf0e10cSrcweir statement.executeUpdate("create table " + tbl_name1 + " (" + 221*cdf0e10cSrcweir col_name1 + " int)"); 222*cdf0e10cSrcweir statement.executeUpdate("create table " + tbl_name2 + " (" + 223*cdf0e10cSrcweir col_name2 + " int)"); 224*cdf0e10cSrcweir } catch (com.sun.star.sdbc.SQLException e2) { 225*cdf0e10cSrcweir e2.printStackTrace(log); 226*cdf0e10cSrcweir throw new StatusException(Status.failed("SQLException")); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface( 231*cdf0e10cSrcweir XQueryDefinitionsSupplier.class, 232*cdf0e10cSrcweir oDBSource); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir XNameAccess defContainer = querySuppl.getQueryDefinitions(); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface( 237*cdf0e10cSrcweir XPropertySet.class, newQuery); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir try { 240*cdf0e10cSrcweir final String query = "select * from " + tbl_name1 + ", " + 241*cdf0e10cSrcweir tbl_name2 + " where " + tbl_name1 + "." + 242*cdf0e10cSrcweir col_name1 + "=" + tbl_name2 + "." + 243*cdf0e10cSrcweir col_name2; 244*cdf0e10cSrcweir queryProp.setPropertyValue("Command", query); 245*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 246*cdf0e10cSrcweir e.printStackTrace(log); 247*cdf0e10cSrcweir throw new StatusException(Status.failed( 248*cdf0e10cSrcweir "Couldn't set property value")); 249*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 250*cdf0e10cSrcweir e.printStackTrace(log); 251*cdf0e10cSrcweir throw new StatusException(Status.failed( 252*cdf0e10cSrcweir "Couldn't set property value")); 253*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 254*cdf0e10cSrcweir e.printStackTrace(log); 255*cdf0e10cSrcweir throw new StatusException(Status.failed( 256*cdf0e10cSrcweir "Couldn't set property value")); 257*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 258*cdf0e10cSrcweir e.printStackTrace(log); 259*cdf0e10cSrcweir throw new StatusException(Status.failed( 260*cdf0e10cSrcweir "Couldn't set property value")); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface( 264*cdf0e10cSrcweir XNameContainer.class, 265*cdf0e10cSrcweir defContainer); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir try { 268*cdf0e10cSrcweir queryContainer.insertByName("Query1", newQuery); 269*cdf0e10cSrcweir store.store(); 270*cdf0e10cSrcweir connection.close (); 271*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 272*cdf0e10cSrcweir e.printStackTrace(log); 273*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't insert query")); 274*cdf0e10cSrcweir } catch (com.sun.star.container.ElementExistException e) { 275*cdf0e10cSrcweir e.printStackTrace(log); 276*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't insert query")); 277*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 278*cdf0e10cSrcweir e.printStackTrace(log); 279*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't insert query")); 280*cdf0e10cSrcweir } catch (com.sun.star.io.IOException e) { 281*cdf0e10cSrcweir e.printStackTrace(log); 282*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't insert query")); 283*cdf0e10cSrcweir } catch (com.sun.star.sdbc.SQLException e) { 284*cdf0e10cSrcweir e.printStackTrace(log); 285*cdf0e10cSrcweir throw new StatusException(Status.failed("Couldn't insert query")); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir PropertyValue[] loadProps = new PropertyValue[3]; 289*cdf0e10cSrcweir loadProps[0] = new PropertyValue(); 290*cdf0e10cSrcweir loadProps[0].Name = "QueryDesignView"; 291*cdf0e10cSrcweir loadProps[0].Value = Boolean.TRUE; 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir loadProps[1] = new PropertyValue(); 294*cdf0e10cSrcweir loadProps[1].Name = "CurrentQuery"; 295*cdf0e10cSrcweir loadProps[1].Value = "Query1"; 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir loadProps[2] = new PropertyValue(); 298*cdf0e10cSrcweir loadProps[2].Name = "DataSource"; 299*cdf0e10cSrcweir loadProps[2].Value = oDBSource; 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir QueryComponent = DesktopTools.loadDoc((XMultiServiceFactory) Param.getMSF (),".component:DB/QueryDesign",loadProps); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent). 304*cdf0e10cSrcweir getCurrentController().getFrame().getContainerWindow(); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "", 311*cdf0e10cSrcweir "TableWindowAccessibility"); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir log.println("ImplementationName " + util.utils.getImplName(oObj)); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir log.println("creating TestEnvironment ... done"); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir TestEnvironment tEnv = new TestEnvironment(oObj); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir shortWait(); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir XAccessibleComponent accComp = (XAccessibleComponent) UnoRuntime.queryInterface( 322*cdf0e10cSrcweir XAccessibleComponent.class, 323*cdf0e10cSrcweir oObj); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir final Point point = accComp.getLocationOnScreen(); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir tEnv.addObjRelation("EventProducer", 329*cdf0e10cSrcweir new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 330*cdf0e10cSrcweir public void fireEvent() { 331*cdf0e10cSrcweir try { 332*cdf0e10cSrcweir Robot rob = new Robot(); 333*cdf0e10cSrcweir rob.mouseMove(point.X + 2, point.Y + 7); 334*cdf0e10cSrcweir rob.mousePress(InputEvent.BUTTON1_MASK); 335*cdf0e10cSrcweir rob.mouseMove(point.X + 400, point.Y); 336*cdf0e10cSrcweir rob.mouseRelease (InputEvent.BUTTON1_MASK); 337*cdf0e10cSrcweir } catch (java.awt.AWTException e) { 338*cdf0e10cSrcweir System.out.println("desired child doesn't exist"); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir }); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir return tEnv; 344*cdf0e10cSrcweir } // finish method getTestEnvironment 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir /** 347*cdf0e10cSrcweir * Closes all open documents. 348*cdf0e10cSrcweir */ 349*cdf0e10cSrcweir protected void cleanup(TestParameters Param, PrintWriter log) { 350*cdf0e10cSrcweir try 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir log.println ("closing QueryComponent ..."); 354*cdf0e10cSrcweir DesktopTools.closeDoc (QueryComponent); 355*cdf0e10cSrcweir log.println ("... done"); 356*cdf0e10cSrcweir XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF (); 357*cdf0e10cSrcweir Object sfa = xMSF.createInstance ("com.sun.star.comp.ucb.SimpleFileAccess"); 358*cdf0e10cSrcweir XSimpleFileAccess xSFA = (XSimpleFileAccess) UnoRuntime.queryInterface (XSimpleFileAccess.class, sfa); 359*cdf0e10cSrcweir log.println ("deleting database file"); 360*cdf0e10cSrcweir xSFA.kill (aFile); 361*cdf0e10cSrcweir log.println ("Could delete file "+aFile+": "+!xSFA.exists (aFile)); 362*cdf0e10cSrcweir } catch (Exception e) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir e.printStackTrace (); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir /** 370*cdf0e10cSrcweir * Sleeps for 1.5 sec. to allow StarOffice to react on <code> 371*cdf0e10cSrcweir * reset</code> call. 372*cdf0e10cSrcweir */ 373*cdf0e10cSrcweir private void shortWait() { 374*cdf0e10cSrcweir try { 375*cdf0e10cSrcweir Thread.sleep(1500); 376*cdf0e10cSrcweir } catch (InterruptedException e) { 377*cdf0e10cSrcweir log.println("While waiting :" + e); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381