poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r1351309 - /poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java
Date Mon, 18 Jun 2012 12:02:36 GMT
Author: berlog
Date: Mon Jun 18 12:02:36 2012
New Revision: 1351309

URL: http://svn.apache.org/viewvc?rev=1351309&view=rev
Log:
fixed bug in EscherAggregate if sheet contains no shapes

Modified:
    poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java

Modified: poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java
URL: http://svn.apache.org/viewvc/poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java?rev=1351309&r1=1351308&r2=1351309&view=diff
==============================================================================
--- poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java (original)
+++ poi/branches/gsoc2012/src/java/org/apache/poi/hssf/record/EscherAggregate.java Mon Jun
18 12:02:36 2012
@@ -491,7 +491,8 @@ public final class EscherAggregate exten
         // 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 exten
                 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 exten
         }
 
         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();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message