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
http://api.openoffice.org/docs/common/ref/com/sun/star/util/OfficeInstallationDirectories.html

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

*
http://api.openoffice.org/docs/common/ref/com/sun/star/script/provider/ScriptURIHelper.html
for the service description ("This service is used to help transform
Scripting Framework storage locations to Scripting Framework script URIs
and vice versa."), this *seems* to be what you're looking for
(didn't try it yet in Basic, as there is no simple way to instantiate a
new-style service here; nor in Java/C++, as the simple bootstrap
mechanism is broken in DEV300_m* - and I'm lazy to see if the
old/complex bootstrap works).

Regards
Ariel.




[1] User and share dirs

[fix line breakes when copy and paste]
'*********************************************************************

Sub PathSettings

        Dim oPathSettings as Object
        oPathSettings = createUnoService("com.sun.star.util.PathSettings")
        
        Dim sBasic$
        sBasic = oPathSettings.getPropertyValue("Basic")
        
'"file:///opt/openoffice.org/basis3.0/share/basic;file:///home/ariel/.openoffice.org3/user/basic"

        Dim sBasic_internal$()  
        sBasic_internal = oPathSettings.getPropertyValue("Basic_internal")
        '(0)="file:///opt/openoffice.org/basis3.0/share/basic"

        Dim sBasic_user$()
        sBasic_user = oPathSettings.getPropertyValue("Basic_user")
        'UBound=-1
        
        Dim sBasic_writable$
        sBasic_writable = oPathSettings.getPropertyValue("Basic_writable")
        '"file:///home/ariel/.openoffice.org3/user/basic"

End Sub

'************************************************************************


Sub OfficeInstallationDirectories

        Dim oOfficeInstDirs as Object
        oOfficeInstDirs =
createUnoService("com.sun.star.util.OfficeInstallationDirectories")
        
        Dim sOfficeInstDir$
        sOfficeInstDir = oOfficeInstDirs.getOfficeInstallationDirectoryURL()
        '"file:///opt/openoffice.org/basis3.0"

        Dim sOfficeUserData$
        sOfficeUserData = oOfficeInstDirs.getOfficeUserDataDirectoryURL()
        '"file:///home/ariel/.openoffice.org3"
        
        Dim sRelocatable$
        sRelocatable = oOfficeInstDirs.makeRelocatableURL(sOfficeUserData +
"/user/basic")
        '"$(userdataurl)/user/basic"
        
        Dim sAbsolute$
        sAbsolute = oOfficeInstDirs.makeAbsoluteURL(sRelocatable)
        '"file:///home/ariel/.openoffice.org3/user/basic"

End Sub


'****************************************************************************

Sub PathSubstitution
        
        Dim oPathSubstitution as Object
        oPathSubstitution = 
createUnoService("com.sun.star.util.PathSubstitution")
        
        Dim sVarSubst$
        
        '$(brandbaseurl) NOT YET AVAILABLE
        'See
http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&msgNo=1168
        'sVarSubst =
oPathSubstitution.getSubstituteVariableValue("$(brandbaseurl)")               
                
        '$(inst)    Installation path of the Office.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(inst)")
        '"file:///opt/openoffice.org/basis3.0"
        
        '$(prog)    Program path of the Office.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(prog)")
        '"file:///opt/openoffice.org/basis3.0/program"
        
        '$(user)    The user installation directory.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(user)")
        '"file:///home/ariel/.openoffice.org3/user"
        
        '$(work)    The work directory of the user.
        '                       Under Windows this would be the "MyDocuments" 
subdirectory.
        '                       Under Unix this would be the home-directory
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(work)")
        '"file:/home/ariel/Documentos"
        
        '$(home)    The home directory of the user.
        '                       Under Unix this would be the home- directory.
        '                       Under Windows this would be the "Documents and 
Settings\"
subdirectory.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(home)")
        '"file:///home/ariel"
        
        '$(temp)    The current temporary directory.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(temp)")
        '"file:///home/ariel/tmp"
        
        '$(path)    The value of PATH environment variable.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(path)")
        
'"file:///opt/openoffice.org3/program;file:///usr/bin;file:///bin;file:///usr/local/bin;file:///usr/X11R6/bin/;file:///usr/games;file:///usr/lib/qt4/bin;file:///home/ariel/bin"
        
        '$(lang)    The country code used by the Office, like 01=english,
49=german.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(lang)")
        '"01"
        
        '$(langid)  The language code used by the Office, like 0x0009=english,
0x0409=english us.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(langid)")
        '"1033"
        
        '$(vlang)   The language used by the Office as a string. Like "german"
for a german Office.
        sVarSubst = oPathSubstitution.getSubstituteVariableValue("$(vlang)")
        '"en-US"
        
        
End Sub


**********************************************************************
**********************************************************************
[2] theMacroExpander

Function expandMacros(sToExpand$)

        Dim oMacroExpander as Object    
        
        oMacroExpander =
GetDefaultContext().getValueByName("/singletons/com.sun.star.util.theMacroExpander")

        expandMacros =  = oMacroExpander.expandMacros(sToExpand)        
        
End Function



--
Ariel Constenla-Haile
La Plata, Argentina

[EMAIL PROTECTED]
[EMAIL PROTECTED]

http://www.ArielConstenlaHaile.com.ar/ooo/



"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to