RE: EXTERNAL: Re: soffice process still running

2013-05-07 Thread Steele, Raymond
Thanks for the recommendation and insight.

Raymond

-Original Message-
From: Ariel Constenla-Haile [mailto:arie...@apache.org] 
Sent: Tuesday, May 07, 2013 10:16 AM
To: api@openoffice.apache.org
Subject: 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

-
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

2013-05-07 Thread Ariel Constenla-Haile
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

2013-05-07 Thread Steele, Raymond
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. 

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?

Thanks Again!

Raymond

-Original Message-
From: Ariel Constenla-Haile [mailto:arie...@apache.org] 
Sent: Monday, May 06, 2013 5:17 PM
To: api@openoffice.apache.org
Subject: Re: EXTERNAL: Re: soffice process still running

Hi Raymond,

On Mon, May 06, 2013 at 08:14:17PM +, Steele, Raymond wrote:
> 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?

Do you know what component is still alive? If I recall clearly, you didn't want 
to close all other documents in the first time, but simply terminate the office 
when all documents have been closed.

This enumeration contains all components that where opened using the 
application framework, if this component is keeping the desktop alive, you have 
to close/dispose it. But then, you face your original problem:
you don't want to close documents that are still open. So, first, investigate 
which is the component that is keeping the office alive:

> if (!xEnumerationAccess.hasElements()) {
> xDesktop.terminate();

Replace this with an if ... else ...
If the enumeration has elements, iterate over them, see if they support 
css.lang.XServiceInfo, and print information about the component; this may get 
you some hint about that last component.


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

2013-05-07 Thread jg
You can dispose the component in question 
(http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/XComponent.html).


jg

-
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

2013-05-06 Thread Ariel Constenla-Haile
Hi Raymond,

On Mon, May 06, 2013 at 08:14:17PM +, Steele, Raymond wrote:
> 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?

Do you know what component is still alive? If I recall clearly, you
didn't want to close all other documents in the first time, but simply
terminate the office when all documents have been closed.

This enumeration contains all components that where opened using the
application framework, if this component is keeping the desktop alive,
you have to close/dispose it. But then, you face your original problem:
you don't want to close documents that are still open. So, first,
investigate which is the component that is keeping the office alive:

> if (!xEnumerationAccess.hasElements()) {
> xDesktop.terminate();

Replace this with an if ... else ...
If the enumeration has elements, iterate over them, see if they support
css.lang.XServiceInfo, and print information about the component; this
may get you some hint about that last component.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpaQQ2zDyWk6.pgp
Description: PGP signature


RE: EXTERNAL: Re: soffice process still running

2013-05-06 Thread Steele, Raymond
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

2013-02-04 Thread Steele, Raymond
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

2013-02-01 Thread Ariel Constenla-Haile
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

2013-01-31 Thread Steele, Raymond
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?

Thanks, 

Raymond

-Original Message-
From: Ariel Constenla-Haile [mailto:arie...@apache.org] 
Sent: Thursday, January 31, 2013 9:03 AM
To: api@openoffice.apache.org
Subject: EXTERNAL: Re: soffice process still running

On Mon, Jan 28, 2013 at 10:44:10PM +, Steele, Raymond wrote:
> After implementing the below code, the soffice process continues to 
> run. I check this using ps -ef| grep soffice on Solaris 10 x86 
> OpenOffice 3.2.  Can anyone explain how to get this process to stop?
> I do not want to use the kill command because I do not want to kill 
> any other instances of open office. Thanks!

Did you try terminating the Desktop? That would be 
http://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/XDesktop.html#terminate
Note that if the quickstarter is enabled, it will throw a 
TerminationVetoException (launch OpenOffice with -quickstart=no to get rid of 
it).


Regards
--
Ariel Constenla-Haile
La Plata, Argentina


RE: EXTERNAL: Re: soffice process still running

2013-01-31 Thread Steele, Raymond
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


RE: EXTERNAL: Re: soffice process still running

2013-01-30 Thread Steele, Raymond
Yes, I have, to no avail.

-Original Message-
From: Marcin Gutman [mailto:mgut...@op.pl] 
Sent: Wednesday, January 30, 2013 2:27 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.
 >

Did you try examples included with SDK?
(/openoffice.org/basis3.4/sdk/examples/)

Some of them use XCloseable. Try grep in "sdk" directory:
 grep -R -i xcloseable ./examples   

Best Regards,
Marcin