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

2015-06-11 Thread SOS


 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
'printUCase(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:and...@pitonyak.org]
Sent: 2015年6月5日19:15
To: Zhang, William
Cc: libreoffice@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.zh...@ptn.advantest.com 
mailto:william.zh...@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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


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

2015-06-10 Thread Zhang, William
Hi Andrew and Fernand,

Thanks a lot for your help.

With your hint, I’ve found a way to get file path for all opened spreadsheet 
documents with Java, my code is as follow.
---
String ooExeFolder = /usr/lib64/libreoffice/program;
XComponentContext xContext = 
BootstrapSocketConnector.bootstrap(ooExeFolder);
XMultiComponentFactory xMCF = xContext.getServiceManager();
Object desktop = 
xMCF.createInstanceWithContext(com.sun.star.frame.Desktop, xContext);
XDesktop xDesktop = 
(XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);
XEnumeration xenum  = xDesktop.getComponents().createEnumeration();

 while(xenum.hasMoreElements()) {
  Object obj = xenum.nextElement();
  XComponent x = 
(XComponent)UnoRuntime.queryInterface(XComponent.class, obj);
  XModel xm = 
(XModel)UnoRuntime.queryInterface(XModel.class, x);
  if (xm != null) {
  String url = xm.getURL(); //url is what I want
  System.out.println(url);
  }
 }

Best Regards
William

-
From: SOS [mailto:s...@pmg.be]
Sent: 2015年6月11日 0:52
To: Zhang, William; us...@global.libreoffice.org
Subject: Re: Q: How to get the path of all opened spreadsheet documents


 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
'printUCase(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


From: Andrew Douglas Pitonyak [mailto:and...@pitonyak.org]
Sent: 2015年6月8日 19:20
To: Zhang, William
Cc: libreoffice@lists.freedesktop.org
Subject: Re: Q: How to get the path of all opened spreadsheet documents


Calc documents implement the following service:

com.sun.star.sheet.SpreadsheetDocument

Using that with the examples below based on a write document:


'**
'// Count the total number of open componets.
'// This includes all document types as well
'// as things such as the Basic IDE and help windows.
'**
Function numberOfOpenComponents As Integer
  Dim i As Integer
  Dim oDocs
  Dim oDoc
  i = 0

  oDocs = StarDesktop.getComponents().createEnumeration()
  Do While oDocs.hasMoreElements()
oDoc = oDocs.nextElement()
i = i + 1
  Loop
  numberOfOpenComponents = i
End Function

'**
'// Count number of open Write documents.
'**
Function countOpenWriteDocs() As Integer
  countOpenWriteDocs = countTypedComponents(com.sun.star.text.TextDocument)
End Function

'**
'// Count number of documents that are open with the specified service type.
'**
Function countTypedComponents(serviceName$) As Integer
  Dim i As Integer
  Dim oDocs
  Dim oDoc
  i = 0

  oDocs = StarDesktop.getComponents().createEnumeration()
  Do While oDocs.hasMoreElements()
oDoc = oDocs.nextElement()
If oDoc.supportsService(serviceName) Then
  i = i + 1
End If
  Loop
  countTypedComponents = i
End Function

'**
'// Return true if the specified document is a Write document.
'**
Function isWriteDocument(oDoc) As Boolean
  If IsNull(oDoc) Then
isWriteDocument = False
  ElseIf IsEmpty(oDoc) Then
isWriteDocument = False
  ElseIf  oDoc.supportsService(com.sun.star.text.TextDocument) Then
isWriteDocument = True
  Else
isWriteDocument = False
  End If
End Function



On 06/07/2015 09:21 PM, Zhang, William wrote:

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 

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

2015-06-08 Thread Zhang, William
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:and...@pitonyak.org]
Sent: 2015年6月5日 19:15
To: Zhang, William
Cc: libreoffice@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.zh...@ptn.advantest.commailto:william.zh...@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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


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

2015-06-08 Thread Andrew Douglas Pitonyak


Calc documents implement the following service:

com.sun.star.sheet.SpreadsheetDocument

Using that with the examples below based on a write document:


'**
'// Count the total number of open componets.
'// This includes all document types as well
'// as things such as the Basic IDE and help windows.
'**
Function numberOfOpenComponents As Integer
  Dim i As Integer
  Dim oDocs
  Dim oDoc
  i = 0

  oDocs = StarDesktop.getComponents().createEnumeration()
  Do While oDocs.hasMoreElements()
oDoc = oDocs.nextElement()
i = i + 1
  Loop
  numberOfOpenComponents = i
End Function

'**
'// Count number of open Write documents.
'**
Function countOpenWriteDocs() As Integer
  countOpenWriteDocs = 
countTypedComponents(com.sun.star.text.TextDocument)

End Function

'**
'// Count number of documents that are open with the specified service type.
'**
Function countTypedComponents(serviceName$) As Integer
  Dim i As Integer
  Dim oDocs
  Dim oDoc
  i = 0

  oDocs = StarDesktop.getComponents().createEnumeration()
  Do While oDocs.hasMoreElements()
oDoc = oDocs.nextElement()
If oDoc.supportsService(serviceName) Then
  i = i + 1
End If
  Loop
  countTypedComponents = i
End Function

'**
'// Return true if the specified document is a Write document.
'**
Function isWriteDocument(oDoc) As Boolean
  If IsNull(oDoc) Then
isWriteDocument = False
  ElseIf IsEmpty(oDoc) Then
isWriteDocument = False
  ElseIf  oDoc.supportsService(com.sun.star.text.TextDocument) Then
isWriteDocument = True
  Else
isWriteDocument = False
  End If
End Function




On 06/07/2015 09:21 PM, Zhang, William wrote:


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:and...@pitonyak.org]
Sent: 2015年6月5日19:15
To: Zhang, William
Cc: libreoffice@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.zh...@ptn.advantest.com 
mailto:william.zh...@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







--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


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

2015-06-06 Thread Andrew Pitonyak
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.zh...@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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


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

2015-06-05 Thread Zhang, William
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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice