Hi Rony,

[thanks for the flowers on your previous mail :-)  ]

Rony G. Flatscher escribió:
http://api.openoffice.org/docs/common/ref/com/sun/star/script/provider/Scri ptURIHelper.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;

I must admit that I don't know the exact meaning of "new-style service" but I've tried with createInstanceWithArguments on the service manager and it seems to work:
Studying your sample I transcribed it to ooRexx and tested the service with the "shortFormScriptURL", but also with the "scriptFullURL", which contains an expansion part, and the service processes both in the same manner.

The service's "getScriptURI()" always returns the short form script URL, which has a potential symbolic path part expanded already, which is very useful as well. But it seems as if there is a bug, if a library is involved (see below).

Just for the record (and because the student in cc: may need it) the ooRexx transcription:

   -- ***** ooRexx *****
   xContext = uno.connect()  -- connect to server and retrieve the XContext
oSM = xContext~getServiceManager -- retrieve XMultiComponentFactory

      /* create the service object */
   sSrvc = "com.sun.star.script.provider.ScriptURIHelper"

mArgs = uno.createArray(.bsf4rexx~string.class, 2) /* create a java.lang.String array */
   mArgs[1]="ooRexx"    /* assign first argument   */
   mArgs[2]="share"     /* assign second argument  */

oScriptURIHelper = oSM~createInstanceWithArgumentsAndContext(sSrvc,mArgs,xContext) xScriptURIHelper = oScriptURIHelper~XScriptUriHelper /* query its interface */

      /* query the storage URI of this language root directory */
   say xScriptURIHelper~getRootStorageURI

      /* define array of scriptURIs and query their storage URI */
   scriptURIS = .array~of( -
"vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share", - "vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=vnd.sun.star.expand:${$SYSBINDIR/bootstrap.ini::BaseInstallation}/share/Scripts/oorexx/Library1" )

   do scriptURI over scriptURIS
      say
      say pp(scriptURI)":"
      storageURI = xScriptURIHelper~getStorageURI(scriptURI)
      say "   " storageURI

         /* query script URI from its storage URI */
      scriptURI = xScriptURIHelper~getScriptURI(storageURI)
      say "   " scriptURI
   end

::requires uno.cls -- get the UNO support for ooRexx (exploiting the Java interfaces) Running the above program from the command line on WXP will yield as its output:

   E:\rony\dev\bsf\src\samples\OOo>testScriptUriHelper.rex
   file:///D:/Programme/OpenOffice.org%202.4/share/Scripts/oorexx

[vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share]: file:///D:/Programme/OpenOffice.org%202.4/share/Scripts/oorexx/Library1.metaDataInfosShare.rex vnd.sun.star.script:Library1.metaDataInfosShare.rex?language=ooRexx&location=share

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


as we have it in OOo Basic and ooRexx, here is in Java:

//***********************************************************************
import com.sun.star.uno.XComponentContext;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.script.provider.ScriptURIHelper;
import com.sun.star.script.provider.XScriptURIHelper;

/**
 *
 * @author ariel
 */
public class ScriptURIHelperDemo {


    /** Creates a new instance of ScriptURIHelperDemo */
    public ScriptURIHelperDemo() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            String[][] sScripts = {
                {
                    "Basic", "user",// Language, Location
                    "vnd.sun.star.script:Standard.Module1.Main?" +
                        "language=Basic&location=application"// Script URI
                },
                {
                    "BeanShell", "share",
                    "vnd.sun.star.script:HelloWorld.helloworld.bsh?" +
                        "language=BeanShell&location=share"
                },
                {
                    "JavaScript", "share",
                    "vnd.sun.star.script:HelloWorld.helloworld.js?" +
                            "language=JavaScript&location=share"
                },
                {
                    "Java", "share",
                    "vnd.sun.star.script:HelloWorld.HelloWorld.printHW?" +
                            "language=Java&location=share"
                },
                {
                    "Python", "share",

"vnd.sun.star.script:pythonSamples|TableSample.py$createTable?" +
                            "language=Python&location=share"
                }
            };

            // get the remote office component context
            XComponentContext xContext = Bootstrap.bootstrap();

            XScriptURIHelper xScriptURIHelper;
            String sLanguage, sLoc;

            for (String[] scripts : sScripts) {
                sLanguage = scripts[0];
                sLoc = scripts[1];

System.out.printf("*********************************************" +
                        "%n%s - %s%n%n", sLanguage, sLoc);

                xScriptURIHelper = ScriptURIHelper.create( xContext,
sLanguage, sLoc );

                System.out.printf("getRootStorageURI() - %s%n%n",
                        xScriptURIHelper.getRootStorageURI() );

                String sOriginalURI = scripts[2];
                String sStorageURI = xScriptURIHelper.getStorageURI(
sOriginalURI );
                String sScriptURI = xScriptURIHelper.getScriptURI(
sStorageURI );

                System.out.printf(
                        "script URI - %s%n" +
                        "getStorageURI() - %s%n" +
                        "getScriptURI() - %s%n%n",
                        sOriginalURI, sStorageURI, sScriptURI);
            }
        } catch (java.lang.Exception e) {
            e.printStackTrace();
        } finally {
            System.exit(0);
        }
    }
}

