]>
Git — Sourcephile - reloto-libreoffice.git/blob - connect_to_libre_office.py
4 # get the uno component context from the PyUNO runtime
5 localContext
= uno
.getComponentContext()
7 # create the UnoUrlResolver
8 resolver
= localContext
.ServiceManager
.createInstanceWithContext(
9 "com.sun.star.bridge.UnoUrlResolver", localContext
)
11 # connect to the running office
12 context
= resolver
.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
13 manager
= context
.ServiceManager
15 # get the central desktop object
16 desktop
= manager
.createInstanceWithContext("com.sun.star.frame.Desktop", context
)
18 # access the current writer document
19 return (desktop
.getCurrentComponent(), context
)