Bugzilla 53302: fixed EscherAggregate to correctly handle Continue records in drawing blocks

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1343218 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2012-05-28 12:15:16 +00:00
parent 25f26be727
commit 9108ca6471
6 changed files with 1836 additions and 37 deletions

View File

@ -34,6 +34,7 @@
<changes>
<release version="3.9-beta1" date="2012-??-??">
<action dev="poi-developers" type="add">53302 - Fixed EscherAggregate to correctly handle Continue records in drawing blocks </action>
<action dev="poi-developers" type="add">53025 - Updatad documentation and example on using Data Validations </action>
<action dev="poi-developers" type="add">53227 - Corrected AddDimensionedImage.java to support XSSF/SXSSF </action>
<action dev="poi-developers" type="add">53058 - Utility for representing drawings contained in a binary Excel file as a XML tree</action>

View File

@ -21,43 +21,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.hssf.record.BOFRecord;
import org.apache.poi.hssf.record.CFHeaderRecord;
import org.apache.poi.hssf.record.CalcCountRecord;
import org.apache.poi.hssf.record.CalcModeRecord;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.ColumnInfoRecord;
import org.apache.poi.hssf.record.DVALRecord;
import org.apache.poi.hssf.record.DefaultColWidthRecord;
import org.apache.poi.hssf.record.DefaultRowHeightRecord;
import org.apache.poi.hssf.record.DeltaRecord;
import org.apache.poi.hssf.record.DimensionsRecord;
import org.apache.poi.hssf.record.DrawingRecord;
import org.apache.poi.hssf.record.EOFRecord;
import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.FeatHdrRecord;
import org.apache.poi.hssf.record.FeatRecord;
import org.apache.poi.hssf.record.GridsetRecord;
import org.apache.poi.hssf.record.GutsRecord;
import org.apache.poi.hssf.record.IndexRecord;
import org.apache.poi.hssf.record.IterationRecord;
import org.apache.poi.hssf.record.MergeCellsRecord;
import org.apache.poi.hssf.record.NoteRecord;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.PaneRecord;
import org.apache.poi.hssf.record.PrintGridlinesRecord;
import org.apache.poi.hssf.record.PrintHeadersRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordBase;
import org.apache.poi.hssf.record.RefModeRecord;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.SaveRecalcRecord;
import org.apache.poi.hssf.record.SelectionRecord;
import org.apache.poi.hssf.record.TextObjectRecord;
import org.apache.poi.hssf.record.UncalcedRecord;
import org.apache.poi.hssf.record.WSBoolRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate;
import org.apache.poi.hssf.record.aggregates.ColumnInfoRecordsAggregate;
import org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable;
@ -1553,6 +1517,14 @@ public final class InternalSheet {
{
loc += 2;
if (records.get( loc ) instanceof NoteRecord) loc ++;
while ( loc + 1 < records.size()
&& records.get( loc ) instanceof ContinueRecord
&& (records.get( loc + 1 ) instanceof ObjRecord ||
records.get( loc + 1 ) instanceof TextObjectRecord) )
{
loc += 2;
if (records.get( loc ) instanceof NoteRecord) loc ++;
}
}
int endloc = loc-1;

View File

@ -373,6 +373,13 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
{
dataSize += ( (DrawingRecord) records.get( loc ) ).getData().length;
loc += 2;
while ( loc + 1 < records.size()
&& sid( records, loc ) == ContinueRecord.sid
&& isObjectRecord( records, loc + 1 ) )
{
dataSize += ( (ContinueRecord) records.get( loc ) ).getData().length;
loc += 2;
}
}
// Create one big buffer
@ -387,6 +394,15 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
System.arraycopy( drawingRecord.getData(), 0, buffer, offset, drawingRecord.getData().length );
offset += drawingRecord.getData().length;
loc += 2;
while ( loc + 1 < records.size()
&& sid( records, loc ) == ContinueRecord.sid
&& isObjectRecord( records, loc + 1 ) )
{
ContinueRecord continueRecord = (ContinueRecord) records.get( loc );
System.arraycopy( continueRecord.getData(), 0, buffer, offset, continueRecord.getData().length );
offset += continueRecord.getData().length;
loc += 2;
}
}
// Decode the shapes
@ -411,6 +427,14 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
Record objRecord = (Record) records.get( loc + 1 );
agg.shapeToObj.put( shapeRecords.get( shapeIndex++ ), objRecord );
loc += 2;
while ( loc + 1 < records.size()
&& sid( records, loc ) == ContinueRecord.sid
&& isObjectRecord( records, loc + 1 ) )
{
objRecord = (Record) records.get( loc + 1 );
agg.shapeToObj.put( shapeRecords.get( shapeIndex++ ), objRecord );
loc += 2;
}
}
return agg;

File diff suppressed because it is too large Load Diff

BIN
test-data/spreadsheet/45129.xls Executable file

Binary file not shown.

BIN
test-data/spreadsheet/dg-text.xls Executable file

Binary file not shown.