[Solved] Py implementation of Java ByteArrayXInputStream...
[Solved] Py implementation of Java ByteArrayXInputStream...
I'm trying to follow this example, but I haven't quite figured out how to use a byte[] as an input stream in Python. In Java there seems to exist an adapter called ByteArrayToXInputStreamAdapter. Does an equivalent exist for the Python implementation?
Last edited by _savage on Mon Oct 19, 2015 7:51 am, edited 1 time in total.
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
Re: Python implementation of Java's ByteArrayXInputStreamAda
UNO module c.s.s.io provides XInputStream and XOutputStream
http://www.openoffice.org/api/docs/comm ... tream.html
http://www.openoffice.org/api/docs/comm ... tream.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Python implementation of Java's ByteArrayXInputStreamAda
Thanks, I saw those. But being interface declarations I still would have to come up with a class that implements these interfaces. What I was asking in my original question was if there is already a Python equivalent for this Java implementation ByteArrayXInputStreamAdapter. Might that even be part of the shipping UNO blob?Villeroy wrote:UNO module c.s.s.io provides XInputStream and XOutputStream
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
Re: Python implementation of Java's ByteArrayXInputStreamAda
This is beyond my knowledge.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Python implementation of Java's ByteArrayXInputStreamAda
Sometimes com.sun.star.io.SequenceInputStream service can be used to this task.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: Python implementation of Java's ByteArrayXInputStreamAda
hanya: funny you say that! I just stumbled upon this code which uses the SequenceInputStream service And based on that example, here's something that works for me:
Now I can just use that stream.
Code: Select all
# Read the content of a file as byte[]
def _file2bytes(fname):
with open(fname, "rb") as f:
return f.read()
# Create an XInputStream implementation from a byte[]
def _file2istream(fname):
fbytes = _file2bytes(fname)
istream = context.ServiceManager.createInstanceWithContext("com.sun.star.io.SequenceInputStream", context)
istream.initialize((uno.ByteSequence(fbytes),))
return istream
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.