简体   繁体   English

OpenOffice Python宏:我在哪里可以找到有用的文档?

[英]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. 我正在尝试为OpenOffice Calc创建一个宏,它将切换包含用户指定值的单元格的背景颜色。 Since I don't know OpenOffice Basic and have no desire to learn it, I'd like to write my macro in Python. 由于我不知道OpenOffice Basic并且不想学习它,我想用Python编写我的宏。

The trouble is, I can't find any useful documentation on how to write Python macros. 麻烦的是,我找不到任何有关如何编写Python宏的有用文档。 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. 我已经知道“ Python作为宏语言 ”,但它只回答了放置Python文件的位置。 It says nothing about the API, how to search for and modify cells, etc. 它没有说明API,如何搜索和修改单元格等。

In addition, there's no information about XSCRIPTCONTEXT , which OOo apparently provides as a global variable. 此外,没有关于XSCRIPTCONTEXT的信息,OOo显然将其作为全局变量提供。 Since I can't run interactively, I can't really interrogate that variable to learn about it. 由于我无法以交互方式运行,因此我无法真正询问该变量以了解它。

EDIT 2: 编辑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. 我发现了一些页面提供了一些信息,但它们要么非常不完整,要么假设有一个全面的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. 我根本没有时间尝试学习整个API,因此我可以理解它的一部分 - 特别是因为我必须学习C ++才能理解文档中使用的语法。

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 要学习api,请查看dev.py的两个辅助函数

https://onesheep.org/scripting-libreoffice-python/ 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: 关于您探索XSCRIPTCONTEXT的特定需求 - 在通过套接字运行时它不可用,但您可以在此处浏览界面:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM