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 ; }
Disconnects from an OOo server using the connection string from the previous connect .