Control Libreoffice Impress from Python

前端 未结 3 2086
遥遥无期
遥遥无期 2021-01-25 16:17

Im writing an application oriented to speakers and conferences. Im writing it with Python and focused on Linux.

I would like to know if its possible to control LibreOffi

3条回答
  •  耶瑟儿~
    2021-01-25 16:53

    The answer from @user3159253 describes how to connect to a presentation file, which is the first part of your question. Then, to control the presentation you will need to use XPresentation2 and XSlideShowController. Here is some code to do this, using the doc variable from the other example:

    def runSlideShow(doc):
        presentation = doc.getPresentation()
        presentation.start()
        while not presentation.isRunning():
            pass
        presentation_controller = presentation.getController()
        presentation_controller.gotoNextSlide()
        print("isRunning() == %s" % presentation_controller.isRunning())
    

    I adapted this code from http://openoffice.2283327.n4.nabble.com/XPresentation2-returns-a-null-XSlideShowController-td2771599.html.

    Responding to your comment: You need to add the following towards the bottom of the code, similar to what is in highlight.py. Did you try running the impress-code-highlighter example?

    def do_runSlideShow(*args):
        ctx = XSCRIPTCONTEXT
        doc = ctx.getDocument()
        runSlideShow(doc)
    
    g_exportedScripts = (do_runSlideShow,)
    if __name__ == "__main__":
        doc = remote_get_doc()
        runSlideShow(doc)
    

提交回复
热议问题