diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java index 3bd96bf206..3e1de7c0a7 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java @@ -309,11 +309,7 @@ public final class HWPFDocument extends HWPFDocumentCore { FSPADocumentPart.HEADER); _fspaMain = new FSPATable(_tableStream, _fib, FSPADocumentPart.MAIN); - if (_fib.getFcDggInfo() != 0) { - _escherRecordHolder = new EscherRecordHolder(_tableStream, _fib.getFcDggInfo(), _fib.getLcbDggInfo()); - } else { - _escherRecordHolder = new EscherRecordHolder(); - } + _escherRecordHolder = new EscherRecordHolder(_tableStream, _fib.getFcDggInfo(), _fib.getLcbDggInfo()); // read in the pictures stream _pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java b/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java index df62b420ad..ccc0a7e42c 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java @@ -34,19 +34,23 @@ import org.apache.poi.util.Internal; */ @Internal public final class EscherRecordHolder { - private final ArrayList escherRecords; - - public EscherRecordHolder() { - escherRecords = new ArrayList<>(); - } + private final ArrayList escherRecords = new ArrayList<>(); public EscherRecordHolder(byte[] data, int offset, int size) { - this(); fillEscherRecords(data, offset, size); } + /** + * Parses the records out of the given data. + * + * The thing to be aware of here is that if {@code size} is {@code 0}, the document does not contain images. + * + * @see FileInformationBlock#getLcbDggInfo() + */ private void fillEscherRecords(byte[] data, int offset, int size) { + if (size == 0) return; + EscherRecordFactory recordFactory = new DefaultEscherRecordFactory(); int pos = offset; while ( pos < offset + size) @@ -62,6 +66,7 @@ public final class EscherRecordHolder { return escherRecords; } + @Override public String toString() { StringBuilder buffer = new StringBuilder();