OpenOffice Python 宏:在哪里可以找到有用的文档?
我正在尝试为 OpenOffice Calc 制作一个宏,它将切换包含用户指定值的单元格的背景颜色。由于我不了解 OpenOffice Basic 并且无意学习它,所以我想用 Python 编写我的宏。
问题是,我找不到任何关于如何编写 Python 宏的有用文档。从我完成的阅读来看,我似乎无法设置一个动态环境,从中可以检查适当的对象本身,因此我只能依赖文档。我在哪里可以学习如何编写宏?
编辑:
我已经知道“Python 作为宏语言”,但它只回答了哪里放置Python文件。它没有提及 API、如何搜索和修改单元格等。
此外,也没有关于 XSCRIPTCONTEXT
的信息,OOo 显然将其作为全局变量提供。由于我无法交互式运行,因此我无法真正询问该变量来了解它。
编辑2:
我发现许多页面提供了一些信息,但它们要么非常不完整,要么假设对 UNO API 具有全面的预先存在的知识。到目前为止,我还没有发现任何有用的东西。我根本没有时间尝试学习整个 API,以便能够理解其中的一部分,尤其是因为我必须学习 C++,以便能够理解文档中使用的语法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经历了同样的动作,因此写了一篇博客文章与其他人分享我所学到的东西。遗憾的是现在(差不多六年后)文档和示例仍然如此稀缺。
要学习 api,请查看
dev.py
中的两个辅助函数https ://onesheep.org/scripting-libreoffice-python/
关于您探索 XSCRIPTCONTEXT 的具体需要 - 通过套接字运行时它不可用,但您可以在此处探索该界面:
http://www.openoffice。 org/api/docs/common/ref/com/sun/star/script/provider/XScriptContext.html
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