Ariel, I am having a case were the process continues to run. I appears the the EnumerationAccess does have elements, causing the desktop not to terminate. Is there a way to terminate a specific desktop that was not last open, and not close other desktops?
Raymond -----Original Message----- From: Steele, Raymond Sent: Monday, February 04, 2013 1:45 PM To: 'api@openoffice.apache.org' Subject: RE: EXTERNAL: Re: soffice process still running Ariel, I am not sure I understand why the following causes only the last opened document to close, but it seems to be the solution. if (!xEnumerationAccess.hasElements()) { xDesktop.terminate(); Thanks! Raymond -----Original Message----- From: Ariel Constenla-Haile [mailto:arie...@apache.org] Sent: Friday, February 01, 2013 5:24 AM To: api@openoffice.apache.org Subject: Re: EXTERNAL: Re: soffice process still running On Thu, Jan 31, 2013 at 05:48:11PM +0000, Steele, Raymond wrote: > Thanks for the feedback. > > I implemented the following, but the method kills off any other > instance of soffice that is running. > > Desktop_obj > = > component_factory.createInstanceWithContext("com.sun.star.frame.Deskto > p", context); XDesktop desktop = > UnoRuntime.queryInterface(XDesktop.class, > desktop_obj); desktop.terminate(); > > Any way that I can close the instance without killing off other > soffice instances? What do you mean by "instance"? There is only one instance of soffice.bin per application using the same user installation directory. If you mean that it closes all other documents, then you can check if this document is the last opened document, and if true, terminate the desktop: http://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/XDesktop.html#getComponents XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, xContext.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", xContext)); XTextDocument xTextDocument = UnoRuntime.queryInterface( XTextDocument.class, xComponentLoader.loadComponentFromURL( "private:factory/swriter", "_default", FrameSearchFlag.ALL, new PropertyValue[]{})); xTextDocument.getText().setString("Dummy text."); XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, xTextDocument); xCloseable.close(true); XDesktop xDesktop = UnoRuntime.queryInterface( XDesktop.class, xComponentLoader); XEnumerationAccess xEnumerationAccess = xDesktop.getComponents(); if (!xEnumerationAccess.hasElements()) { xDesktop.terminate(); } Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org