UPDATE 19/09: it seems that some people had misunderstood the post title, so here is a clarification: I’m not comparing Word with OpenOffice or something like that, the title refers to the design choices of OpenOffice in using Python 2.6 as an option for scripting language, it’s a humorous title and should not be considered in literal sense.
This is a very simple, but powerful, Python script to call Google Sets API (in fact it’s not an API call – since Google doesn’t have an official API for Sets service – but an interesting and well done scraper using BeautifulSoup) inside the OpenOffice 3.1.1 Writer… anyway, you can check the video to understand what it really does:
And here is the very complex source-code:
from xgoogle.googlesets import GoogleSets def growMyLines(): """ Calls Google Set unofficial API (xgoogle) """ doc = XSCRIPTCONTEXT.getDocument() controller = doc.getCurrentController() selection = controller.getSelection() count = selection.getCount(); text_range = selection.getByIndex(0); lines_list = text_range.getString().split("\n"); gset = GoogleSets(lines_list) gset_results = gset.get_results() results_concat = "\n".join(gset_results) text_range.setString(results_concat); g_exportedScripts = growMyLines,
You need to put the “xgoogle” module inside the “OpenOffice.org 3\Basis\program\python-core-2.6.1\lib” path, and the above script inside “OpenOffice.org 3\Basis\share\Scripts\python”.
I hope you enjoyed =) with new Python 2.6 core in OpenOffice 3, they have increased the productivity potential at the limit.