//***********************************************************************


the output in Linux/SuSe is

*********************************************
Basic - user

getRootStorageURI() - file:///home/ariel/.openoffice.org2/user/Scripts/basic

script URI -
vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=application
getStorageURI() -
file:///home/ariel/.openoffice.org2/user/Scripts/basic/Standard.Module1.Main
getScriptURI() -
vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=user

*********************************************
BeanShell - share

getRootStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/beanshell

script URI -
vnd.sun.star.script:HelloWorld.helloworld.bsh?language=BeanShell&location=share
getStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/beanshell/HelloWorld.helloworld.bsh
getScriptURI() -
vnd.sun.star.script:HelloWorld.helloworld.bsh?language=BeanShell&location=share

*********************************************
JavaScript - share

getRootStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/javascript

script URI -
vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share
getStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/javascript/HelloWorld.helloworld.js
getScriptURI() -
vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share

*********************************************
Java - share

getRootStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/java

script URI -
vnd.sun.star.script:HelloWorld.HelloWorld.printHW?language=Java&location=share
getStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/java/HelloWorld.HelloWorld.printHW
getScriptURI() -
vnd.sun.star.script:HelloWorld.HelloWorld.printHW?language=Java&location=share

*********************************************
Python - share

getRootStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/python

script URI -
vnd.sun.star.script:pythonSamples|TableSample.py$createTable?language=Python&location=share
getStorageURI() -
file:///opt/openoffice.org2.4/program/../share/Scripts/python/pythonSamples/TableSample.py$createTable
getScriptURI() -
vnd.sun.star.script:pythonSamples|TableSample.py$createTable?language=Python&location=share



Looking at the results of "getStorageURI()" the libarary name "Library1" should be delimited from the script's name "metaDataInfosShare" by the file separator character "/" (i.e., the dot would need to be turned into a slash).

Is this a bug or a feature?

in all the cases the "physical" LibraryContainer/Script [for example
user/basic/Standard/Module1.xba] seems to turns to
LibraryContainer.Script with getStorageURI()


* in OOo Basic
vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=application
turns to
file:///home/ariel/.openoffice.org2/user/Scripts/basic/Standard.Module1.Main
 instead of
file:///home/ariel/.openoffice.org2/user/Scripts/basic/Standard/Module1.Main

* BeanShell
vnd.sun.star.script:HelloWorld.helloworld.bsh?language=BeanShell&location=share
file:///opt/openoffice.org2.4/program/../share/Scripts/beanshell/HelloWorld.helloworld.bsh
instead of ../share/Scripts/beanshell/HelloWorld/helloworld.bsh

* JavaScript
vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share
file:///opt/openoffice.org2.4/program/../share/Scripts/javascript/HelloWorld.helloworld.js
instead of ../share/Scripts/javascript/HelloWorld/helloworld.js


* Java
vnd.sun.star.script:HelloWorld.HelloWorld.printHW?language=Java&location=share
file:///opt/openoffice.org2.4/program/../share/Scripts/java/HelloWorld.HelloWorld.printHW
instead of ../share/Scripts/java/HelloWorld/HelloWorld.printHW


The Python example may look special:

vnd.sun.star.script:pythonSamples|TableSample.py$createTable?language=Python&location=share
turns to
file:///opt/openoffice.org2.4/program/../share/Scripts/python/pythonSamples/TableSample.py$createTable

while the "real" location is
/opt/openoffice.org2.4/share/Scripts/python/pythonSamples/TableSample.py


The bottom line: I've no idea what rule it follows

* for using the dot instead of the slash
* for using "$" in the Python example instead of the point, as in
Standard.Module1.Main (instead of Standard.Module1$Main)

Another good question I didn't try yet is: what are we allowed to do
with this storage URI? can it be used with UCB methods to access the
storage?

I found this ScriptURIHelper looking for a better way to embedded Java
Archives (JARs) and Python scripts inside OOo documents, as the
Scripting Framework has left them alone [can ooRexx be also embedded
inside OOo docs.?]. Currently I'm using the embed API
(http://api.openoffice.org/docs/common/ref/com/sun/star/embed/module-ix.html)
to store the JAR and the parcel descriptor.

Another thing I didn't try is if/how the ScriptURIHelper works when the
script is located inside a document.


Regards
Ariel.

--
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