static void skipPadding( LittleEndianByteArrayInputStream lei ) { final int offset = lei.getReadIndex(); int skipBytes = (4 - (offset & 3)) & 3; for (int i=0; i<skipBytes; i++) { lei.mark(1); int b = lei.read(); if (b == -1 || b != 0) { lei.reset(); break; } } } }
public void read( LittleEndianByteArrayInputStream lei ) { _type = lei.readShort(); short padding = lei.readShort(); if ( padding != 0 ) { LOG.log( POILogger.WARN, "TypedPropertyValue padding at offset " + lei.getReadIndex() + " MUST be 0, but it's value is " + padding ); } readValue( lei ); }
public void read( LittleEndianByteArrayInputStream lei ) { int offset = lei.getReadIndex(); int size = lei.readInt(); if ( size < 4 ) { String msg = "ClipboardData at offset "+offset+" size less than 4 bytes "+ "(doesn't even have format field!). Setting to format == 0 and hope for the best"; LOG.log( POILogger.WARN, msg); _format = 0; _value = new byte[0]; return; } _format = lei.readInt(); _value = IOUtils.safelyAllocate(size - LittleEndianConsts.INT_SIZE, MAX_RECORD_LENGTH); lei.readFully(_value); }
public void read(LittleEndianByteArrayInputStream lei) { final int length = lei.readInt(); final int unicodeBytes = length*2; _value = IOUtils.safelyAllocate(unicodeBytes, MAX_RECORD_LENGTH); // If Length is zero, this field MUST be zero bytes in length. If Length is // nonzero, this field MUST be a null-terminated array of 16-bit Unicode characters, followed by // zero padding to a multiple of 4 bytes. The string represented by this field SHOULD NOT // contain embedded or additional trailing null characters. if (length == 0) { return; } final int offset = lei.getReadIndex(); lei.readFully(_value); if (_value[unicodeBytes-2] != 0 || _value[unicodeBytes-1] != 0) { String msg = "UnicodeString started at offset #" + offset + " is not NULL-terminated"; throw new IllegalPropertySetDataException(msg); } TypedPropertyValue.skipPadding(lei); }
public void read( LittleEndianByteArrayInputStream lei ) { int offset = lei.getReadIndex(); int size = lei.readInt(); _value = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); if (size == 0) { return; } // If Size is zero, this field MUST be zero bytes in length. If Size is // nonzero and the CodePage property set's CodePage property has the value CP_WINUNICODE // (0x04B0), then the value MUST be a null-terminated array of 16-bit Unicode characters, // followed by zero padding to a multiple of 4 bytes. If Size is nonzero and the property set's // CodePage property has any other value, it MUST be a null-terminated array of 8-bit characters // from the code page identified by the CodePage property, followed by zero padding to a // multiple of 4 bytes. The string represented by this field MAY contain embedded or additional // trailing null characters and an OLEPS implementation MUST be able to handle such strings. lei.readFully(_value); if (_value[size - 1] != 0 ) { // TODO Some files, such as TestVisioWithCodepage.vsd, are currently // triggering this for values that don't look like codepages // See Bug #52258 for details String msg = "CodePageString started at offset #" + offset + " is not NULL-terminated"; LOG.log(POILogger.WARN, msg); } TypedPropertyValue.skipPadding(lei); }
final int nRemainingBytes = subRecordData.length-subRecStream.getReadIndex(); if (nRemainingBytes > 0) {
public static Object read( LittleEndianByteArrayInputStream lei, final int length, final long type, final int codepage ) throws ReadingNotSupportedException, UnsupportedEncodingException { final int offset = lei.getReadIndex(); TypedPropertyValue typedPropertyValue = new TypedPropertyValue( (int) type, null ); try { final int unpadded = lei.getReadIndex()-offset; lei.setReadIndex(offset); final byte[] v = IOUtils.safelyAllocate(unpadded, MAX_RECORD_LENGTH);
public TextSpecInfoRun[] getTextSpecInfoRuns(){ LittleEndianByteArrayInputStream bis = new LittleEndianByteArrayInputStream(_data); // NOSONAR List<TextSpecInfoRun> lst = new ArrayList<>(); while (bis.getReadIndex() < _data.length) { lst.add(new TextSpecInfoRun(bis)); } return lst.toArray(new TextSpecInfoRun[lst.size()]); }
static void skipPadding( LittleEndianByteArrayInputStream lei ) { final int offset = lei.getReadIndex(); int skipBytes = (4 - (offset & 3)) & 3; for (int i=0; i<skipBytes; i++) { lei.mark(1); int b = lei.read(); if (b == -1 || b != 0) { lei.reset(); break; } } } }
public void read( LittleEndianByteArrayInputStream lei ) { _type = lei.readShort(); short padding = lei.readShort(); if ( padding != 0 ) { LOG.log( POILogger.WARN, "TypedPropertyValue padding at offset " + lei.getReadIndex() + " MUST be 0, but it's value is " + padding ); } readValue( lei ); }
public void read( LittleEndianByteArrayInputStream lei ) { int offset = lei.getReadIndex(); int size = lei.readInt(); if ( size < 4 ) { String msg = "ClipboardData at offset "+offset+" size less than 4 bytes "+ "(doesn't even have format field!). Setting to format == 0 and hope for the best"; LOG.log( POILogger.WARN, msg); _format = 0; _value = new byte[0]; return; } _format = lei.readInt(); _value = IOUtils.safelyAllocate(size - LittleEndianConsts.INT_SIZE, MAX_RECORD_LENGTH); lei.readFully(_value); }
public void read(LittleEndianByteArrayInputStream lei) { final int length = lei.readInt(); final int unicodeBytes = length*2; _value = IOUtils.safelyAllocate(unicodeBytes, MAX_RECORD_LENGTH); // If Length is zero, this field MUST be zero bytes in length. If Length is // nonzero, this field MUST be a null-terminated array of 16-bit Unicode characters, followed by // zero padding to a multiple of 4 bytes. The string represented by this field SHOULD NOT // contain embedded or additional trailing null characters. if (length == 0) { return; } final int offset = lei.getReadIndex(); lei.readFully(_value); if (_value[unicodeBytes-2] != 0 || _value[unicodeBytes-1] != 0) { String msg = "UnicodeString started at offset #" + offset + " is not NULL-terminated"; throw new IllegalPropertySetDataException(msg); } TypedPropertyValue.skipPadding(lei); }
public void read( LittleEndianByteArrayInputStream lei ) { int offset = lei.getReadIndex(); int size = lei.readInt(); _value = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); if (size == 0) { return; } // If Size is zero, this field MUST be zero bytes in length. If Size is // nonzero and the CodePage property set's CodePage property has the value CP_WINUNICODE // (0x04B0), then the value MUST be a null-terminated array of 16-bit Unicode characters, // followed by zero padding to a multiple of 4 bytes. If Size is nonzero and the property set's // CodePage property has any other value, it MUST be a null-terminated array of 8-bit characters // from the code page identified by the CodePage property, followed by zero padding to a // multiple of 4 bytes. The string represented by this field MAY contain embedded or additional // trailing null characters and an OLEPS implementation MUST be able to handle such strings. lei.readFully(_value); if (_value[size - 1] != 0 ) { // TODO Some files, such as TestVisioWithCodepage.vsd, are currently // triggering this for values that don't look like codepages // See Bug #52258 for details String msg = "CodePageString started at offset #" + offset + " is not NULL-terminated"; LOG.log(POILogger.WARN, msg); } TypedPropertyValue.skipPadding(lei); }
final int nRemainingBytes = subRecordData.length-subRecStream.getReadIndex(); if (nRemainingBytes > 0) {
public static Object read( LittleEndianByteArrayInputStream lei, final int length, final long type, final int codepage ) throws ReadingNotSupportedException, UnsupportedEncodingException { final int offset = lei.getReadIndex(); TypedPropertyValue typedPropertyValue = new TypedPropertyValue( (int) type, null ); try { final int unpadded = lei.getReadIndex()-offset; lei.setReadIndex(offset); final byte[] v = IOUtils.safelyAllocate(unpadded, MAX_RECORD_LENGTH);