Q: How to get the path of all opened spreadsheet documents

SOS sos at pmg.be
Wed Jun 10 09:52:52 PDT 2015


  Zhang

in basic i use this function

Function TaskonDesktop(DocPath as String) as Boolean

Dim oComponents as Object

     ' Search if one of the active Components ist the one that you 
search for
     oComponents = StarDesktop.Components.CreateEnumeration
     While oComponents.HasmoreElements
         oComponent = oComponents.NextElement
'print    UCase(oComponent.URL) & " - " & UCase(converttoURL(DocPath)
             If UCase(oComponent.URL) = UCase(converttoURL(DocPath)) then
                 TaskonDesktop = True
         Exit Function
         End If
     Wend
     TaskonDesktop = False
End Function


hope it helps

Fernand
>
> Hi Andrew,
>
> Thanks a lot for your reply.
>
> Q1: In your case do you only care about documents that have been 
> saved... Ignoring new never saved to disk docs?
>
> àWhat I want to get is all calc documents as long as the doc is 
> opened, no matter it have been saved or not.
>
>   So firstly, I want to know if it’s possible to do it in this case. 
> If no, maybe I can only care the doc which have been saved and ignore 
> which is not saved.
>
> Q2: You enumerate the open components from the desktop object and 
> check of the component is a calc document.
>
> àSorry, I know how to get the desktop object, but I am not clear how 
> to get the open component and check them as you mentioned.
>
>   This is my gap, would you please give example code based on my 
> comment for Q1?
>
> Thanks in advanced!
>
> Best Regards
>
> William
>
> -----Original Message-----
> From: Andrew Pitonyak [mailto:andrew at pitonyak.org]
> Sent: 2015年6月5日19:15
> To: Zhang, William
> Cc: libreoffice at lists.freedesktop.org
> Subject: Re: Q: How to get the path of all opened spreadsheet documents
>
> No time to find the solution now.... But I have done this sort of 
> thing in basic.
>
> You enumerate the open components from the desktop object and check of 
> the component is a calc document.
>
> In your case do you only care about documents that have been saved... 
> Ignoring new never saved to disk docs?
>
> Think I can find a basic example of it helps
>
> On Jun 4, 2015 10:35 PM, "Zhang, William" 
> <william.zhang at ptn.advantest.com 
> <mailto:william.zhang at ptn.advantest.com>> wrote:
>
> >
>
> > Hi,
>
> >
>
> >
>
> >
>
> > Request:
>
> >
>
> > In RedHat7, I want to get the path of all opened spreadsheet documents with Java.
>
> >
>
> >
>
> >
>
> > What I’ve done:
>
> >
>
> > 1.I used Runtime.exec(cmd…) with Java code, the ‘cmd’was defined with 
> “ps –ef | grep xxx”
>
> >
>
> > ->if only one spreadsheet document opened, the returned info list the correct 
> document, I can parse it and get the file path
>
> >
>
> > ->but if multi spreadsheet documents opened, the returned process still only 
> list the first document, I cannot get other documents.
>
> >
>
> >2.I also test in bash, it seems “ps -ef”cannot list all files.
>
> >
>
> >
>
> >
>
> > So , I want to know is there any other way to do it. such as using UNO service with 
> libreoffice API to get it.
>
> >
>
> > Anyone who knows it is much appreciate.
>
> >
>
> >
>
> >
>
> > Best Regards
>
> >
>
> > William
>
> >
>
> >
>
>
>
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20150610/06623ff6/attachment.html>


More information about the LibreOffice mailing list