public Ptg[] getTokens() { LittleEndianInput in = new LittleEndianByteArrayInputStream(_byteEncoding); return Ptg.readTokens(_encodedTokenLen, in); } /**
/** * Reads a variant type from a byte array. * * @param src The byte array * @param offset The offset in the byte array where the variant starts * @param length The length of the variant including the variant type field * @param type The variant type to read * @param codepage The codepage to use for non-wide strings * @return A Java object that corresponds best to the variant field. For * example, a VT_I4 is returned as a {@link Long}, a VT_LPSTR as a * {@link String}. * @exception ReadingNotSupportedException if a property is to be written * who's variant type HPSF does not yet support * @exception UnsupportedEncodingException if the specified codepage is not * supported. * @see Variant */ public static Object read( final byte[] src, final int offset, final int length, final long type, final int codepage ) throws ReadingNotSupportedException, UnsupportedEncodingException { LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(src, offset); return read( lei, length, type, codepage ); }
LittleEndianByteArrayInputStream subRecStream = new LittleEndianByteArrayInputStream(subRecordData); CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)SubRecord.createSubRecord(subRecStream, 0); subrecords.add(cmo);
LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(src, offset, length);
LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(src, offFix);
LittleEndianByteArrayInputStream plain = new LittleEndianByteArrayInputStream(buf, 0); // NOSONAR LittleEndianByteArrayOutputStream leos = new LittleEndianByteArrayOutputStream(buf, 0); // NOSONAR enc.setChunkSize(Biff8DecryptingStream.RC4_REKEYING_INTERVAL);
LittleEndianInput in = new LittleEndianByteArrayInputStream(remainder);
/** * Parses the tabstops from TxMasterStyle record * * @param data the data stream * @param offset the offset within the data */ public void parseProperty(byte data[], int offset) { tabStops.addAll(readTabStops(new LittleEndianByteArrayInputStream(data, offset))); }
public Ptg[] getTokens() { LittleEndianInput in = new LittleEndianByteArrayInputStream(_byteEncoding); return Ptg.readTokens(_encodedTokenLen, in); } /**
public Ptg[] getTokens() { LittleEndianInput in = new LittleEndianByteArrayInputStream(_byteEncoding); return Ptg.readTokens(_encodedTokenLen, in); } /**
public long getD4() { // ByteArrayOutputStream baos = new ByteArrayOutputStream(8); try { new DataOutputStream(baos).writeLong(_d4); } catch (IOException e) { throw new RuntimeException(e); } byte[] buf = baos.toByteArray(); return new LittleEndianByteArrayInputStream(buf).readLong(); }
public Ptg[] getTokens() { LittleEndianInput in = new LittleEndianByteArrayInputStream(_byteEncoding); return Ptg.readTokens(_encodedTokenLen, in); } /**
public long getD4() { // ByteArrayOutputStream baos = new ByteArrayOutputStream(8); try { new DataOutputStream(baos).writeLong(_d4); } catch (IOException e) { throw new RuntimeException(e); } byte[] buf = baos.toByteArray(); return new LittleEndianByteArrayInputStream(buf).readLong(); }
private Formula(byte[] byteEncoding, int encodedTokenLen) { _byteEncoding = byteEncoding; _encodedTokenLen = encodedTokenLen; if (false) { // set to true to eagerly check Ptg decoding LittleEndianByteArrayInputStream in = new LittleEndianByteArrayInputStream(byteEncoding); Ptg.readTokens(encodedTokenLen, in); int nUnusedBytes = _byteEncoding.length - in.getReadIndex(); if (nUnusedBytes > 0) { // TODO - this seems to occur when IntersectionPtg is present // This example file "IntersectionPtg.xls" // used by test: TestIntersectionPtg.testReading() // has 10 bytes unused at the end of the formula // 10 extra bytes are just 0x01 and 0x00 System.out.println(nUnusedBytes + " unused bytes at end of formula"); } } } /**
private Formula(byte[] byteEncoding, int encodedTokenLen) { _byteEncoding = byteEncoding; _encodedTokenLen = encodedTokenLen; if (false) { // set to true to eagerly check Ptg decoding LittleEndianByteArrayInputStream in = new LittleEndianByteArrayInputStream(byteEncoding); Ptg.readTokens(encodedTokenLen, in); int nUnusedBytes = _byteEncoding.length - in.getReadIndex(); if (nUnusedBytes > 0) { // TODO - this seems to occur when IntersectionPtg is present // This example file "IntersectionPtg.xls" // used by test: TestIntersectionPtg.testReading() // has 10 bytes unused at the end of the formula // 10 extra bytes are just 0x01 and 0x00 System.out.println(nUnusedBytes + " unused bytes at end of formula"); } } } /**
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()]); }
/** * Reads a variant type from a byte array. * * @param src The byte array * @param offset The offset in the byte array where the variant starts * @param length The length of the variant including the variant type field * @param type The variant type to read * @param codepage The codepage to use for non-wide strings * @return A Java object that corresponds best to the variant field. For * example, a VT_I4 is returned as a {@link Long}, a VT_LPSTR as a * {@link String}. * @exception ReadingNotSupportedException if a property is to be written * who's variant type HPSF does not yet support * @exception UnsupportedEncodingException if the specified codepage is not * supported. * @see Variant */ public static Object read( final byte[] src, final int offset, final int length, final long type, final int codepage ) throws ReadingNotSupportedException, UnsupportedEncodingException { LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(src, offset); return read( lei, length, type, codepage ); }
/** * Constructs the ruler atom record from its * source data. * * @param source the source data as a byte array. * @param start the start offset into the byte array. * @param len the length of the slice in the byte array. */ protected TextRulerAtom(final byte[] source, final int start, final int len) { final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, MAX_RECORD_LENGTH)); try { // Get the header. IOUtils.readFully(leis, _header); // Get the record data. read(leis); } catch (IOException e){ logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage()); } }
private void decryptPicBytes(byte[] pictstream, int offset, int len) throws IOException, GeneralSecurityException { // when reading the picture elements, each time a segment is read, the cipher needs // to be reset (usually done when calling Cipher.doFinal) LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(pictstream, offset); Decryptor dec = getEncryptionInfo().getDecryptor(); ChunkedCipherInputStream ccis = (ChunkedCipherInputStream)dec.getDataStream(lei, len, 0); readFully(ccis, pictstream, offset, len); ccis.close(); lei.close(); }
protected void decryptRecord(byte[] docstream, int persistId, int offset) { if (dea == null) { return; } Decryptor dec = getEncryptionInfo().getDecryptor(); dec.setChunkSize(-1); try (LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(docstream, offset); ChunkedCipherInputStream ccis = (ChunkedCipherInputStream)dec.getDataStream(lei, docstream.length-offset, 0)) { ccis.initCipherForBlock(persistId); // decrypt header and read length to be decrypted readFully(ccis, docstream, offset, 8); // decrypt the rest of the record int rlen = (int)LittleEndian.getUInt(docstream, offset+4); readFully(ccis, docstream, offset+8, rlen); } catch (Exception e) { throw new EncryptedPowerPointFileException(e); } }