Hi Ariel,

you are the best, thank you very much for your help and especially your pointers!


Ariel Constenla-Haile wrote:
Rony G. Flatscher escribió:
Hi there,

have tried to research the service needed for expanding a script URL to its canonical path to no avail.

E.g. given the following infos from OOo, how would one be able to get at the canonical path (fully qualified, but shortest operating system dependent path, but the OOo-URL rendering of it would be fine as well)?

   * parcelLocation
o vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests

o vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1

   * shortFormScriptURL
o vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=user

o vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share

   * scriptFullURL
o vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests

o vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1


Or, alternatively: how can one reliably infer the canonical path to the "user" and "share" root directory with the help of OOo services? Would that solution work for 3.x as well?

TIA,

---rony

Hi Rony,

I'm not sure about the first part of your question, so I answer first
your "at least".

For getting the "user" and "share" you can try with:

http://api.openoffice.org/docs/common/ref/com/sun/star/util/PathSubstitution.html http://api.openoffice.org/docs/common/ref/com/sun/star/util/PathSettings.html
Found the above two and experimented with them already. However, I have felt a little bit unsecure whether the assumptions one needs to apply in order to build the physical path to the user and share level macros would be stable, especially when 3.0 comes along.

http://api.openoffice.org/docs/common/ref/com/sun/star/util/OfficeInstallationDirectories.html
This one was new, thank you! (But again, the same considerations would apply as for the above two starting points.)


Bellow [1] is a demo (results from DEV300_m19).

For your original question (expand a script URL), you may take a look at

*
http://api.openoffice.org/docs/common/ref/com/sun/star/util/theMacroExpander.html
I've tested this [2] on other subjects, but not with Scripts URIs
*That was it*! Thank you *very* much, Ariel!

This singleton is able to expand the "parcelLocation" and the "scriptFullUrl" encodings above.

Here is an ooRexx script that tests that singleton:

   /* an ooRexx script for testen the theMacroExpander singleton */
   xContext = UNO.connect()  -- connect to server and retrieve the XContext 
object

   xme= 
xContext~getValueByName("/singletons/com.sun.star.util.theMacroExpander")~XMacroExpander

   macrofiedExpressions= .array~of( -
      
"vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=user"
 , -
      
"vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share"
     , -
      
"vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests",
 -
      
"vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1"
          , -
      
"vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests"
 , -
      
"vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1"
        -
      )

   do expr over macrofiedExpressions      -- iterate over the collection
      say pp(expr)":"                     -- show macrofied expression
      say "  " pp(xme~expandMacros(expr)) -- expand and show the expression
      say
   end

   ::requires uno.cls   -- get the UNO support for ooRexx (exploiting the Java 
interfaces)

The output produced matches the location on my PC (in this case a Windows XP laptop):

   F:\test\ooo\studenten\macroExpansions>testMacroExpander.rex
   
[vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=user]:
      
[vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=user]

   
[vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share]:
      
[vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share]

   
[vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests]:
      
[vnd.sun.star.script:Library3-Tests.metaDataInfosUser.rex?language=ooRexx&location=vnd.sun.star.expand:file:///D:/Dokumente%20und%20Einstellungen/Administrator/Anwendungsdaten/OpenOffice.org2/user/Scripts/oorexx/Library3-Tests]

   
[vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1]:
      
[vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=vnd.sun.star.expand:file:///D:/Programme/OpenOffice.org%202.4/program/../share/Scripts/oorexx/Library1]

   
[vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::UserInstallation}/user/Scripts/oorexx/Library3-Tests]:
      
[vnd.sun.star.expand:file:///D:/Dokumente%20und%20Einstellungen/Administrator/Anwendungsdaten/OpenOffice.org2/user/Scripts/oorexx/Library3-Tests]

   
[vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1]:
      
[vnd.sun.star.expand:file:///D:/Programme/OpenOffice.org%202.4/program/../share/Scripts/oorexx/Library1]
This is exactly what I have been looking for!

Kudos to you, Ariel!

Regards from Vienna (Austria)

---rony


Reply via email to