When I start office as
soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
I can then choose
File → Open…, and open a document in a completely new window. The code I know and have found everywhere, which is:
#!python import uno # run libreoffice as: # soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager" def connectToLo(): # get the uno component context from the PyUNO runtime localContext = uno.getComponentContext() resolver = localContext.ServiceManager.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", localContext ) # connect to the running office ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" ) smgr = ctx.ServiceManager desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx) return desktop.getCurrentComponent() model = connectToLo()
returns a descriptor of the currently focused instance, whichever it is. But in my current task I need to open 2 windows (Calc and Impress), and work with them simultaneously. How do I do that?