soffice process still running

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

soffice process still running

Steele, Raymond
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!

  // Conditions: xDocument = m_xLoadedDocument
  // Check supported functionality of the document (model or controller).
  com.sun.star.frame.XModel xModel =
    (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
      com.sun.star.frame.XModel.class,xDocument);

  if(xModel!=null)
  {
    // It is a full featured office document.
    // Try to use close mechanism instead of a hard dispose().
    // But maybe such service is not available on this model.
    com.sun.star.util.XCloseable xCloseable =
      (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
        com.sun.star.util.XCloseable.class,xModel);

  if(xCloseable!=null)
  {
    try
      {
        // use close(boolean DeliverOwnership)
        // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
        // assume ownership if they object the closure by throwing a CloseVetoException
        // Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
        xCloseable.close(true);
      }
      catch(com.sun.star.util.CloseVetoException exCloseVeto)
      {
      }
  }
  // If close is not supported by this model - try to dispose it.
  // But if the model disagree with a reset request for the modify state
  // we shouldn't do so. Otherwhise some strange things can happen.
  else
  {
      com.sun.star.lang.XComponent xDisposeable =
        (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
         com.sun.star.lang.XComponent.class,xModel);
         xDisposeable.dispose();
       }
       catch(com.sun.star.beans.PropertyVetoException exModifyVeto)
       {
       }
      }
    }
  }


Raymond Steele
U-2 Mission Planning
Software Engineer
Lockheed Martin - IS&GS Defense
1300 S. Litchfield Rd.
Goodyear, AZ 85338
Email: [hidden email]
Business phone:  623-925-6102

Reply | Threaded
Open this post in threaded view
|

RE: soffice process still running

Steele, Raymond
Any help here would be appreciated.   xCloseable.close(true) does not kill the soffice process off. Also, I am using version 3.3 versus 3.2 as stated below.

Thanks!


From: Steele, Raymond
Sent: Monday, January 28, 2013 3:44 PM
To: '[hidden email]'; '[hidden email]'; '[hidden email]'
Subject: soffice process still running

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!

  // Conditions: xDocument = m_xLoadedDocument
  // Check supported functionality of the document (model or controller).
  com.sun.star.frame.XModel xModel =
    (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
      com.sun.star.frame.XModel.class,xDocument);

  if(xModel!=null)
  {
    // It is a full featured office document.
    // Try to use close mechanism instead of a hard dispose().
    // But maybe such service is not available on this model.
    com.sun.star.util.XCloseable xCloseable =
      (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
        com.sun.star.util.XCloseable.class,xModel);

  if(xCloseable!=null)
  {
    try
      {
        // use close(boolean DeliverOwnership)
        // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
        // assume ownership if they object the closure by throwing a CloseVetoException
        // Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
        xCloseable.close(true);
      }
      catch(com.sun.star.util.CloseVetoException exCloseVeto)
      {
      }
  }
  // If close is not supported by this model - try to dispose it.
  // But if the model disagree with a reset request for the modify state
  // we shouldn't do so. Otherwhise some strange things can happen.
  else
  {
      com.sun.star.lang.XComponent xDisposeable =
        (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
         com.sun.star.lang.XComponent.class,xModel);
         xDisposeable.dispose();
       }
       catch(com.sun.star.beans.PropertyVetoException exModifyVeto)
       {
       }
      }
    }
  }


Raymond Steele

Reply | Threaded
Open this post in threaded view
|

Re: soffice process still running

Marcin Gutman
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
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

Steele, Raymond
Yes, I have, to no avail.

-----Original Message-----
From: Marcin Gutman [mailto:[hidden email]]
Sent: Wednesday, January 30, 2013 2:27 PM
To: [hidden email]; 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
Reply | Threaded
Open this post in threaded view
|

Re: soffice process still running

Marcin Gutman
In reply to this post by Steele, Raymond
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
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

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:[hidden email]]
Sent: Wednesday, January 30, 2013 3:51 PM
To: [hidden email]; 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
Reply | Threaded
Open this post in threaded view
|

Re: soffice process still running

Ariel Constenla-Haile-2
In reply to this post by Steele, Raymond
On Mon, Jan 28, 2013 at 10:44:10PM +0000, 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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

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:[hidden email]]
Sent: Thursday, January 31, 2013 9:03 AM
To: [hidden email]
Subject: EXTERNAL: Re: soffice process still running

On Mon, Jan 28, 2013 at 10:44:10PM +0000, 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
Reply | Threaded
Open this post in threaded view
|

Re: soffice process still running

Marcin Gutman
Hi,

 > 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 about combining both methods?

if (doc is the last one){
      use desktop.terminate
}else{
      use closeable.close
}

Best Regards,
Marcin


Reply | Threaded
Open this post in threaded view
|

Re: EXTERNAL: Re: soffice process still running

Ariel Constenla-Haile-2
In reply to this post by Steele, Raymond
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.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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

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:[hidden email]]
Sent: Friday, February 01, 2013 5:24 AM
To: [hidden email]
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
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

Steele, Raymond
In reply to this post by Ariel Constenla-Haile-2
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: '[hidden email]'
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:[hidden email]]
Sent: Friday, February 01, 2013 5:24 AM
To: [hidden email]
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: EXTERNAL: Re: soffice process still running

Ariel Constenla-Haile-2
Hi Raymond,

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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: EXTERNAL: Re: soffice process still running

jg-2
In reply to this post by Steele, Raymond
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

Steele, Raymond
In reply to this post by Ariel Constenla-Haile-2
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:[hidden email]]
Sent: Monday, May 06, 2013 5:17 PM
To: [hidden email]
Subject: Re: EXTERNAL: Re: soffice process still running

Hi Raymond,

On Mon, May 06, 2013 at 08:14:17PM +0000, 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: EXTERNAL: Re: soffice process still running

Ariel Constenla-Haile-2
Hi Raymond,

On Tue, May 07, 2013 at 04:25:57PM +0000, 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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL: Re: soffice process still running

Steele, Raymond
Thanks for the recommendation and insight.

Raymond

-----Original Message-----
From: Ariel Constenla-Haile [mailto:[hidden email]]
Sent: Tuesday, May 07, 2013 10:16 AM
To: [hidden email]
Subject: Re: EXTERNAL: Re: soffice process still running

Hi Raymond,

On Tue, May 07, 2013 at 04:25:57PM +0000, 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: [hidden email]
For additional commands, e-mail: [hidden email]