I'm trying to create an .odt document just using python. But, I'm completely stuck for the moment, and this main goal seems to be still a long way to go...
I'm using a mac os x 10.9.5 computer, and my AOO version is the 4.1.1
Let me explain what I have done.
First of all, I've opened a terminal to launch OpenOffice, with the following:
Code: Select all
$ cd ../../Applications/OpenOffice.app/Contents/MacOS/
$ ./soffice.bin -headless -nofirststartwizard -accept="uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"
Secondly, I open an other terminal, go in the same folder than in the first terminal, then launch python, import the uno package and declare a class whose goal is to create OpenOffice easily. Here is the code:
Code: Select all
$ cd ../../Applications/OpenOffice.app/Contents/MacOS/
$ python
>>> import uno
>>> class UnoClient:
... def __init__(self):
... localContext = uno.getComponentContext()
... resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
... self.smgr = resolver.resolve("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager")
... def create_document(self, app):
... remoteContext = self.smgr.getPropertyValue("DefaultContext")
... desktop = self.smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)
... url = "private:factory/{0}".format(app)
... return desktop.loadComponentFromURL(url,"_blank", 0, () )
Finally, I'm trying to declare a UnoClient objet by
Code: Select all
unoClient = UnoClient()
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in __init__
__main__.NoConnectException: Connector : couldn't connect to socket (Undefined error: 0)
Thanks very much for all your answer,
Tolliob