https://issues.apache.org/ooo/show_bug.cgi?id=119935
Priority: P3
Bug ID: 119935
Assignee: [email protected]
Summary: private:stream - load component from ByteArray crashes
aoo34
Severity: critical
Issue Type: DEFECT
Classification: Code
OS: Windows, all
Reporter: [email protected]
Hardware: PC
Status: CONFIRMED
Version: AOO 3.4.0
Component: scripting
Product: framework
playing with the macro below i noticed aoo3.4 (and oo3.3, lo 3.5.4) will crash
suddenly while oo 3.2 works fine:
steps to reproduce:
- run macro "Test_loadComponentFromByteArray"
- close new document (sometomes you have to run twice,
or close another open document)
- crash
'http://www.oooforum.org/forum/viewtopic.phtml?t=43637
'by ms777
'demonstrates loading a document from byte array
'we start with a simple one: a byte array, every second byte is a tab char
Sub Test_loadComponentFromByteArray
aProps = CreateDefaultMediaDescriptor()
aBytes = Array(72,9,69,9,76,9,76,9,79)
oTmpDoc = loadComponentFromByteArray(aBytes, "_default", 0, aProps)
End Sub
Function loadComponentFromByteArray(aBytes as Any, sFrameName as String,
lSearchFlags as Long, aPropsT as Object) as Object
'create a temporary storage
oStorageFac = createUnoService("com.sun.star.embed.StorageFactory")
oStorage = oStorageFac.createInstance()
oStream = oStorage.openStreamElement("ms777",
com.sun.star.embed.ElementModes.WRITE)
'now write the byte array to the stream
oStream.WriteBytes(aBytes)
oStream.flush
oStream.closeOutput
oStream.dispose
'open the stream again, now for seekable reading
oStream = oStorage.openStreamElement("ms777",
com.sun.star.embed.ElementModes.SEEKABLEREAD)
aProps = AddInputStreamToMediaDescriptor(oStream, aPropsT) ' func name says
all ...
'now load it
loadComponentFromByteArray =
StarDesktop.loadComponentFromURL("private:stream", "_default", 0, aProps)
End Function
'two little helpers for both examples
Function CreateDefaultMediaDescriptor() as Object
Dim aProps(1) as new com.sun.star.beans.PropertyValue
aProps(0).Name = "FilterOptions"
aProps(0).Value = ""
aProps(0).Value = "9,0,0,1" 'tab separated
aProps(1).Name = "FilterName"
aProps(1).Value = "Text - txt - csv (StarCalc)"
CreateDefaultMediaDescriptor = aProps()
End Function
Function AddInputStreamToMediaDescriptor(oStream as Object, aPropsT as Object)
as Object
'copy the MediaDescriptor, add the InputStream
lUBound = UBound(aPropsT)
Dim aProps(lUBound+1) as new com.sun.star.beans.PropertyValue
For k=0 to lUBound
aProps(k).Name = aPropsT(k).Name
aProps(k).Value = aPropsT(k).Value
Next k
aProps(lUBound+1).Name = "InputStream"
aProps(lUBound+1).Value = oStream
AddInputStreamToMediaDescriptor = aProps()
End Function
--
You are receiving this mail because:
You are the assignee for the bug.