You can create a Library Module in a Document to hold Basic macros, and using the APSO extension the same for Python macros.
Is it possible to do the same fot Javascript macros and if so how?
[Solved] Embed Javascript Macro in Document Module
[Solved] Embed Javascript Macro in Document Module
Last edited by peterwt on Sat Dec 23, 2017 7:48 pm, edited 1 time in total.
Peter
LibreOffice 4.4.1.2 on Windows 8
LibreOffice 4.4.1.2 on Windows 8
Re: Embed Javascript Macro in Document Module
Also asked at AskLibreOffice
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Re: Embed Javascript Macro in Document Module
With or without APSO for Python you can simply embed the script under Script/python/ and add something like the following to META-INF/manifest.xml
These 3 entries declare the full path Scripts/python/XTableSQL.py plus each path element Scripts/python/ and Scripts/ as part of the document.
I would think that the same works with JavaScript and Beanshell macros as well.
Code: Select all
<manifest:file-entry manifest:media-type="" manifest:full-path="Scripts/python/XTableSQL.py"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/python/"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/"/>
I would think that the same works with JavaScript and Beanshell macros as well.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Embed Javascript Macro in Document Module
Indeed, it works as expected. I just tried with the helloworld.js that is shipped with the office suite. I added the Script/javascript/HelloWorld/ directory with the code and another file parcel-descriptor.xml to a Writer document, added 5 entries (2 files and 3 path elements) to META/manifest.xml and a push button to call the embedded macro.
- Attachments
-
- HelloWorld.js_embedded.odt
- Embedded JavaScript macro
- (10.63 KiB) Downloaded 257 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Embed Javascript Macro in Document Module
I noticed looking at the scripts supplied with LO that the beanshell, java, and javascript scripts were in a directory for each script. The directory had the script and a parcel-descriptor.xml file. I wasn't sure if the parcel-descriptor had to be included in the manifest.xml. The example you included shows all i needed.
I also posted this question in ask.libreoffice.org and had a similar reply from Jim K. He included an example which also shows how to call the Javascript from a Basic macro in the same document. So you can include macros in different languages in the same document. I have attached this example.
Peter
LibreOffice 4.4.1.2 on Windows 8
LibreOffice 4.4.1.2 on Windows 8