1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package complex.framework.recovery; 29 30 import com.sun.star.frame.XController; 31 import com.sun.star.frame.XDispatch; 32 import com.sun.star.frame.XDispatchProvider; 33 import com.sun.star.frame.XModel; 34 import com.sun.star.lang.XComponent; 35 import com.sun.star.lang.XMultiServiceFactory; 36 import com.sun.star.uno.UnoRuntime; 37 import com.sun.star.util.URL; 38 import com.sun.star.util.XURLTransformer; 39 40 /** 41 * Thread to crash the office. This thread dies after the office process 42 * is nopt longer available. 43 */ 44 public class CrashThread extends Thread { 45 public XComponent xDoc = null; 46 public XMultiServiceFactory msf = null; 47 48 public CrashThread(XComponent xDoc, XMultiServiceFactory msf) { 49 this.xDoc = xDoc; 50 this.msf = msf; 51 } 52 53 public void run() { 54 try{ 55 XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc); 56 57 XController xController = xModel.getCurrentController(); 58 XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface( 59 XDispatchProvider.class, 60 xController); 61 XURLTransformer xParser = (XURLTransformer) UnoRuntime.queryInterface( 62 XURLTransformer.class, 63 msf.createInstance( 64 "com.sun.star.util.URLTransformer")); 65 66 // Because it's an in/out parameter we must use an array of URL objects. 67 URL[] aParseURL = new URL[1]; 68 aParseURL[0] = new URL(); 69 aParseURL[0].Complete = ".uno:Crash"; 70 xParser.parseStrict(aParseURL); 71 72 URL aURL = aParseURL[0]; 73 XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); 74 75 if (xDispatcher != null) { 76 xDispatcher.dispatch(aURL, null); 77 } 78 } catch (Exception e){} 79 } 80 } 81