What is getDesktop () ?

Usually the first statement, when scripting with python to work on a LibreOffice document, would be:
desktop = XSCRIPTCONTEXT.getDesktop()

getDesktop() is a method of the object XSCRIPTCONTEXT and returns the Desktop Reference on which our script can interact with. This reference is the main interface of the Desktop Service.

It allows to access useful methods from the Desktop interface like getCurrentComponent() or getComponents(). The ‘current Component’ being the active document on which you will be able to work directly, for example editing text or cells.

Still hungry?

The getDesktop() method is a method of class ScriptContext and is define in pythonscript.py. You can find pythonscript.py in /lib/libreoffice/program on Linux, probably in a similar path on MacOs and in C:\Program Files\LibreOffice\program on Windows (standard install).

Leave a Comment

Your email address will not be published. Required fields are marked *