Load document from stdin instead of an URL

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Load document from stdin instead of an URL

Post by _savage »

In order to load a document by a script into an office instance, I currently use the loadComponentFromURL() from the XComponentLoader interface. However, this accepts only a URL as parameter.

Is there a way to read a document directly from stdin? Or: can I pipe data into office?
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Load document from stdin instead of an URL

Post by RoryOF »

There is discussion on this at
http://unix.stackexchange.com/questions ... -via-stdin

Other searches suggest the best way (=simplest) may be to make a file of the data and then to open that automatically in OpenOffice.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Re: Load document from stdin instead of an URL

Post by _savage »

Hmpf. Looks like files only...

I wonder if I could pass a local /dev/stdin as a URL. No, can't:

Code: Select all

Unsupported URL <file:///dev/stdin>: "type detection failed"
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Re: Load document from stdin instead of an URL

Post by _savage »

I came across this thread today which uses a byte array of the file and converts it to an input stream that's then loaded. Looks to me like an appropriate solution? Only problem is that I can't quite figure out how the ByteArrayXInputStreamAdapter is accessible with Python UNO, or if this is something I'd have to implement and provide myself.
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
Post Reply