You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by "Rony G. Flatscher (Apache)" <ro...@apache.org> on 2012/07/08 17:43:50 UTC

Ad scripting languages (Re: OpenOffice in Java

Hi Andreas,

On 07.07.2012 17:36, Andreas Säger wrote:
> Am 06.07.2012 16:26, Rony G. Flatscher (Apache) wrote:
>> In addtion, the very important AOO scripting framework is totally Java based.
>
> Why can I run all non-Java macros on a machine with no Java?
>
not sure, what you are after.

AFAIK, originally there was "StarBasic" implemented as the scripting language for OpenOffice (later
renamed to "OpenOffice.org Basic") and part of it.

Then, later, Python got added as a scripting language, by implementing a Python UNO binding.

That was it for quite some time as it is everything else but a trivial task to create the
infrastructure to add a new scripting language to OpenOffice from scratch for programmers who might
have no working knowledge about the UNO framework.

Then later (2004?, 2005?), a Java scripting framework got added to OpenOffice.

This Java scripting framework allowed in the first place to finally add JavaScript (Rhino, a very
popular Java implemenation of JavaScript) as a scripting language to OpenOffice.

In addtion BeanShell ("interpreted Java") was added as an additional scripting languages to
OpenOffice as well taking advantage of the new Java scripting framework.

Because there has been a Java scripting framework for OpenOffice it has become a feasible job to add
any scripting language to OpenOffice for which a Java implementation existed, without the need of an
intimate knowledge of the UNO framework. A feasible example of adding scripting languages to
OpenOffice via the Java scripting framework would be all the Apache BSF scripting languages (cf.
<http://commons.apache.org/bsf/>). Starting with Java 1.6 the "javax.script" package got introduced
into Java which could be used to add new scripting languages to OpenOffice as well, using the
existing Java scripting framework.

The interesting thing here is, that one can use the Java scripting framework for OpenOffice also for
scripting languages, that are implemented in C++, believe it or not!

This may sound strange, but in effect, this is simpler than starting from scratch to create some UNO
binding for a new scripting language for programmers who have no intimate knowledge of the UNO
framework and its implementations. An example for such a possibility is the oxt-package that adds
the opensource and "human centric" scripting language ooRexx (cf. <http://www.ooRexx.org>) to
OpenOffice using Java as the bridge (there is an ooRexx package, that has extensive Java support via
JNI for ooRexx, camouflaging all of Java as the dynamically typed, caseless programming language
ooRexx, and does so successfully and fast, cf. <http://sourceforge.net/projects/bsf4oorexx/>, the
oxt-package is part of the distribution and gets automatically installed with BSF4ooRexx, if
OpenOffice is installed on the machine).

---

Two years ago, there was a presentation of an OpenOffice introspection tool implemented in ooRexx,
which can be used interactively or via all the OpenOffice scripting languages via the dispatch
interface, which is able to create great overviews of the UNO objects (and/or UNO classes) you have
in hand, including links that lead to the OpenOffice API documentation on the Internet. Here is a
link to a brief tutorial which might be interesting for OpenOffice developers, hence giving links to
the slides, the brief tutorial on how to use it from OpenOffice.org Basic, Java, JavaScript, ooRexx,
and Python:

  * slides:
      o <http://wi.wu.ac.at/rgf/rexx/misc/OOoCon/2010_Budapest/UNO%5fAPI%5fInfo%2dOOoCon%2d20100902%2epdf>

  * tutorial/readme:
      o <http://wi.wu.ac.at/rgf/rexx/misc/OOoCon/2010_Budapest/read%2dme%2dUNO%5fAPI%5finfo%2ehtml%2epdf>

  * result of introspecting an UNO writer object on-the-fly, one level only, yielding 11 pages of
    documentation:
      o <http://wi.wu.ac.at/rgf/rexx/misc/OOoCon/2010_Budapest/UNO%5fAPI%5fINFO%2dcom%2esun%2estar%2edocument%2eOfficeDocument%2bcom%2e%2e%2e%2d2010%2d08%2d29T23%5f11%5f12%2e592000%2epdf>

  * result of introspecting an UNO writer object on-the-fly, two levels, yielding 55 (!) pages of
    documentation:
      o <http://wi.wu.ac.at/rgf/rexx/misc/OOoCon/2010_Budapest/UNO%5fAPI%5fINFO%2dcom%2esun%2estar%2edocument%2eOfficeDocument%2bcom%2e%2e%2e%2d2010%2d08%2d29T23%5f11%5f27%2e749000%2epdf>

As you (hopefully) see, having a Java based scripting framework is a boon for OpenOffice. It
allows/enables programmers to rather quickly make a scripting language available to OpenOffice
taking advantage of the Java scripting framework.

---rony