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(_
    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
    If bHidden Then
    End If
End Sub

Ariel Constenla-Haile
La Plata, Argentina

Attachment: pgplCMGGJhdKz.pgp
Description: PGP signature

Reply via email to