Jens Tröger wrote: > I use LO for document analysis (not conversion), i.e. I need to load a > document and poke its styles and also extract some content. This > *should* run without any GUI because we don't even have the X libs > installed on Linux; works ok so far. That exact same approach on Mac > *always* pops open a window, which has irritated me for a while. Good > you mention that this might be broken. If you run LO on the Mac as a service with --headless and you open a doc from a script with "Hidden=True", no window will pop up. If the document is open long enough (for example if you put a sleep in the script) you can see from the doc that there is an invisible window. From the Dock you can open that window. It does have the document filename as title, but it doesn't contain the document. It is a kind of strange window. Here is a script that extracts the text from a Writer document. Start LO as /Applications/LibreOffice.app/Contents/MacOS/soffice '--accept=socket,host=localhost,port=2002;urp;StarOffice.Servicemanager' --headless
and run the script with LO's Python: import uno from unohelper import systemPathToFileUrl from com.sun.star.beans import PropertyValue from os.path import realpath localContext = uno.getComponentContext() resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext") desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context) loadURL = systemPathToFileUrl(realpath("test.odt")) inProps = PropertyValue( "Hidden" , -1 , True, 0 ), # 1-tuple! textdoc = desktop.loadComponentFromURL(loadURL, "_blank", 0, inProps); print(textdoc.Text.String) textdoc.close(True) -- Piet van Oostrum <p...@vanoostrum.org> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice