Hi Christoph,
Christoph Lutz wrote:
Hi,
I have got a question regarding the scripting-framework and uno-packages and I hope this is the correct list since the list [EMAIL PROTECTED] seems to be inactive. If not, please hint me to the correct list.
I want to deploy and invoke scripting-framework-macros within uno-packages. After installing a package via "unopkg add", the invokation of the macro is done via a URL that I pass to the swriter-command in the commandline. Thus I am convinced to have everything done like documented in the Developers Guide (OOo 2), I get an error message "Library Library1 not found!" and the macro doesn't start.
Let me try to describe how I got there:
1) I used the default "HelloWorld"-macro one gets when createing a new BeanShell-macro using Tools->Macros->Organize Macros-->BeanShell / create... I stored the macro called "Macro1.bsh" in the "Library1" and attached it to a new writer-document.
2) I stored the writer document and extracted the directory "Scripts/BeanShell/Library1" from the zipped document.
These steps are just to get a valid test-macro "Macro1.bsh" in a valid "Library1" with a valid parcel-descriptor.xml. The next steps are about to create a simple uno-package that provides the macro:
3) I created a new temporary directory as a container for my new uno-package. I copied the extracted directory "Library1" into the new temporary directory.
4) Now I created a new directory called "META-INF" within the temporary directory and added the following manifest.xml-file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
<manifest:manifest>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.framework-script" manifest:full-path="Library1"/>
</manifest:manifest>
This structure is as documented on page 1075 in the DevGuide 2.
5) I bundled (zipped) the files in the temporary directory to "test.uno.pkg" and installed the package using "unopkg add <pathto>/test.uno.pkg". A subsequent "unopkg list" produced the following output:
C:\Program Files\OpenOffice.org 1.9.79\program>unopkg list
all deployed user packages:
Name: test.uno.pkg
URL: vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/A.tmp_/test.uno.pkg
is registered: yes
Media-Type: application/vnd.sun.star.package-bundle
Description: UNO Package Bundle
bundled Packages: {
Name: Library1
URL: vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/A.tmp_/test.uno.pkg/Library1
is registered: yes Media-Type: application/vnd.sun.star.framework-script Description: BeanShell Bibliothek }
6) now I tried to invoke the new macro using the following URL-parameter-string for the swriter command:
C:\Program Files\OpenOffice.org 1.9.79\program>swriter "vnd.sun.star.script:Library1.Macro1.bsh?language=BeanShell&location=user:uno_package/test.uno.pkg"
the macro can be invoked by
C:\Program Files\OpenOffice.org 1.9.79\program>swriter "vnd.sun.star.script:Library1.Macro1.bsh?language=BeanShell&location=user:uno_packages/test.uno.pkg"
There was only a simple typo, you wrote 'uno_package' instead of 'uno_packages'. Nevertheless the macro won't run, but the office unfortunately crashes. I wrote #i49388# for the crash.
I got the following error-messages (translated from the german version):
A scripting-framework error occured when trying to execute the BeanShell script Macro1.bsh
Message: Library Library1 not found.
The URL-string I used is documented on Page 1067 in the DevGuide 2, so I think it should be correct.
Have I done something wrong or can you confirm I have done everything correct, so I can submit a bug?
Every hints are welcome! Today I used OOo 1.9.m79 but I had the same experience with version 1.9.m100.
Thank you very much!
best regards, Christoph Lutz
Even after #i49388# is fixed, please be aware of the fact, that your macro won't run in the context of your document. Invoking macros from commandline is done asynchronously, which means that the macro might run before the document is fully loaded. If you want to run the macro in the document context, add the macro to your document and create an event binding.
Thomas
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
