Re: EXTERNAL: Re: soffice process still running
Hi Raymond, On Tue, May 07, 2013 at 04:25:57PM +, Steele, Raymond wrote: Ariel, Thank you for the quick response. I have narrowed the continued process down to a component. However, the behavior is strange because I am not really opening the component in my code. My code opens a document using XComponentLoader::loadComponentFromURL(). I set the Hidden property to true so the user cannot see it. The document that is open contains Dynamic Data Exchange (DDE) links to another closed document. The code then uses XRefreshable interface to refresh all the DDE links found in XIndexAccess. Lastly, I export the document using the ODF Spreadsheet / calc8 filter name using XStore::storeToURL(). For some reason, this whole process opens (hidden) the other document to which the document I am refreshing contains DDE links to, even though I do not explicitly open it. Strange. It sounds logical that if you are refreshing the links, the application opens documents that are linked; what sounds like a bug is that the linked document isn't closed after the document containing the link is closed. This might be worth a bug report. In my original query, I did not want to close documents that were not opened by my application. (i.e. the user opens it by clicking on the OpenOffice desktop icon). My solution to this point for this issue is: if XEnumeration does have more elements, I create an enumeration from XEnumerationAccess, loop through it, get the XComponent interface and XModel for each element, and XClose::close() the component if the XModel::getURL() matches a specific URL to the implicitly opened document. Lastly, if the enumeration does not have any more elements, I terminate the desktop. All of this prevents my application from inadvertently closing any documents that were not opened by my application. Do you have any insight to this behavior or recommendations? May be you can asume that hidden documents were not opened by the user, and close them: if the enumeration has elements if all remaining documents are hidden close the all You can know if a document was loaded with Hidden set to true in the media descriptor by looping through css.frame.XModel.getArgs() REM * BASIC * Option Explicit Sub Main Dim aArgs(0) as new com.sun.star.beans.PropertyValue aArgs(0).Name = Hidden aArgs(0).Value = TRUE Dim oDoc as Object oDoc = StarDesktop.loadComponentFromURL(_ private:factory/swriter,_ _default,_ com.sun.star.frame.FrameSearchFlag.ALL,_ aArgs) Dim aLoadArgs() aLoadArgs = oDoc.getArgs() Dim aPropVal Dim bHidden as Boolean bHidden = FALSE For Each aPropVal In aLoadArgs If aPropVal.Name = Hidden Then bHidden = aPropVal.Value Exit For End If Next If bHidden Then oDoc.close(TRUE) End If End Sub Regards -- Ariel Constenla-Haile La Plata, Argentina pgplCMGGJhdKz.pgp Description: PGP signature
RE: EXTERNAL: Re: soffice process still running
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 +, 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
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 +, 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
Re: EXTERNAL: Re: soffice process still running
On Thu, Jan 31, 2013 at 05:48:11PM +, 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.Desktop, 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 pgpnA9g8bsyQb.pgp Description: PGP signature
RE: EXTERNAL: Re: soffice process still running
Yes, I seen this article. I guess, I don't understand why we would have to use XAsyncJob to close the document, if this is the solution. -Original Message- From: Marcin Gutman [mailto:mgut...@op.pl] Sent: Wednesday, January 30, 2013 3:51 PM To: api@openoffice.apache.org; Steele, Raymond Subject: EXTERNAL: Re: soffice process still running Hi, Any help here would be appreciated. xCloseable.close(true) does not kill the soffice process off. I found this: http://openoffice.2283327.n4.nabble.com/Instance-of-soffice-bin-remains-running-after-closing-OOo-td3032232.html Quotation: I solved the problem (or would that be a workaround) by adding an XAsyncJob that is called OnPrepareUnload which does an XCloseable-close() on background.odt This is called earlier than the destructor and everything closes cleanly as expected. Best Regards, Marcin