Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is there a LibreOffice BASIC (or other) REPL interactive shell?

I am on Ubuntu 14.04, LibroOffice 4.2.8.2. Does this - or any other later version - have a possibility for a BASIC REPL shell? That is, some form of a terminal program, where I could type stuff like rg = ThisComponent.CurrentSelection, and then inspect the variable rg?

I'm guessing, python could probably be used in this role somehow, instead of BASIC - note that in Ubuntu 14.04, I did:

sudo apt-get install libreoffice-script-provider-python

This installs a script /usr/lib/libreoffice/program/pythonscript.py, but if I run it, it fails:

$ python2.7 /usr/lib/libreoffice/program/pythonscript.py
Traceback (most recent call last):
  File "/usr/lib/libreoffice/program/pythonscript.py", line 19, in <module>
    import uno
ImportError: No module named uno

$ sudo apt-get install python-uno
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-uno is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libreoffice-script-provider-python

E: Package 'python-uno' has no installation candidate

$ apt-show-versions -R python.*uno
python3-uno:amd64/trusty-security 1:4.2.8-0ubuntu5.1 uptodate
python3-uno:i386 not installed

So, there is only a python3 module of uno on this OS; still, even if I'd get an interactive shell with:

$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> print(uno)
<module 'uno' from '/usr/lib/python3/dist-packages/uno.py'>
>>> dir(uno)
['Any', 'Bool', 'ByteSequence', 'Char', 'Enum', 'Type', '__builtin__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_g_ctx', '_g_delegatee', '_impl_extractName', '_uno_extract_printable_stacktrace', '_uno_import', '_uno_struct__eq__', '_uno_struct__getattr__', '_uno_struct__init__', '_uno_struct__repr__', '_uno_struct__setattr__', '_uno_struct__str__', 'absolutize', 'createUnoStruct', 'fileUrlToSystemPath', 'generateUuid', 'getClass', 'getComponentContext', 'getConstantByName', 'getCurrentContext', 'getTypeByName', 'invoke', 'isInterface', 'os', 'pyuno', 'setCurrentContext', 'socket', 'sys', 'systemPathToFileUrl', 'unicode']
>>>

... I still don't know what (if anything) can I use to "get" a currently open document, or a selection in it - what could I use here?