According to LibreOffice: SequenceInputStream Service Reference, the SequenceInputStream service should have a createStreamFromSequence() method, which I would like to use to initialize an instance with some byte data. Unfortunately, when I do actually try to call that method, the mentioned runtime error is triggered.
function BytesToString(data() as variant, _
optional encoding as string) as string
dim istrm as object
dim tstrm as object
dim var as variant
if IsMissing(encoding) then
encoding = "utf-8"
end if
istrm = CreateUnoService("com.sun.star.io.SequenceInputStream")
'- runtime ERROR: property or method not found: createStreamFromSequence
istrm.createStreamFromSequence(data)
tstrm = CreateUnoService("com.sun.star.io.TextInputStream")
tstrm.setInputStream(istrm)
tstrm.setEncoding(encoding)
var = tstrm.isEOF()
'var = tstrm.readLine()
var = tstrm.readString(Array(), false)
tstrm.closeInput()
BytesToString = var
end function
sub TestSub()
dim var as variant
var = Array(97,98,99)
var = BytesToString(var)
exit sub
end sub
When I write the value of istrm.dbg_methods to a file, I can confirm that the createStreamFromSequence() method is not among the methods in that listing. However, there is an initialize() method which seems to originate from a base class - calling it using “initialize(data)” will fail due to an IllegalArgumentException.
So what is the problem?!?
- Do I need to call the createStreamFromSequence() method in a different way because it is a “Public Member Function” that isn’t part of an actual interface? That method seems to be a direct service method?
- Is it a bug because that method isn’t available, even though it should be?
Version: 24.8.0.3 (X86_64) / LibreOffice Community
Build ID: 0bdf1299c94fe897b119f97f3c613e9dca6be583
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: de-DE (en_US.UTF-8); UI: en-US
Calc: threaded