Hi Paolo,
Paolo Mantovani wrote:
Hi Ariel,
Il sabato 14 giugno 2008 22:13:45 Ariel Constenla-Haile ha scritto:
[....]
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
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?
Regards,
---rony