diff options
author | Evgeniy Berlog <berlog@apache.org> | 2012-06-18 12:02:36 +0000 |
---|---|---|
committer | Evgeniy Berlog <berlog@apache.org> | 2012-06-18 12:02:36 +0000 |
commit | 25ceb36664b1ca6eab23ff981551236d933158b4 (patch) | |
tree | cf9468c3ce7ac984d846d9712ff5ce8c8fbc11ab /src/java/org/apache/poi/hssf | |
parent | 39c271cde0d37d7805fbbbe8489cf8e690b1e0ac (diff) | |
download | poi-25ceb36664b1ca6eab23ff981551236d933158b4.tar.gz poi-25ceb36664b1ca6eab23ff981551236d933158b4.zip |
fixed bug in EscherAggregate if sheet contains no shapes
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1351309 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf')
-rw-r--r-- | src/java/org/apache/poi/hssf/record/EscherAggregate.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java index e65fd0333d..f1b470398f 100644 --- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java +++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java @@ -491,7 +491,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { // the first one because it's the patriach). pos = offset; int writtenEscherBytes = 0; - for (int i = 1; i < shapes.size(); i++) { + int i; + for (i = 1; i < shapes.size(); i++) { int endOffset = (Integer) spEndingOffsets.get(i) - 1; int startOffset; if (i == 1) @@ -515,10 +516,15 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { pos += writeDataIntoDrawingRecord(0, drawingData, writtenEscherBytes, pos, data, i); } } + if ((pos - offset) < buffer.length-1){ + byte[] drawingData = new byte[buffer.length - (pos - offset)]; + System.arraycopy(buffer, (pos - offset), drawingData, 0, drawingData.length); + pos += writeDataIntoDrawingRecord(0, drawingData, writtenEscherBytes, pos, data, i); + } // write records that need to be serialized after all drawing group records - for (int i = 0; i < tailRec.size(); i++) { - Record rec = (Record) tailRec.get(i); + for (i = 0; i < tailRec.size(); i++) { + Record rec = tailRec.get(i); pos += rec.serialize(pos, data); } int bytesWritten = pos - offset; @@ -599,6 +605,9 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { } int drawingRecordSize = rawEscherSize + (shapeToObj.size()) * 4; + if (rawEscherSize != 0 && spEndingOffsets.size()==1/**EMPTY**/){ + continueRecordsHeadersSize +=4; + } int objRecordSize = 0; for (Iterator iterator = shapeToObj.values().iterator(); iterator.hasNext(); ) { Record r = (Record) iterator.next(); |