mirror of https://github.com/apache/poi.git
Simplify initialization of HWPF EscherRecordHolder
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12857e68ac
commit
b7038df14d
|
@ -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);
|
||||
|
|
|
@ -34,19 +34,23 @@ import org.apache.poi.util.Internal;
|
|||
*/
|
||||
@Internal
|
||||
public final class EscherRecordHolder {
|
||||
private final ArrayList<EscherRecord> escherRecords;
|
||||
|
||||
public EscherRecordHolder() {
|
||||
escherRecords = new ArrayList<>();
|
||||
}
|
||||
private final ArrayList<EscherRecord> 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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue