Java Code Examples for com.sun.star.frame.XDesktop#terminate()

The following examples show how to use com.sun.star.frame.XDesktop#terminate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagedOfficeProcess.java    From kkFileViewOfficeEdit with Apache License 2.0 5 votes vote down vote up
private void doStopProcess() {
	try {
		XDesktop desktop = OfficeUtils.cast(XDesktop.class, connection.getService(OfficeUtils.SERVICE_DESKTOP));
		desktop.terminate();
	} catch (DisposedException disposedException) {
		// expected
	} catch (Exception exception) {
		// in case we can't get hold of the desktop
		doTerminateProcess();
	}
	doEnsureProcessExited();
}
 
Example 2
Source File: ManagedOfficeProcess.java    From kkFileView with Apache License 2.0 5 votes vote down vote up
private void doStopProcess() {
	try {
		XDesktop desktop = OfficeUtils.cast(XDesktop.class, connection.getService(OfficeUtils.SERVICE_DESKTOP));
		desktop.terminate();
	} catch (DisposedException disposedException) {
		// expected
	} catch (Exception exception) {
		// in case we can't get hold of the desktop
		doTerminateProcess();
	}
	doEnsureProcessExited();
}
 
Example 3
Source File: ManagedOfficeProcess.java    From wenku with MIT License 5 votes vote down vote up
private void doStopProcess() {
	try {
		XDesktop desktop = OfficeUtils.cast(XDesktop.class, connection.getService(OfficeUtils.SERVICE_DESKTOP));
		desktop.terminate();
	} catch (DisposedException disposedException) {
		// expected
	} catch (Exception exception) {
		// in case we can't get hold of the desktop
		doTerminateProcess();
	}
	doEnsureProcessExited();
}
 
Example 4
Source File: BootstrapConnector.java    From yarg with Apache License 2.0 5 votes vote down vote up
/**
 * Disconnects from an OOo server using the connection string from the
 * previous connect.
 * 
 * If there has been no previous connect, the disconnects does nothing.
 * 
 * If there has been a previous connect, disconnect tries to terminate
 * the OOo server and kills the OOo server process the connect started.
 */
public void disconnect() {

    if (oooConnectionString == null)
        return;

    // call office to terminate itself
    try {
        // get local context
        XComponentContext xLocalContext = getLocalContext();

        // create a URL resolver
        XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext);

        // get remote context
        XComponentContext xRemoteContext = getRemoteContext(xUrlResolver);

        // get desktop to terminate office
        Object desktop = xRemoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext);
        XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
        xDesktop.terminate();
    }
    catch (Exception e) {
        // Bad luck, unable to terminate office
    }

    oooServer.kill();
    oooConnectionString = null;
}