2

至少在 Linux 上为 LibreOffice / OpenOffice 开发 Python 宏时,我读到您必须将 py 脚本放在特定目录中。

Python LibreOffice/OOo 开发人员是否有部署这些脚本的首选方法,或者是否有另一种方法可以在 LibreOffice/OOo 中指定您希望这些脚本的位置?

4

2 回答 2

1

也许一个不错的方法是熟悉 Python 设置工具本身(http://packages.python.org/an_example_pypi_project/setuptools.html),并编写一个适当的 setup.py 脚本,将所有需要的文件放在适当的目录

您的宏甚至可以使用“easy_install”Python 框架安装

于 2012-05-24T18:51:47.997 回答
-1

为避免重新加载已更改的宏(即使将其部署到正确的文件夹),您可以让 LibreOffice 在开发期间侦听套接字:

import uno

def getModel():
    # get the uno component context from the PyUNO runtime
    localContext = uno.getComponentContext()

    # create the UnoUrlResolver
    resolver = localContext.ServiceManager.createInstanceWithContext(
    "com.sun.star.bridge.UnoUrlResolver", localContext)

    # connect to the running office
    context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
    manager = context.ServiceManager

    # get the central desktop object
    desktop = manager.createInstanceWithContext("com.sun.star.frame.Desktop", context)

    # access the current writer document
    return desktop.getCurrentComponent()

我在这篇文章中解释了当你准备好部署时如何替换这个开发道具

于 2017-02-08T09:05:19.030 回答