( XStream xStream,
String sStreamName,
String sMediaType,
boolean bCompressed,
byte[] pBytes )
| 36 | } |
| 37 | |
| 38 | public boolean WriteBytesToStream( XStream xStream, |
| 39 | String sStreamName, |
| 40 | String sMediaType, |
| 41 | boolean bCompressed, |
| 42 | byte[] pBytes ) |
| 43 | { |
| 44 | // get output stream of substream |
| 45 | XOutputStream xOutput = xStream.getOutputStream(); |
| 46 | if ( xOutput == null ) |
| 47 | { |
| 48 | Error( "Can't get XOutputStream implementation from substream '" + sStreamName + "'!" ); |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | // get XTruncate implementation from output stream |
| 53 | XTruncate xTruncate = UnoRuntime.queryInterface( XTruncate.class, xOutput ); |
| 54 | if ( xTruncate == null ) |
| 55 | { |
| 56 | Error( "Can't get XTruncate implementation from substream '" + sStreamName + "'!" ); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | // write requested byte sequence |
| 61 | try |
| 62 | { |
| 63 | xTruncate.truncate(); |
| 64 | xOutput.writeBytes( pBytes ); |
| 65 | } |
| 66 | catch( Exception e ) |
| 67 | { |
| 68 | Error( "Can't write to stream '" + sStreamName + "', exception: " + e ); |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | // get access to the XPropertySet interface |
| 73 | XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xStream ); |
| 74 | if ( xPropSet == null ) |
| 75 | { |
| 76 | Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" ); |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | // set properties to the stream |
| 81 | try |
| 82 | { |
| 83 | xPropSet.setPropertyValue( "MediaType", sMediaType ); |
| 84 | xPropSet.setPropertyValue( "Compressed", Boolean.valueOf( bCompressed ) ); |
| 85 | } |
| 86 | catch( Exception e ) |
| 87 | { |
| 88 | Error( "Can't set properties to substream '" + sStreamName + "', exception: " + e ); |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | // check size property of the stream |
| 93 | try |
| 94 | { |
| 95 | int nSize = AnyConverter.toInt( xPropSet.getPropertyValue( "Size" ) ); |
no test coverage detected