Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


On Wed, Feb 15, 2017 at 12:12 PM, Gergely Buday <
buday.gergely@uni-eszterhazy.hu> wrote:

Where in the Libre Office source tree I can find the glue code for various
extension languages?


I do not remember the code locations, but I once had a look at Java and
Python bindings. For python, some (most, almost all?) classes are generated
dynamically at runtime (so you get no code completion in IDE). For Java,
there is some hand-written glue code and the rest are generated jar files
(it directly generates jars from the IDL without intermediate Java sources;
method parameter names are not specified in the jars, so you get some code
completion, but it is not great.)

There are manual attempts to write nicer, more human friendly bindings, I
saw something e.g. for python when I searched Pypi. Not sure how
comprehensive they are; it possibly covers only what the original author
needed covered...



Another option is to use Scala as it is possible to write extensions in
Java and Scala can use Java libraries.



Did anybody write a Libre Office extension in Scala?


I was looking into writing a macro[1] in Kotlin. It is not ML, but it has
some syntactic elements borrowed from that tradition... One nice thing you
can do in Kotlin (that you cannot in Java) is create extension function

fun <T> Any.query(anInterface: Class<T>): T {
// TODO: taking KClass did not work for me
return UnoRuntime.queryInterface(anInterface, this)
}

and then you can do

val sheets = xScriptContext.document.query(com.sun.star.sheet.XSpreadshee
tDocument::class.java)

instead of

val sheets = UnoRuntime.queryInterface(com.sun.star.sheet.XSpreadsheetDoc
ument::class.java, xScriptContext.document)

Neither is spectacularly readable, but choosing from the two, the first is
IMO nicer.

Also, I have a gradle task to compile and push the macro to my libreoffice
directory, so I can recompile and redeploy it into running Calc in about 5
seconds. Not spectacular either, but it is as good as I was able to get
given I have to have a compilation step.

[1] https://github.com/msgqe/doccheck
-- 
Jiří Daněk

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.