Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenOffice Python macros: Where can I find useful documentation?

I'm trying to make a macro for OpenOffice Calc that will toggle the background color of cells containing a user-specified value. Since I don't know OpenOffice Basic and have no desire to learn it, I'd like to write my macro in Python.

The trouble is, I can't find any useful documentation on how to write Python macros. From the reading I've done, it appears that I can't set up a dynamic environment from where I can examine the appropriate object(s) themselves, so I'll have to rely solely on documentation. Where can I learn how to write my macro?

EDIT:

I already know about "Python as a Macro Language," but it only answers where to put Python files. It says nothing about the API, how to search for and modify cells, etc.

In addition, there's no information about XSCRIPTCONTEXT, which OOo apparently provides as a global variable. Since I can't run interactively, I can't really interrogate that variable to learn about it.

EDIT 2:

I've found a number of pages that give bits and pieces of info, but they're either terribly incomplete or they assume a comprehensive pre-existing knowledge of the UNO API. So far, I haven't found anything useful. I simply don't have the time to try to learn the entire API just so I can understand one portion of it--especially since I'd have to learn C++ just so I could understand the syntax used in the documentation.

like image 624
Scott Severance Avatar asked May 10 '11 00:05

Scott Severance


1 Answers

I went through the same motions and so wrote a blog post to share with others what I have learned. Pity that now (almost six years later) the documentation and examples are still so scarce.

For learning the api, check out the two helper functions in dev.py

https://onesheep.org/scripting-libreoffice-python/

About your specific need to explore XSCRIPTCONTEXT - it is not available when running through the socket, but you can explore the interface here:

http://www.openoffice.org/api/docs/common/ref/com/sun/star/script/provider/XScriptContext.html

like image 150
Jannie Theunissen Avatar answered Oct 15 '22 09:10

Jannie Theunissen