1) Full implementation of UnicodeStrings 2) exposure of RichText strings to the usermodel 3) Modification to SSTRecord to support duplicates. Fixes a few bugs 4) RecordInputStream *smart* ?? handeling of continue records! Phew This took 6 months on and off to put together. Just happy to commit somethig Report any problems! git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353769 13f79535-47bb-0310-9956-ffa450edef68tags/AFTER_RICHTEXT
@@ -355,6 +355,7 @@ | |||
<exclude name="**/AllTests.java"/> | |||
<exclude name="**/TestEmptyDocument.java"/> | |||
<exclude name="**/TestUnfixedBugs.java"/> | |||
<exclude name="**/TestcaseRecordInputStream.java"/> | |||
</fileset> | |||
</batchtest> | |||
</junit> |
@@ -90,64 +90,27 @@ public class BiffViewer { | |||
public static Record[] createRecords(InputStream in, boolean dump) | |||
throws RecordFormatException { | |||
ArrayList records = new ArrayList(); | |||
// Record last_record = null; | |||
int loc = 0; | |||
RecordDetails activeRecord = null; | |||
try { | |||
// long offset = 0; | |||
short rectype = 0; | |||
do { | |||
rectype = LittleEndian.readShort(in); | |||
int startloc = loc; | |||
loc += 2; | |||
if (rectype != 0) { | |||
short recsize = LittleEndian.readShort(in); | |||
loc += 2; | |||
byte[] data = new byte[(int) recsize]; | |||
in.read(data); | |||
loc += recsize; | |||
Record record = createRecord(rectype, recsize, data ); | |||
// if (record.getSid() == DrawingGroupRecord.sid) | |||
// { | |||
// if (activeRecord.getRecord().getSid() == DrawingGroupRecord.sid) | |||
// { | |||
// DrawingGroupRecord dg = (DrawingGroupRecord) activeRecord.getRecord(); | |||
// System.out.println( "Joined" ); | |||
// dg.join( (AbstractEscherHolderRecord) record ); | |||
// } | |||
// else | |||
// { | |||
// records.add(record); | |||
// if (activeRecord != null) | |||
// activeRecord.dump(); | |||
// activeRecord = new RecordDetails(rectype, recsize, startloc, data, record); | |||
// } | |||
// } | |||
// else | |||
BiffviewRecordInputStream recStream = new BiffviewRecordInputStream(in); | |||
while (recStream.hasNextRecord()) { | |||
recStream.nextRecord(); | |||
if (recStream.getSid() != 0) { | |||
Record record = createRecord (recStream); | |||
if (record.getSid() != ContinueRecord.sid) | |||
{ | |||
records.add(record); | |||
if (activeRecord != null) | |||
activeRecord.dump(); | |||
activeRecord = new RecordDetails(rectype, recsize, startloc, data, record); | |||
} | |||
else | |||
{ | |||
activeRecord.getRecord().processContinueRecord(data); | |||
activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), (int)recStream.getPos(), record); | |||
} | |||
if (dump) { | |||
dumpRaw(rectype, recsize, data); | |||
recStream.dumpBytes(); | |||
} | |||
} | |||
} | |||
} while (rectype != 0); | |||
activeRecord.dump(); | |||
} catch (IOException e) { | |||
throw new RecordFormatException("Error reading bytes"); | |||
} | |||
@@ -165,454 +128,383 @@ public class BiffViewer { | |||
} | |||
private static void dumpContinueRecord(Record last_record, boolean dump, byte[] data) throws IOException { | |||
if (last_record == null) { | |||
throw new RecordFormatException( | |||
"First record is a ContinueRecord??"); | |||
} | |||
if (dump) { | |||
System.out.println( | |||
"-----PRECONTINUED LAST RECORD WOULD SERIALIZE LIKE:"); | |||
byte[] lr = last_record.serialize(); | |||
if (lr != null) { | |||
HexDump.dump(last_record.serialize(), | |||
0, System.out, 0); | |||
} | |||
System.out.println(); | |||
System.out.println( | |||
"-----PRECONTINUED----------------------------------"); | |||
} | |||
last_record.processContinueRecord(data); | |||
if (dump) { | |||
System.out.println( | |||
"-----CONTINUED LAST RECORD WOULD SERIALIZE LIKE:"); | |||
HexDump.dump(last_record.serialize(), 0, | |||
System.out, 0); | |||
System.out.println(); | |||
System.out.println( | |||
"-----CONTINUED----------------------------------"); | |||
} | |||
} | |||
private static void dumpUnknownRecord(byte[] data) throws IOException { | |||
// record hex dump it! | |||
System.out.println( | |||
"-----UNKNOWN----------------------------------"); | |||
if (data.length > 0) { | |||
HexDump.dump(data, 0, System.out, 0); | |||
} else { | |||
System.out.print("**NO RECORD DATA**"); | |||
} | |||
System.out.println(); | |||
System.out.println( | |||
"-----UNKNOWN----------------------------------"); | |||
} | |||
private static void dumpRaw( short rectype, short recsize, byte[] data ) throws IOException | |||
{ | |||
// System.out | |||
// .println("fixing to recordize the following"); | |||
System.out.println("============================================"); | |||
System.out.print( "rectype = 0x" | |||
+ Integer.toHexString( rectype ) ); | |||
System.out.println( ", recsize = 0x" | |||
+ Integer.toHexString( recsize ) ); | |||
System.out.println( | |||
"-BEGIN DUMP---------------------------------" ); | |||
if ( data.length > 0 ) | |||
{ | |||
HexDump.dump( data, 0, System.out, 0 ); | |||
} | |||
else | |||
{ | |||
System.out.println( "**NO RECORD DATA**" ); | |||
} | |||
// System.out.println(); | |||
System.out.println( | |||
"-END DUMP-----------------------------------" ); | |||
} | |||
/** | |||
* Essentially a duplicate of RecordFactory. Kept seperate as not to screw | |||
* up non-debug operations. | |||
* | |||
*/ | |||
private static Record createRecord( short rectype, short size, | |||
byte[] data ) | |||
private static Record createRecord( RecordInputStream in ) | |||
{ | |||
Record retval = null; | |||
switch ( rectype ) | |||
switch ( in.getSid() ) | |||
{ | |||
case ChartRecord.sid: | |||
retval = new ChartRecord( rectype, size, data ); | |||
retval = new ChartRecord( in ); | |||
break; | |||
case ChartFormatRecord.sid: | |||
retval = new ChartFormatRecord( rectype, size, data ); | |||
retval = new ChartFormatRecord( in ); | |||
break; | |||
case SeriesRecord.sid: | |||
retval = new SeriesRecord( rectype, size, data ); | |||
retval = new SeriesRecord( in ); | |||
break; | |||
case BeginRecord.sid: | |||
retval = new BeginRecord( rectype, size, data ); | |||
retval = new BeginRecord( in ); | |||
break; | |||
case EndRecord.sid: | |||
retval = new EndRecord( rectype, size, data ); | |||
retval = new EndRecord( in ); | |||
break; | |||
case BOFRecord.sid: | |||
retval = new BOFRecord( rectype, size, data ); | |||
retval = new BOFRecord( in ); | |||
break; | |||
case InterfaceHdrRecord.sid: | |||
retval = new InterfaceHdrRecord( rectype, size, data ); | |||
retval = new InterfaceHdrRecord( in ); | |||
break; | |||
case MMSRecord.sid: | |||
retval = new MMSRecord( rectype, size, data ); | |||
retval = new MMSRecord( in ); | |||
break; | |||
case InterfaceEndRecord.sid: | |||
retval = new InterfaceEndRecord( rectype, size, data ); | |||
retval = new InterfaceEndRecord( in ); | |||
break; | |||
case WriteAccessRecord.sid: | |||
retval = new WriteAccessRecord( rectype, size, data ); | |||
retval = new WriteAccessRecord( in ); | |||
break; | |||
case CodepageRecord.sid: | |||
retval = new CodepageRecord( rectype, size, data ); | |||
retval = new CodepageRecord( in ); | |||
break; | |||
case DSFRecord.sid: | |||
retval = new DSFRecord( rectype, size, data ); | |||
retval = new DSFRecord( in ); | |||
break; | |||
case TabIdRecord.sid: | |||
retval = new TabIdRecord( rectype, size, data ); | |||
retval = new TabIdRecord( in ); | |||
break; | |||
case FnGroupCountRecord.sid: | |||
retval = new FnGroupCountRecord( rectype, size, data ); | |||
retval = new FnGroupCountRecord( in ); | |||
break; | |||
case WindowProtectRecord.sid: | |||
retval = new WindowProtectRecord( rectype, size, data ); | |||
retval = new WindowProtectRecord( in ); | |||
break; | |||
case ProtectRecord.sid: | |||
retval = new ProtectRecord( rectype, size, data ); | |||
retval = new ProtectRecord( in ); | |||
break; | |||
case PasswordRecord.sid: | |||
retval = new PasswordRecord( rectype, size, data ); | |||
retval = new PasswordRecord( in ); | |||
break; | |||
case ProtectionRev4Record.sid: | |||
retval = new ProtectionRev4Record( rectype, size, data ); | |||
retval = new ProtectionRev4Record( in ); | |||
break; | |||
case PasswordRev4Record.sid: | |||
retval = new PasswordRev4Record( rectype, size, data ); | |||
retval = new PasswordRev4Record( in ); | |||
break; | |||
case WindowOneRecord.sid: | |||
retval = new WindowOneRecord( rectype, size, data ); | |||
retval = new WindowOneRecord( in ); | |||
break; | |||
case BackupRecord.sid: | |||
retval = new BackupRecord( rectype, size, data ); | |||
retval = new BackupRecord( in ); | |||
break; | |||
case HideObjRecord.sid: | |||
retval = new HideObjRecord( rectype, size, data ); | |||
retval = new HideObjRecord( in ); | |||
break; | |||
case DateWindow1904Record.sid: | |||
retval = new DateWindow1904Record( rectype, size, data ); | |||
retval = new DateWindow1904Record( in ); | |||
break; | |||
case PrecisionRecord.sid: | |||
retval = new PrecisionRecord( rectype, size, data ); | |||
retval = new PrecisionRecord( in ); | |||
break; | |||
case RefreshAllRecord.sid: | |||
retval = new RefreshAllRecord( rectype, size, data ); | |||
retval = new RefreshAllRecord( in ); | |||
break; | |||
case BookBoolRecord.sid: | |||
retval = new BookBoolRecord( rectype, size, data ); | |||
retval = new BookBoolRecord( in ); | |||
break; | |||
case FontRecord.sid: | |||
retval = new FontRecord( rectype, size, data ); | |||
retval = new FontRecord( in ); | |||
break; | |||
case FormatRecord.sid: | |||
retval = new FormatRecord( rectype, size, data ); | |||
retval = new FormatRecord( in ); | |||
break; | |||
case ExtendedFormatRecord.sid: | |||
retval = new ExtendedFormatRecord( rectype, size, data ); | |||
retval = new ExtendedFormatRecord( in ); | |||
break; | |||
case StyleRecord.sid: | |||
retval = new StyleRecord( rectype, size, data ); | |||
retval = new StyleRecord( in ); | |||
break; | |||
case UseSelFSRecord.sid: | |||
retval = new UseSelFSRecord( rectype, size, data ); | |||
retval = new UseSelFSRecord( in ); | |||
break; | |||
case BoundSheetRecord.sid: | |||
retval = new BoundSheetRecord( rectype, size, data ); | |||
retval = new BoundSheetRecord( in ); | |||
break; | |||
case CountryRecord.sid: | |||
retval = new CountryRecord( rectype, size, data ); | |||
retval = new CountryRecord( in ); | |||
break; | |||
case SSTRecord.sid: | |||
retval = new SSTRecord( rectype, size, data ); | |||
retval = new SSTRecord( in ); | |||
break; | |||
case ExtSSTRecord.sid: | |||
retval = new ExtSSTRecord( rectype, size, data ); | |||
retval = new ExtSSTRecord( in ); | |||
break; | |||
case EOFRecord.sid: | |||
retval = new EOFRecord( rectype, size, data ); | |||
retval = new EOFRecord( in ); | |||
break; | |||
case IndexRecord.sid: | |||
retval = new IndexRecord( rectype, size, data ); | |||
retval = new IndexRecord( in ); | |||
break; | |||
case CalcModeRecord.sid: | |||
retval = new CalcModeRecord( rectype, size, data ); | |||
retval = new CalcModeRecord( in ); | |||
break; | |||
case CalcCountRecord.sid: | |||
retval = new CalcCountRecord( rectype, size, data ); | |||
retval = new CalcCountRecord( in ); | |||
break; | |||
case RefModeRecord.sid: | |||
retval = new RefModeRecord( rectype, size, data ); | |||
retval = new RefModeRecord( in ); | |||
break; | |||
case IterationRecord.sid: | |||
retval = new IterationRecord( rectype, size, data ); | |||
retval = new IterationRecord( in ); | |||
break; | |||
case DeltaRecord.sid: | |||
retval = new DeltaRecord( rectype, size, data ); | |||
retval = new DeltaRecord( in ); | |||
break; | |||
case SaveRecalcRecord.sid: | |||
retval = new SaveRecalcRecord( rectype, size, data ); | |||
retval = new SaveRecalcRecord( in ); | |||
break; | |||
case PrintHeadersRecord.sid: | |||
retval = new PrintHeadersRecord( rectype, size, data ); | |||
retval = new PrintHeadersRecord( in ); | |||
break; | |||
case PrintGridlinesRecord.sid: | |||
retval = new PrintGridlinesRecord( rectype, size, data ); | |||
retval = new PrintGridlinesRecord( in ); | |||
break; | |||
case GridsetRecord.sid: | |||
retval = new GridsetRecord( rectype, size, data ); | |||
retval = new GridsetRecord( in ); | |||
break; | |||
case DrawingGroupRecord.sid: | |||
retval = new DrawingGroupRecord( rectype, size, data ); | |||
retval = new DrawingGroupRecord( in ); | |||
break; | |||
case DrawingRecordForBiffViewer.sid: | |||
retval = new DrawingRecordForBiffViewer( rectype, size, data ); | |||
retval = new DrawingRecordForBiffViewer( in ); | |||
break; | |||
case DrawingSelectionRecord.sid: | |||
retval = new DrawingSelectionRecord( rectype, size, data ); | |||
retval = new DrawingSelectionRecord( in ); | |||
break; | |||
case GutsRecord.sid: | |||
retval = new GutsRecord( rectype, size, data ); | |||
retval = new GutsRecord( in ); | |||
break; | |||
case DefaultRowHeightRecord.sid: | |||
retval = new DefaultRowHeightRecord( rectype, size, data ); | |||
retval = new DefaultRowHeightRecord( in ); | |||
break; | |||
case WSBoolRecord.sid: | |||
retval = new WSBoolRecord( rectype, size, data ); | |||
retval = new WSBoolRecord( in ); | |||
break; | |||
case HeaderRecord.sid: | |||
retval = new HeaderRecord( rectype, size, data ); | |||
retval = new HeaderRecord( in ); | |||
break; | |||
case FooterRecord.sid: | |||
retval = new FooterRecord( rectype, size, data ); | |||
retval = new FooterRecord( in ); | |||
break; | |||
case HCenterRecord.sid: | |||
retval = new HCenterRecord( rectype, size, data ); | |||
retval = new HCenterRecord( in ); | |||
break; | |||
case VCenterRecord.sid: | |||
retval = new VCenterRecord( rectype, size, data ); | |||
retval = new VCenterRecord( in ); | |||
break; | |||
case PrintSetupRecord.sid: | |||
retval = new PrintSetupRecord( rectype, size, data ); | |||
retval = new PrintSetupRecord( in ); | |||
break; | |||
case DefaultColWidthRecord.sid: | |||
retval = new DefaultColWidthRecord( rectype, size, data ); | |||
retval = new DefaultColWidthRecord( in ); | |||
break; | |||
case DimensionsRecord.sid: | |||
retval = new DimensionsRecord( rectype, size, data ); | |||
retval = new DimensionsRecord( in ); | |||
break; | |||
case RowRecord.sid: | |||
retval = new RowRecord( rectype, size, data ); | |||
retval = new RowRecord( in ); | |||
break; | |||
case LabelSSTRecord.sid: | |||
retval = new LabelSSTRecord( rectype, size, data ); | |||
retval = new LabelSSTRecord( in ); | |||
break; | |||
case RKRecord.sid: | |||
retval = new RKRecord( rectype, size, data ); | |||
retval = new RKRecord( in ); | |||
break; | |||
case NumberRecord.sid: | |||
retval = new NumberRecord( rectype, size, data ); | |||
retval = new NumberRecord( in ); | |||
break; | |||
case DBCellRecord.sid: | |||
retval = new DBCellRecord( rectype, size, data ); | |||
retval = new DBCellRecord( in ); | |||
break; | |||
case WindowTwoRecord.sid: | |||
retval = new WindowTwoRecord( rectype, size, data ); | |||
retval = new WindowTwoRecord( in ); | |||
break; | |||
case SelectionRecord.sid: | |||
retval = new SelectionRecord( rectype, size, data ); | |||
retval = new SelectionRecord( in ); | |||
break; | |||
case ContinueRecord.sid: | |||
retval = new ContinueRecord( rectype, size, data ); | |||
retval = new ContinueRecord( in ); | |||
break; | |||
case LabelRecord.sid: | |||
retval = new LabelRecord( rectype, size, data ); | |||
retval = new LabelRecord( in ); | |||
break; | |||
case MulRKRecord.sid: | |||
retval = new MulRKRecord( rectype, size, data ); | |||
retval = new MulRKRecord( in ); | |||
break; | |||
case MulBlankRecord.sid: | |||
retval = new MulBlankRecord( rectype, size, data ); | |||
retval = new MulBlankRecord( in ); | |||
break; | |||
case BlankRecord.sid: | |||
retval = new BlankRecord( rectype, size, data ); | |||
retval = new BlankRecord( in ); | |||
break; | |||
case BoolErrRecord.sid: | |||
retval = new BoolErrRecord( rectype, size, data ); | |||
retval = new BoolErrRecord( in ); | |||
break; | |||
case ColumnInfoRecord.sid: | |||
retval = new ColumnInfoRecord( rectype, size, data ); | |||
retval = new ColumnInfoRecord( in ); | |||
break; | |||
case MergeCellsRecord.sid: | |||
retval = new MergeCellsRecord( rectype, size, data ); | |||
retval = new MergeCellsRecord( in ); | |||
break; | |||
case AreaRecord.sid: | |||
retval = new AreaRecord( rectype, size, data ); | |||
retval = new AreaRecord( in ); | |||
break; | |||
case DataFormatRecord.sid: | |||
retval = new DataFormatRecord( rectype, size, data ); | |||
retval = new DataFormatRecord( in ); | |||
break; | |||
case BarRecord.sid: | |||
retval = new BarRecord( rectype, size, data ); | |||
retval = new BarRecord( in ); | |||
break; | |||
case DatRecord.sid: | |||
retval = new DatRecord( rectype, size, data ); | |||
retval = new DatRecord( in ); | |||
break; | |||
case PlotGrowthRecord.sid: | |||
retval = new PlotGrowthRecord( rectype, size, data ); | |||
retval = new PlotGrowthRecord( in ); | |||
break; | |||
case UnitsRecord.sid: | |||
retval = new UnitsRecord( rectype, size, data ); | |||
retval = new UnitsRecord( in ); | |||
break; | |||
case FrameRecord.sid: | |||
retval = new FrameRecord( rectype, size, data ); | |||
retval = new FrameRecord( in ); | |||
break; | |||
case ValueRangeRecord.sid: | |||
retval = new ValueRangeRecord( rectype, size, data ); | |||
retval = new ValueRangeRecord( in ); | |||
break; | |||
case SeriesListRecord.sid: | |||
retval = new SeriesListRecord( rectype, size, data ); | |||
retval = new SeriesListRecord( in ); | |||
break; | |||
case FontBasisRecord.sid: | |||
retval = new FontBasisRecord( rectype, size, data ); | |||
retval = new FontBasisRecord( in ); | |||
break; | |||
case FontIndexRecord.sid: | |||
retval = new FontIndexRecord( rectype, size, data ); | |||
retval = new FontIndexRecord( in ); | |||
break; | |||
case LineFormatRecord.sid: | |||
retval = new LineFormatRecord( rectype, size, data ); | |||
retval = new LineFormatRecord( in ); | |||
break; | |||
case AreaFormatRecord.sid: | |||
retval = new AreaFormatRecord( rectype, size, data ); | |||
retval = new AreaFormatRecord( in ); | |||
break; | |||
case LinkedDataRecord.sid: | |||
retval = new LinkedDataRecord( rectype, size, data ); | |||
retval = new LinkedDataRecord( in ); | |||
break; | |||
case FormulaRecord.sid: | |||
retval = new FormulaRecord( rectype, size, data ); | |||
retval = new FormulaRecord( in ); | |||
break; | |||
case SheetPropertiesRecord.sid: | |||
retval = new SheetPropertiesRecord( rectype, size, data ); | |||
retval = new SheetPropertiesRecord( in ); | |||
break; | |||
case DefaultDataLabelTextPropertiesRecord.sid: | |||
retval = new DefaultDataLabelTextPropertiesRecord( rectype, size, data ); | |||
retval = new DefaultDataLabelTextPropertiesRecord( in ); | |||
break; | |||
case TextRecord.sid: | |||
retval = new TextRecord( rectype, size, data ); | |||
retval = new TextRecord( in ); | |||
break; | |||
case AxisParentRecord.sid: | |||
retval = new AxisParentRecord( rectype, size, data ); | |||
retval = new AxisParentRecord( in ); | |||
break; | |||
case AxisLineFormatRecord.sid: | |||
retval = new AxisLineFormatRecord( rectype, size, data ); | |||
retval = new AxisLineFormatRecord( in ); | |||
break; | |||
case SupBookRecord.sid: | |||
retval = new SupBookRecord( rectype, size, data ); | |||
retval = new SupBookRecord( in ); | |||
break; | |||
case ExternSheetRecord.sid: | |||
retval = new ExternSheetRecord( rectype, size, data ); | |||
retval = new ExternSheetRecord( in ); | |||
break; | |||
case SCLRecord.sid: | |||
retval = new SCLRecord( rectype, size, data ); | |||
retval = new SCLRecord( in ); | |||
break; | |||
case SeriesToChartGroupRecord.sid: | |||
retval = new SeriesToChartGroupRecord( rectype, size, data ); | |||
retval = new SeriesToChartGroupRecord( in ); | |||
break; | |||
case AxisUsedRecord.sid: | |||
retval = new AxisUsedRecord( rectype, size, data ); | |||
retval = new AxisUsedRecord( in ); | |||
break; | |||
case AxisRecord.sid: | |||
retval = new AxisRecord( rectype, size, data ); | |||
retval = new AxisRecord( in ); | |||
break; | |||
case CategorySeriesAxisRecord.sid: | |||
retval = new CategorySeriesAxisRecord( rectype, size, data ); | |||
retval = new CategorySeriesAxisRecord( in ); | |||
break; | |||
case AxisOptionsRecord.sid: | |||
retval = new AxisOptionsRecord( rectype, size, data ); | |||
retval = new AxisOptionsRecord( in ); | |||
break; | |||
case TickRecord.sid: | |||
retval = new TickRecord( rectype, size, data ); | |||
retval = new TickRecord( in ); | |||
break; | |||
case SeriesTextRecord.sid: | |||
retval = new SeriesTextRecord( rectype, size, data ); | |||
retval = new SeriesTextRecord( in ); | |||
break; | |||
case ObjectLinkRecord.sid: | |||
retval = new ObjectLinkRecord( rectype, size, data ); | |||
retval = new ObjectLinkRecord( in ); | |||
break; | |||
case PlotAreaRecord.sid: | |||
retval = new PlotAreaRecord( rectype, size, data ); | |||
retval = new PlotAreaRecord( in ); | |||
break; | |||
case SeriesIndexRecord.sid: | |||
retval = new SeriesIndexRecord( rectype, size, data ); | |||
retval = new SeriesIndexRecord( in ); | |||
break; | |||
case LegendRecord.sid: | |||
retval = new LegendRecord( rectype, size, data ); | |||
retval = new LegendRecord( in ); | |||
break; | |||
case LeftMarginRecord.sid: | |||
retval = new LeftMarginRecord( rectype, size, data ); | |||
retval = new LeftMarginRecord( in ); | |||
break; | |||
case RightMarginRecord.sid: | |||
retval = new RightMarginRecord( rectype, size, data ); | |||
retval = new RightMarginRecord( in ); | |||
break; | |||
case TopMarginRecord.sid: | |||
retval = new TopMarginRecord( rectype, size, data ); | |||
retval = new TopMarginRecord( in ); | |||
break; | |||
case BottomMarginRecord.sid: | |||
retval = new BottomMarginRecord( rectype, size, data ); | |||
retval = new BottomMarginRecord( in ); | |||
break; | |||
case PaletteRecord.sid: | |||
retval = new PaletteRecord( rectype, size, data ); | |||
retval = new PaletteRecord( in ); | |||
break; | |||
case StringRecord.sid: | |||
retval = new StringRecord( rectype, size, data ); | |||
retval = new StringRecord( in ); | |||
break; | |||
case NameRecord.sid: | |||
retval = new NameRecord( rectype, size, data ); | |||
retval = new NameRecord( in ); | |||
break; | |||
case PaneRecord.sid: | |||
retval = new PaneRecord( rectype, size, data ); | |||
retval = new PaneRecord( in ); | |||
break; | |||
case SharedFormulaRecord.sid: | |||
retval = new SharedFormulaRecord( rectype, size, data); | |||
retval = new SharedFormulaRecord( in); | |||
break; | |||
case ObjRecord.sid: | |||
retval = new ObjRecord( rectype, size, data); | |||
retval = new ObjRecord( in); | |||
break; | |||
case TextObjectRecord.sid: | |||
retval = new TextObjectRecord( rectype, size, data); | |||
retval = new TextObjectRecord( in); | |||
break; | |||
case HorizontalPageBreakRecord.sid: | |||
retval = new HorizontalPageBreakRecord( rectype, size, data); | |||
retval = new HorizontalPageBreakRecord( in); | |||
break; | |||
case VerticalPageBreakRecord.sid: | |||
retval = new VerticalPageBreakRecord( rectype, size, data); | |||
retval = new VerticalPageBreakRecord( in); | |||
break; | |||
default: | |||
retval = new UnknownRecord( rectype, size, data ); | |||
retval = new UnknownRecord( in ); | |||
} | |||
return retval; | |||
} | |||
@@ -684,15 +576,13 @@ public class BiffViewer { | |||
{ | |||
short rectype, recsize; | |||
int startloc; | |||
byte[] data; | |||
Record record; | |||
public RecordDetails( short rectype, short recsize, int startloc, byte[] data, Record record ) | |||
public RecordDetails( short rectype, short recsize, int startloc, Record record ) | |||
{ | |||
this.rectype = rectype; | |||
this.recsize = recsize; | |||
this.startloc = startloc; | |||
this.data = data; | |||
this.record = record; | |||
} | |||
@@ -706,11 +596,6 @@ public class BiffViewer { | |||
return recsize; | |||
} | |||
public byte[] getData() | |||
{ | |||
return data; | |||
} | |||
public Record getRecord() | |||
{ | |||
return record; | |||
@@ -718,12 +603,18 @@ public class BiffViewer { | |||
public void dump() throws IOException | |||
{ | |||
if (record instanceof UnknownRecord) | |||
dumpUnknownRecord(data); | |||
else | |||
dumpNormal(record, startloc, rectype, recsize); | |||
} | |||
} | |||
static class BiffviewRecordInputStream extends RecordInputStream { | |||
public BiffviewRecordInputStream(InputStream in) { | |||
super(in); | |||
} | |||
public void dumpBytes() { | |||
HexDump.dump(this.data, 0, this.currentLength); | |||
} | |||
} | |||
} | |||
@@ -36,159 +36,159 @@ import org.apache.poi.hssf.eventusermodel.HSSFEventFactory; | |||
* Event Factory version of HSSF test class. | |||
* @author andy | |||
*/ | |||
public class EFHSSF | |||
{ | |||
String infile; | |||
String outfile; | |||
HSSFWorkbook workbook = null; | |||
HSSFSheet cursheet = null; | |||
/** Creates a new instance of EFHSSF */ | |||
public EFHSSF() | |||
{ | |||
} | |||
public void setInputFile(String infile) | |||
{ | |||
this.infile = infile; | |||
} | |||
public void setOutputFile(String outfile) | |||
{ | |||
this.outfile = outfile; | |||
} | |||
public void run() | |||
throws IOException | |||
{ | |||
FileInputStream fin = new FileInputStream(infile); | |||
POIFSFileSystem poifs = new POIFSFileSystem(fin); | |||
InputStream din = poifs.createDocumentInputStream("Workbook"); | |||
HSSFRequest req = new HSSFRequest(); | |||
req.addListenerForAllRecords(new EFHSSFListener(this)); | |||
HSSFEventFactory factory = new HSSFEventFactory(); | |||
factory.processEvents(req, din); | |||
fin.close(); | |||
din.close(); | |||
FileOutputStream fout = new FileOutputStream(outfile); | |||
workbook.write(fout); | |||
fout.close(); | |||
System.out.println("done."); | |||
} | |||
public void recordHandler(Record record) | |||
{ | |||
HSSFRow row = null; | |||
HSSFCell cell = null; | |||
int sheetnum = -1; | |||
switch (record.getSid()) | |||
{ | |||
case BOFRecord.sid : | |||
BOFRecord bof = ( BOFRecord ) record; | |||
if (bof.getType() == bof.TYPE_WORKBOOK) | |||
{ | |||
workbook = new HSSFWorkbook(); | |||
} | |||
else if (bof.getType() == bof.TYPE_WORKSHEET) | |||
{ | |||
sheetnum++; | |||
cursheet = workbook.getSheetAt(sheetnum); | |||
} | |||
break; | |||
case BoundSheetRecord.sid : | |||
BoundSheetRecord bsr = ( BoundSheetRecord ) record; | |||
workbook.createSheet(bsr.getSheetname()); | |||
break; | |||
case RowRecord.sid : | |||
RowRecord rowrec = ( RowRecord ) record; | |||
cursheet.createRow(rowrec.getRowNumber()); | |||
break; | |||
case NumberRecord.sid : | |||
NumberRecord numrec = ( NumberRecord ) record; | |||
row = cursheet.getRow(numrec.getRow()); | |||
cell = row.createCell(numrec.getColumn(), | |||
HSSFCell.CELL_TYPE_NUMERIC); | |||
cell.setCellValue(numrec.getValue()); | |||
break; | |||
case SSTRecord.sid : | |||
SSTRecord sstrec = ( SSTRecord ) record; | |||
for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) | |||
{ | |||
workbook.addSSTString(sstrec.getString(k)); | |||
} | |||
break; | |||
case LabelSSTRecord.sid : | |||
LabelSSTRecord lrec = ( LabelSSTRecord ) record; | |||
row = cursheet.getRow(lrec.getRow()); | |||
cell = row.createCell(lrec.getColumn(), | |||
HSSFCell.CELL_TYPE_STRING); | |||
cell.setCellValue(workbook.getSSTString(lrec.getSSTIndex())); | |||
break; | |||
} | |||
} | |||
public static void main(String [] args) | |||
{ | |||
if ((args.length < 2) || !args[ 0 ].equals("--help")) | |||
{ | |||
try | |||
{ | |||
EFHSSF viewer = new EFHSSF(); | |||
viewer.setInputFile(args[ 0 ]); | |||
viewer.setOutputFile(args[ 1 ]); | |||
viewer.run(); | |||
} | |||
catch (IOException e) | |||
{ | |||
e.printStackTrace(); | |||
} | |||
} | |||
else | |||
{ | |||
System.out.println("EFHSSF"); | |||
System.out.println( | |||
"General testbed for HSSFEventFactory based testing and " | |||
+ "Code examples"); | |||
System.out.println("Usage: java org.apache.poi.hssf.dev.EFHSSF " | |||
+ "file1 file2"); | |||
System.out.println( | |||
" --will rewrite the file reading with the event api"); | |||
System.out.println("and writing with the standard API"); | |||
} | |||
} | |||
} | |||
class EFHSSFListener | |||
implements HSSFListener | |||
{ | |||
EFHSSF efhssf; | |||
public EFHSSFListener(EFHSSF efhssf) | |||
{ | |||
this.efhssf = efhssf; | |||
} | |||
public void processRecord(Record record) | |||
{ | |||
efhssf.recordHandler(record); | |||
} | |||
} | |||
//JMH | |||
//public class EFHSSF | |||
//{ | |||
// String infile; | |||
// String outfile; | |||
// HSSFWorkbook workbook = null; | |||
// HSSFSheet cursheet = null; | |||
// | |||
// /** Creates a new instance of EFHSSF */ | |||
// | |||
// public EFHSSF() | |||
// { | |||
// } | |||
// | |||
// public void setInputFile(String infile) | |||
// { | |||
// this.infile = infile; | |||
// } | |||
// | |||
// public void setOutputFile(String outfile) | |||
// { | |||
// this.outfile = outfile; | |||
// } | |||
// | |||
// public void run() | |||
// throws IOException | |||
// { | |||
// FileInputStream fin = new FileInputStream(infile); | |||
// POIFSFileSystem poifs = new POIFSFileSystem(fin); | |||
// InputStream din = poifs.createDocumentInputStream("Workbook"); | |||
// HSSFRequest req = new HSSFRequest(); | |||
// | |||
// req.addListenerForAllRecords(new EFHSSFListener(this)); | |||
// HSSFEventFactory factory = new HSSFEventFactory(); | |||
// | |||
// factory.processEvents(req, din); | |||
// fin.close(); | |||
// din.close(); | |||
// FileOutputStream fout = new FileOutputStream(outfile); | |||
// | |||
// workbook.write(fout); | |||
// fout.close(); | |||
// System.out.println("done."); | |||
// } | |||
// | |||
// public void recordHandler(Record record) | |||
// { | |||
// HSSFRow row = null; | |||
// HSSFCell cell = null; | |||
// int sheetnum = -1; | |||
// | |||
// switch (record.getSid()) | |||
// { | |||
// | |||
// case BOFRecord.sid : | |||
// BOFRecord bof = ( BOFRecord ) record; | |||
// | |||
// if (bof.getType() == bof.TYPE_WORKBOOK) | |||
// { | |||
// workbook = new HSSFWorkbook(); | |||
// } | |||
// else if (bof.getType() == bof.TYPE_WORKSHEET) | |||
// { | |||
// sheetnum++; | |||
// cursheet = workbook.getSheetAt(sheetnum); | |||
// } | |||
// break; | |||
// | |||
// case BoundSheetRecord.sid : | |||
// BoundSheetRecord bsr = ( BoundSheetRecord ) record; | |||
// | |||
// workbook.createSheet(bsr.getSheetname()); | |||
// break; | |||
// | |||
// case RowRecord.sid : | |||
// RowRecord rowrec = ( RowRecord ) record; | |||
// | |||
// cursheet.createRow(rowrec.getRowNumber()); | |||
// break; | |||
// | |||
// case NumberRecord.sid : | |||
// NumberRecord numrec = ( NumberRecord ) record; | |||
// | |||
// row = cursheet.getRow(numrec.getRow()); | |||
// cell = row.createCell(numrec.getColumn(), | |||
// HSSFCell.CELL_TYPE_NUMERIC); | |||
// cell.setCellValue(numrec.getValue()); | |||
// break; | |||
// | |||
// case SSTRecord.sid : | |||
// SSTRecord sstrec = ( SSTRecord ) record; | |||
// | |||
// for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) | |||
// { | |||
// workbook.addSSTString(new UnicodeString(sstrec.getString(k))); | |||
// } | |||
// break; | |||
// | |||
// case LabelSSTRecord.sid : | |||
// LabelSSTRecord lrec = ( LabelSSTRecord ) record; | |||
// | |||
// row = cursheet.getRow(lrec.getRow()); | |||
// cell = row.createCell(lrec.getColumn(), | |||
// HSSFCell.CELL_TYPE_STRING); | |||
// cell.setCellValue(workbook.getSSTString(lrec.getSSTIndex())); | |||
// break; | |||
// } | |||
// } | |||
// | |||
// public static void main(String [] args) | |||
// { | |||
// if ((args.length < 2) || !args[ 0 ].equals("--help")) | |||
// { | |||
// try | |||
// { | |||
// EFHSSF viewer = new EFHSSF(); | |||
// | |||
// viewer.setInputFile(args[ 0 ]); | |||
// viewer.setOutputFile(args[ 1 ]); | |||
// viewer.run(); | |||
// } | |||
// catch (IOException e) | |||
// { | |||
// e.printStackTrace(); | |||
// } | |||
// } | |||
// else | |||
// { | |||
// System.out.println("EFHSSF"); | |||
// System.out.println( | |||
// "General testbed for HSSFEventFactory based testing and " | |||
// + "Code examples"); | |||
// System.out.println("Usage: java org.apache.poi.hssf.dev.EFHSSF " | |||
// + "file1 file2"); | |||
// System.out.println( | |||
// " --will rewrite the file reading with the event api"); | |||
// System.out.println("and writing with the standard API"); | |||
// } | |||
// } | |||
//} | |||
// | |||
//class EFHSSFListener | |||
// implements HSSFListener | |||
//{ | |||
// EFHSSF efhssf; | |||
// | |||
// public EFHSSFListener(EFHSSF efhssf) | |||
// { | |||
// this.efhssf = efhssf; | |||
// } | |||
// | |||
// public void processRecord(Record record) | |||
// { | |||
// efhssf.recordHandler(record); | |||
// } | |||
//} |
@@ -83,6 +83,7 @@ import org.apache.poi.hssf.record.ProtectionRev4Record; | |||
import org.apache.poi.hssf.record.RKRecord; | |||
import org.apache.poi.hssf.record.Record; | |||
import org.apache.poi.hssf.record.RecordFormatException; | |||
import org.apache.poi.hssf.record.RecordInputStream; | |||
import org.apache.poi.hssf.record.RefModeRecord; | |||
import org.apache.poi.hssf.record.RefreshAllRecord; | |||
import org.apache.poi.hssf.record.RightMarginRecord; | |||
@@ -262,22 +263,11 @@ public class EventRecordFactory | |||
{ | |||
Record last_record = null; | |||
try | |||
{ | |||
short rectype = 0; | |||
do | |||
{ | |||
rectype = LittleEndian.readShort(in); | |||
if (rectype != 0) | |||
{ | |||
short recsize = LittleEndian.readShort(in); | |||
byte[] data = new byte[ ( int ) recsize ]; | |||
in.read(data); | |||
Record[] recs = createRecord(rectype, recsize, | |||
data); // handle MulRK records | |||
RecordInputStream recStream = new RecordInputStream(in); | |||
while (recStream.hasNextRecord()) { | |||
recStream.nextRecord(); | |||
Record[] recs = createRecord(recStream); // handle MulRK records | |||
if (recs.length > 1) | |||
{ | |||
for (int k = 0; k < recs.length; k++) | |||
@@ -288,8 +278,6 @@ public class EventRecordFactory | |||
break; | |||
} | |||
} | |||
// records.add( | |||
// recs[ k ]); // these will be number records | |||
last_record = | |||
recs[ k ]; // do to keep the algorythm homogenous...you can't | |||
} // actually continue a number record anyhow. | |||
@@ -300,19 +288,6 @@ public class EventRecordFactory | |||
if (record != null) | |||
{ | |||
if (rectype == ContinueRecord.sid && | |||
! (last_record instanceof ContinueRecord) && // include continuation records after | |||
! (last_record instanceof UnknownRecord) ) // unknown records or previous continuation records | |||
{ | |||
if (last_record == null) | |||
{ | |||
throw new RecordFormatException( | |||
"First record is a ContinueRecord??"); | |||
} | |||
last_record.processContinueRecord(data); | |||
} | |||
else | |||
{ | |||
if (last_record != null) { | |||
if (throwRecordEvent(last_record) == false && abortable == true) { | |||
last_record = null; | |||
@@ -321,35 +296,21 @@ public class EventRecordFactory | |||
} | |||
last_record = record; | |||
//records.add(record); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
while (rectype != 0); | |||
if (last_record != null) { | |||
throwRecordEvent(last_record); | |||
} | |||
} | |||
catch (IOException e) | |||
{ | |||
throw new RecordFormatException("Error reading bytes"); | |||
} | |||
// Record[] retval = new Record[ records.size() ]; | |||
// retval = ( Record [] ) records.toArray(retval); | |||
} | |||
/** | |||
* create a record, if there are MUL records than multiple records | |||
* are returned digested into the non-mul form. | |||
*/ | |||
public static Record [] createRecord(short rectype, short size, | |||
byte [] data) | |||
public static Record [] createRecord(RecordInputStream in) | |||
{ | |||
Record retval = null; | |||
Record[] realretval = null; | |||
@@ -357,18 +318,18 @@ public class EventRecordFactory | |||
try | |||
{ | |||
Constructor constructor = | |||
( Constructor ) recordsMap.get(new Short(rectype)); | |||
( Constructor ) recordsMap.get(new Short(in.getSid())); | |||
if (constructor != null) | |||
{ | |||
retval = ( Record ) constructor.newInstance(new Object[] | |||
{ | |||
new Short(rectype), new Short(size), data | |||
in | |||
}); | |||
} | |||
else | |||
{ | |||
retval = new UnknownRecord(rectype, size, data); | |||
retval = new UnknownRecord(in); | |||
} | |||
} | |||
catch (Exception introspectionException) | |||
@@ -470,7 +431,7 @@ public class EventRecordFactory | |||
sid = record.getField("sid").getShort(null); | |||
constructor = record.getConstructor(new Class[] | |||
{ | |||
short.class, short.class, byte [].class | |||
RecordInputStream.class | |||
}); | |||
} | |||
catch (Exception illegalArgumentException) |
@@ -24,6 +24,7 @@ import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.hssf.eventusermodel.HSSFUserException; | |||
import org.apache.poi.hssf.record.RecordFormatException; | |||
import org.apache.poi.hssf.record.Record; | |||
import org.apache.poi.hssf.record.RecordInputStream; | |||
import org.apache.poi.hssf.record.RecordFactory; | |||
import org.apache.poi.hssf.record.ContinueRecord; | |||
import org.apache.poi.poifs.filesystem.POIFSFileSystem; | |||
@@ -98,7 +99,7 @@ public class HSSFEventFactory | |||
{ | |||
try | |||
{ | |||
genericProcessEvents(req, in); | |||
genericProcessEvents(req, new RecordInputStream(in)); | |||
} | |||
catch (HSSFUserException hue) | |||
{/*If an HSSFUserException user exception is thrown, ignore it.*/ } | |||
@@ -117,7 +118,7 @@ public class HSSFEventFactory | |||
public short abortableProcessEvents(HSSFRequest req, InputStream in) | |||
throws IOException, HSSFUserException | |||
{ | |||
return genericProcessEvents(req, in); | |||
return genericProcessEvents(req, new RecordInputStream(in)); | |||
} | |||
/** | |||
@@ -129,23 +130,22 @@ public class HSSFEventFactory | |||
* @return numeric user-specified result code. | |||
*/ | |||
protected short genericProcessEvents(HSSFRequest req, InputStream in) | |||
protected short genericProcessEvents(HSSFRequest req, RecordInputStream in) | |||
throws IOException, HSSFUserException | |||
{ | |||
short userCode = 0; | |||
short sid = 0; | |||
process: | |||
try | |||
{ | |||
byte[] sidbytes = new byte[ 2 ]; | |||
int bytesread = in.read(sidbytes); | |||
Record rec = null; | |||
while (bytesread > 0) | |||
while (in.hasNextRecord()) | |||
{ | |||
in.nextRecord(); | |||
sid = LittleEndian.getShort(sidbytes); | |||
sid = in.getSid();; | |||
// | |||
// for some reasons we have to make the workbook to be at least 4096 bytes | |||
@@ -171,16 +171,8 @@ public class HSSFEventFactory | |||
} | |||
if (sid != ContinueRecord.sid) | |||
{ | |||
short size = LittleEndian.readShort(in); | |||
byte[] data = new byte[ size ]; | |||
if (data.length > 0) | |||
{ | |||
in.read(data); | |||
} | |||
//System.out.println("creating "+sid); | |||
Record[] recs = RecordFactory.createRecord(sid, size, | |||
data); | |||
Record[] recs = RecordFactory.createRecord(in); | |||
if (recs.length > 1) | |||
{ // we know that the multiple | |||
@@ -199,17 +191,9 @@ public class HSSFEventFactory | |||
// records, it will go here too. | |||
} | |||
else | |||
{ // we do have a continue record | |||
short size = LittleEndian.readShort(in); | |||
byte[] data = new byte[ size ]; | |||
if (data.length > 0) | |||
{ | |||
in.read(data); | |||
} | |||
rec.processContinueRecord(data); | |||
throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception"); | |||
} | |||
bytesread = in.read(sidbytes); // read next record sid | |||
} | |||
if (rec != null) | |||
{ | |||
@@ -217,11 +201,7 @@ public class HSSFEventFactory | |||
if (userCode != 0) break process; | |||
} | |||
} | |||
catch (IOException e) | |||
{ | |||
throw new RecordFormatException("Error reading bytes" + | |||
"while processing record sid="+sid); | |||
} | |||
return userCode; | |||
// Record[] retval = new Record[ records.size() ]; |
@@ -609,7 +609,7 @@ public class Sheet implements Model | |||
records.remove(k); | |||
LabelSSTRecord newrec = new LabelSSTRecord(); | |||
int stringid = | |||
wb.addSSTString(oldrec.getValue()); | |||
wb.addSSTString(new UnicodeString(oldrec.getValue())); | |||
newrec.setRow(oldrec.getRow()); | |||
newrec.setColumn(oldrec.getColumn()); |
@@ -625,35 +625,21 @@ public class Workbook implements Model | |||
/** | |||
* Adds a string to the SST table and returns its index (if its a duplicate | |||
* just returns its index and update the counts) | |||
* just returns its index and update the counts) ASSUMES compressed unicode | |||
* (meaning 8bit) | |||
* | |||
* @param string the string to be added to the SSTRecord | |||
* @param use16bits whether to use utf 16 or false for compressed unicode | |||
* | |||
* @return index of the string within the SSTRecord | |||
*/ | |||
public int addSSTString(String string, boolean use16bits) { | |||
public int addSSTString(UnicodeString string) { | |||
if (log.check( POILogger.DEBUG )) | |||
log.log(DEBUG, "insert to sst string='", string, "' and use16bits= ", | |||
new Boolean(use16bits)); | |||
log.log(DEBUG, "insert to sst string='", string); | |||
if (sst == null) { | |||
insertSST(); | |||
} | |||
return sst.addString(string, use16bits); | |||
} | |||
/** | |||
* Adds a string to the SST table and returns its index (if its a duplicate | |||
* just returns its index and update the counts) ASSUMES compressed unicode | |||
* (meaning 8bit) | |||
* | |||
* @param string the string to be added to the SSTRecord | |||
* | |||
* @return index of the string within the SSTRecord | |||
*/ | |||
public int addSSTString(String string) { | |||
return addSSTString(string, false); | |||
return sst.addString(string); | |||
} | |||
/** | |||
@@ -661,11 +647,11 @@ public class Workbook implements Model | |||
* @return String containing the SST String | |||
*/ | |||
public String getSSTString(int str) { | |||
public UnicodeString getSSTString(int str) { | |||
if (sst == null) { | |||
insertSST(); | |||
} | |||
String retval = sst.getString(str); | |||
UnicodeString retval = sst.getString(str); | |||
if (log.check( POILogger.DEBUG )) | |||
log.log(DEBUG, "Returning SST for index=", new Integer(str), | |||
@@ -1631,7 +1617,7 @@ public class Workbook implements Model | |||
*/ | |||
protected PaletteRecord createPalette() | |||
{ | |||
return new PaletteRecord(PaletteRecord.sid); | |||
return new PaletteRecord(); | |||
} | |||
/** |
@@ -57,25 +57,9 @@ public abstract class AbstractEscherHolderRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AbstractEscherHolderRecord(short id, short size, byte [] data) | |||
public AbstractEscherHolderRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Bar record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1017 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AbstractEscherHolderRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -92,17 +76,17 @@ public abstract class AbstractEscherHolderRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
escherRecords = new ArrayList(); | |||
if (! DESERIALISE ) | |||
{ | |||
rawData = new byte[size]; | |||
System.arraycopy(data, offset, rawData, 0, size); | |||
rawData = in.readRemainder(); | |||
} | |||
else | |||
{ | |||
convertToEscherRecords( offset, size, data ); | |||
byte[] data = in.readAllContinuedRemainder(); | |||
convertToEscherRecords( 0, data.length, data ); | |||
} | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -58,25 +57,9 @@ public class AreaFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AreaFormatRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a AreaFormat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x100a or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AreaFormatRecord(short id, short size, byte [] data, int offset) | |||
public AreaFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -93,16 +76,16 @@ public class AreaFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_foregroundColor = LittleEndian.getInt(data, pos + 0x0 + offset); | |||
field_2_backgroundColor = LittleEndian.getInt(data, pos + 0x4 + offset); | |||
field_3_pattern = LittleEndian.getShort(data, pos + 0x8 + offset); | |||
field_4_formatFlags = LittleEndian.getShort(data, pos + 0xa + offset); | |||
field_5_forecolorIndex = LittleEndian.getShort(data, pos + 0xc + offset); | |||
field_6_backcolorIndex = LittleEndian.getShort(data, pos + 0xe + offset); | |||
field_1_foregroundColor = in.readInt(); | |||
field_2_backgroundColor = in.readInt(); | |||
field_3_pattern = in.readShort(); | |||
field_4_formatFlags = in.readShort(); | |||
field_5_forecolorIndex = in.readShort(); | |||
field_6_backcolorIndex = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -54,25 +53,9 @@ public class AreaRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AreaRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Area record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x101A or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AreaRecord(short id, short size, byte [] data, int offset) | |||
public AreaRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -89,11 +72,11 @@ public class AreaRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_formatFlags = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_formatFlags = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -55,25 +54,9 @@ public class AxisLineFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AxisLineFormatRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a AxisLineFormat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1021 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AxisLineFormatRecord(short id, short size, byte [] data, int offset) | |||
public AxisLineFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -90,11 +73,11 @@ public class AxisLineFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_axisType = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -67,25 +66,9 @@ public class AxisOptionsRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AxisOptionsRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a AxisOptions record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1062 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AxisOptionsRecord(short id, short size, byte [] data, int offset) | |||
public AxisOptionsRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -102,19 +85,19 @@ public class AxisOptionsRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_minimumCategory = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_maximumCategory = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_majorUnitValue = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_majorUnit = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_5_minorUnitValue = LittleEndian.getShort(data, pos + 0x8 + offset); | |||
field_6_minorUnit = LittleEndian.getShort(data, pos + 0xa + offset); | |||
field_7_baseUnit = LittleEndian.getShort(data, pos + 0xc + offset); | |||
field_8_crossingPoint = LittleEndian.getShort(data, pos + 0xe + offset); | |||
field_9_options = LittleEndian.getShort(data, pos + 0x10 + offset); | |||
field_1_minimumCategory = in.readShort(); | |||
field_2_maximumCategory = in.readShort(); | |||
field_3_majorUnitValue = in.readShort(); | |||
field_4_majorUnit = in.readShort(); | |||
field_5_minorUnitValue = in.readShort(); | |||
field_6_minorUnit = in.readShort(); | |||
field_7_baseUnit = in.readShort(); | |||
field_8_crossingPoint = in.readShort(); | |||
field_9_options = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -57,25 +56,9 @@ public class AxisParentRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AxisParentRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a AxisParent record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1041 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AxisParentRecord(short id, short size, byte [] data, int offset) | |||
public AxisParentRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -92,15 +75,15 @@ public class AxisParentRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_x = LittleEndian.getInt(data, pos + 0x2 + offset); | |||
field_3_y = LittleEndian.getInt(data, pos + 0x6 + offset); | |||
field_4_width = LittleEndian.getInt(data, pos + 0xa + offset); | |||
field_5_height = LittleEndian.getInt(data, pos + 0xe + offset); | |||
field_1_axisType = in.readShort(); | |||
field_2_x = in.readInt(); | |||
field_3_y = in.readInt(); | |||
field_4_width = in.readInt(); | |||
field_5_height = in.readInt(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -58,25 +57,9 @@ public class AxisRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AxisRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Axis record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x101d or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AxisRecord(short id, short size, byte [] data, int offset) | |||
public AxisRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -93,15 +76,15 @@ public class AxisRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_reserved1 = LittleEndian.getInt(data, pos + 0x2 + offset); | |||
field_3_reserved2 = LittleEndian.getInt(data, pos + 0x6 + offset); | |||
field_4_reserved3 = LittleEndian.getInt(data, pos + 0xa + offset); | |||
field_5_reserved4 = LittleEndian.getInt(data, pos + 0xe + offset); | |||
field_1_axisType = in.readShort(); | |||
field_2_reserved1 = in.readInt(); | |||
field_3_reserved2 = in.readInt(); | |||
field_4_reserved3 = in.readInt(); | |||
field_5_reserved4 = in.readInt(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -51,25 +50,9 @@ public class AxisUsedRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public AxisUsedRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a AxisUsed record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1046 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public AxisUsedRecord(short id, short size, byte [] data, int offset) | |||
public AxisUsedRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -86,11 +69,11 @@ public class AxisUsedRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_numAxis = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_numAxis = in.readShort(); | |||
} | |||
@@ -93,25 +93,9 @@ public class BOFRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BOFRecord(short id, short size, byte [] data) | |||
public BOFRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
// fillFields(data,size); | |||
} | |||
/** | |||
* Constructs a BOFRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x809 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset the offset of the record's data | |||
*/ | |||
public BOFRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
// fillFields(data,size); | |||
} | |||
@@ -124,14 +108,14 @@ public class BOFRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_version = LittleEndian.getShort(data, 0 + offset); | |||
field_2_type = LittleEndian.getShort(data, 2 + offset); | |||
field_3_build = LittleEndian.getShort(data, 4 + offset); | |||
field_4_year = LittleEndian.getShort(data, 6 + offset); | |||
field_5_history = LittleEndian.getInt(data, 8 + offset); | |||
field_6_rversion = LittleEndian.getInt(data, 12 + offset); | |||
field_1_version = in.readShort(); | |||
field_2_type = in.readShort(); | |||
field_3_build = in.readShort(); | |||
field_4_year = in.readShort(); | |||
field_5_history = in.readInt(); | |||
field_6_rversion = in.readInt(); | |||
} | |||
/** |
@@ -47,23 +47,9 @@ public class BackupRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BackupRecord(short id, short size, byte [] data) | |||
public BackupRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a BackupRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x40 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the start of the record's data | |||
*/ | |||
public BackupRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -74,9 +60,9 @@ public class BackupRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_backup = LittleEndian.getShort(data, 0 + offset); | |||
field_1_backup = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -57,25 +56,9 @@ public class BarRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BarRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Bar record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1017 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BarRecord(short id, short size, byte [] data, int offset) | |||
public BarRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -92,13 +75,13 @@ public class BarRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_barSpace = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_categorySpace = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_formatFlags = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_1_barSpace = in.readShort(); | |||
field_2_categorySpace = in.readShort(); | |||
field_3_formatFlags = in.readShort(); | |||
} | |||
@@ -46,23 +46,9 @@ public class BeginRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BeginRecord(short id, short size, byte [] data) | |||
public BeginRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a BeginRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1033 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BeginRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -73,7 +59,7 @@ public class BeginRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
} | |||
@@ -58,31 +58,17 @@ public class BlankRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BlankRecord(short id, short size, byte [] data) | |||
public BlankRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs a BlankRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x201 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BlankRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_col = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf = LittleEndian.getShort(data, 4 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_col = in.readShort(); | |||
field_3_xf = in.readShort(); | |||
} | |||
/** |
@@ -47,23 +47,9 @@ public class BookBoolRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BookBoolRecord(short id, short size, byte [] data) | |||
public BookBoolRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a BookBoolRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0xDA or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BookBoolRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -74,9 +60,9 @@ public class BookBoolRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_save_link_values = LittleEndian.getShort(data, 0 + offset); | |||
field_1_save_link_values = in.readShort(); | |||
} | |||
/** |
@@ -59,23 +59,9 @@ public class BoolErrRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BoolErrRecord(short id, short size, byte [] data) | |||
public BoolErrRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a BoolErr record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x205 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record | |||
*/ | |||
public BoolErrRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -86,14 +72,14 @@ public class BoolErrRecord | |||
* @param size size of data | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_column = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); | |||
field_4_bBoolErr = data[ 6 + offset ]; | |||
field_5_fError = data[ 7 + offset ]; | |||
field_1_row = in.readUShort(); | |||
field_2_column = in.readShort(); | |||
field_3_xf_index = in.readShort(); | |||
field_4_bBoolErr = in.readByte(); | |||
field_5_fError = in.readByte(); | |||
} | |||
//public void setRow(short row) |
@@ -46,23 +46,9 @@ public class BottomMarginRecord | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BottomMarginRecord( short id, short size, byte[] data ) | |||
public BottomMarginRecord( RecordInputStream in ) | |||
{ | |||
super( id, size, data ); | |||
} | |||
/** | |||
* Constructs a BottomMargin record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x29 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BottomMarginRecord( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super( in ); | |||
} | |||
/** | |||
@@ -78,9 +64,9 @@ public class BottomMarginRecord | |||
} | |||
} | |||
protected void fillFields( byte[] data, short size, int offset ) | |||
protected void fillFields( RecordInputStream in ) | |||
{ | |||
field_1_margin = LittleEndian.getDouble( data, 0x0 + offset ); | |||
field_1_margin = in.readDouble(); | |||
} | |||
public String toString() |
@@ -54,23 +54,9 @@ public class BoundSheetRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public BoundSheetRecord( short id, short size, byte[] data ) | |||
public BoundSheetRecord( RecordInputStream in ) | |||
{ | |||
super( id, size, data ); | |||
} | |||
/** | |||
* Constructs a BoundSheetRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x85 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public BoundSheetRecord( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super( in ); | |||
} | |||
protected void validateSid( short id ) | |||
@@ -92,21 +78,21 @@ public class BoundSheetRecord | |||
* | |||
*/ | |||
protected void fillFields( byte[] data, short size, int offset ) | |||
protected void fillFields( RecordInputStream in ) | |||
{ | |||
field_1_position_of_BOF = LittleEndian.getInt( data, 0 + offset ); // bof | |||
field_2_option_flags = LittleEndian.getShort( data, 4 + offset ); // flags | |||
field_3_sheetname_length = data[6 + offset]; // len(str) | |||
field_4_compressed_unicode_flag = data[7 + offset]; // unicode | |||
field_1_position_of_BOF = in.readInt(); // bof | |||
field_2_option_flags = in.readShort(); // flags | |||
field_3_sheetname_length = in.readByte(); // len(str) | |||
field_4_compressed_unicode_flag = in.readByte(); // unicode | |||
int nameLength = LittleEndian.ubyteToInt( field_3_sheetname_length ); | |||
if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 ) | |||
{ | |||
field_5_sheetname = StringUtil.getFromUnicodeLE( data, 8 + offset, nameLength ); | |||
field_5_sheetname = in.readUnicodeLEString(nameLength); | |||
} | |||
else | |||
{ | |||
field_5_sheetname = StringUtil.getFromCompressedUnicode( data, 8 + offset, nameLength ); | |||
field_5_sheetname = in.readCompressedUnicode(nameLength); | |||
} | |||
} | |||
@@ -158,7 +144,11 @@ public class BoundSheetRecord | |||
/** | |||
* Set the sheetname for this sheet. (this appears in the tabs at the bottom) | |||
* @param sheetname the name of the sheet | |||
<<<<<<< BoundSheetRecord.java | |||
* @thows IllegalArgumentException if sheet name will cause excel to crash. | |||
======= | |||
* @throws IllegalArgumentException if sheet name will cause excel to crash. | |||
>>>>>>> 1.14 | |||
*/ | |||
public void setSheetname( String sheetname ) |
@@ -53,23 +53,9 @@ public class CalcCountRecord | |||
* | |||
*/ | |||
public CalcCountRecord(short id, short size, byte [] data) | |||
public CalcCountRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CalcCountRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0xC or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public CalcCountRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -80,9 +66,9 @@ public class CalcCountRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_iterations = LittleEndian.getShort(data, 0 + offset); | |||
field_1_iterations = in.readShort(); | |||
} | |||
/** |
@@ -68,23 +68,9 @@ public class CalcModeRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public CalcModeRecord(short id, short size, byte [] data) | |||
public CalcModeRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CalcModeRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0xD or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's start data | |||
*/ | |||
public CalcModeRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -95,9 +81,9 @@ public class CalcModeRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_calcmode = LittleEndian.getShort(data, 0 + offset); | |||
field_1_calcmode = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -57,25 +56,9 @@ public class CategorySeriesAxisRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public CategorySeriesAxisRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CategorySeriesAxis record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1020 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public CategorySeriesAxisRecord(short id, short size, byte [] data, int offset) | |||
public CategorySeriesAxisRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -92,14 +75,14 @@ public class CategorySeriesAxisRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_crossingPoint = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_labelFrequency = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_tickMarkFrequency = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_options = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_1_crossingPoint = in.readShort(); | |||
field_2_labelFrequency = in.readShort(); | |||
field_3_tickMarkFrequency = in.readShort(); | |||
field_4_options = in.readShort(); | |||
} | |||
@@ -54,23 +54,9 @@ public class ChartFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ChartFormatRecord(short id, short size, byte [] data) | |||
public ChartFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a ChartFormatRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must equal the sid or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ChartFormatRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -81,13 +67,13 @@ public class ChartFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field1_x_position = LittleEndian.getInt(data, 0 + offset); | |||
field2_y_position = LittleEndian.getInt(data, 4 + offset); | |||
field3_width = LittleEndian.getInt(data, 8 + offset); | |||
field4_height = LittleEndian.getInt(data, 12 + offset); | |||
field5_grbit = LittleEndian.getShort(data, 16 + offset); | |||
field1_x_position = in.readInt(); | |||
field2_y_position = in.readInt(); | |||
field3_width = in.readInt(); | |||
field4_height = in.readInt(); | |||
field5_grbit = in.readShort(); | |||
} | |||
public String toString() |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -54,25 +53,9 @@ public class ChartRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ChartRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Chart record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1002 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ChartRecord(short id, short size, byte [] data, int offset) | |||
public ChartRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -89,14 +72,14 @@ public class ChartRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_x = LittleEndian.getInt(data, pos + 0x0 + offset); | |||
field_2_y = LittleEndian.getInt(data, pos + 0x4 + offset); | |||
field_3_width = LittleEndian.getInt(data, pos + 0x8 + offset); | |||
field_4_height = LittleEndian.getInt(data, pos + 0xc + offset); | |||
field_1_x = in.readInt(); | |||
field_2_y = in.readInt(); | |||
field_3_width = in.readInt(); | |||
field_4_height = in.readInt(); | |||
} | |||
@@ -54,23 +54,9 @@ public class CodepageRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public CodepageRecord(short id, short size, byte [] data) | |||
public CodepageRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CodepageRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x42 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset offset of the record | |||
*/ | |||
public CodepageRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -81,9 +67,9 @@ public class CodepageRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_codepage = LittleEndian.getShort(data, 0 + offset); | |||
field_1_codepage = in.readShort(); | |||
} | |||
/** |
@@ -60,33 +60,19 @@ public class ColumnInfoRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ColumnInfoRecord(short id, short size, byte [] data) | |||
public ColumnInfoRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs a ColumnInfo record and sets its fields appropriately | |||
* | |||
* @param id id must be 0x7d or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ColumnInfoRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data); | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_first_col = LittleEndian.getShort(data, 0 + offset); | |||
field_2_last_col = LittleEndian.getShort(data, 2 + offset); | |||
field_3_col_width = LittleEndian.getShort(data, 4 + offset); | |||
field_4_xf_index = LittleEndian.getShort(data, 6 + offset); | |||
field_5_options = LittleEndian.getShort(data, 8 + offset); | |||
field_6_reserved = data[ 10 + offset ]; | |||
field_1_first_col = in.readShort(); | |||
field_2_last_col = in.readShort(); | |||
field_3_col_width = in.readShort(); | |||
field_4_xf_index = in.readShort(); | |||
field_5_options = in.readShort(); | |||
field_6_reserved = in.readShort(); | |||
} | |||
protected void validateSid(short id) |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -91,26 +90,9 @@ public class CommonObjectDataSubRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public CommonObjectDataSubRecord(short id, short size, byte [] data) | |||
public CommonObjectDataSubRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CommonObjectData record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x15 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public CommonObjectDataSubRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -126,16 +108,16 @@ public class CommonObjectDataSubRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_objectType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_objectId = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_option = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_reserved1 = LittleEndian.getInt(data, pos + 0x6 + offset); | |||
field_5_reserved2 = LittleEndian.getInt(data, pos + 0xa + offset); | |||
field_6_reserved3 = LittleEndian.getInt(data, pos + 0xe + offset); | |||
field_1_objectType = in.readShort(); | |||
field_2_objectId = in.readShort(); | |||
field_3_option = in.readShort(); | |||
field_4_reserved1 = in.readInt(); | |||
field_5_reserved2 = in.readInt(); | |||
field_6_reserved3 = in.readInt(); | |||
} | |||
@@ -54,23 +54,9 @@ public class ContinueRecord | |||
* @param data raw data | |||
*/ | |||
public ContinueRecord(short id, short size, byte [] data) | |||
public ContinueRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Main constructor -- kinda dummy because we don't validate or fill fields | |||
* | |||
* @param id record id | |||
* @param size record size | |||
* @param data raw data | |||
* @param offset of the record's data | |||
*/ | |||
public ContinueRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -115,74 +101,6 @@ public class ContinueRecord | |||
return field_1_data; | |||
} | |||
/** | |||
* Use to serialize records that are too big for their britches (>8228..why 8228 and | |||
* not 8192 aka 8k? Those folks in washington don't ususally make sense... | |||
* or at least to anyone outside fo marketing... | |||
* @deprecated handle this within the record...this didn't actualyl work out | |||
*/ | |||
public static byte [] processContinue(byte [] data) | |||
{ // could do this recursively but that seems hard to debug | |||
// how many continue records do we need | |||
// System.out.println("In ProcessContinue"); | |||
int records = (data.length / 8214); // we've a 1 offset but we're also off by one due to rounding...so it balances out | |||
int offset = 8214; | |||
// System.out.println("we have "+records+" continue records to process"); | |||
ArrayList crs = new ArrayList(records); | |||
int totalsize = 8214; | |||
byte[] retval = null; | |||
for (int cr = 0; cr < records; cr++) | |||
{ | |||
ContinueRecord contrec = new ContinueRecord(); | |||
int arraysize = Math.min((8214 - 4), (data.length - offset)); | |||
byte[] crdata = new byte[ arraysize ]; | |||
System.arraycopy(data, offset, crdata, 0, arraysize); | |||
// System.out.println("arraycopy(data,"+offset+",crdata,"+0+","+arraysize+");"); | |||
offset += crdata.length; | |||
contrec.setData(crdata); | |||
crs.add(contrec.serialize()); | |||
} | |||
for (int cr = 0; cr < records; cr++) | |||
{ | |||
totalsize += (( byte [] ) crs.get(cr)).length; | |||
} | |||
// System.out.println("totalsize="+totalsize); | |||
retval = new byte[ totalsize ]; | |||
offset = 8214; | |||
System.arraycopy(data, 0, retval, 0, 8214); | |||
for (int cr = 0; cr < records; cr++) | |||
{ | |||
byte[] src = ( byte [] ) crs.get(cr); | |||
System.arraycopy(src, 0, retval, offset, src.length); | |||
// System.out.println("arraycopy(src,"+0+",retval,"+offset+","+src.length+");"); | |||
offset += src.length; | |||
} | |||
return retval; | |||
} | |||
/** | |||
* Fill the fields. Only thing is, this record has no fields -- | |||
* | |||
* @param ignored_parm1 Ignored | |||
* @param ignored_parm2 Ignored | |||
*/ | |||
protected void fillFields(byte [] ignored_parm1, short ignored_parm2) | |||
{ | |||
this.field_1_data = ignored_parm1; | |||
// throw new RecordFormatException("Are you crazy? Don't fill a continue record"); | |||
// do nothing | |||
} | |||
/** | |||
* Make sure we have a good id | |||
* | |||
@@ -227,8 +145,9 @@ public class ContinueRecord | |||
* @param ignored_parm3 Ignored | |||
*/ | |||
protected void fillFields(byte [] ignored_parm1, short ignored_parm2, int ignored_parm3) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_data = in.readRemainder(); | |||
} | |||
/** |
@@ -51,23 +51,9 @@ public class CountryRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public CountryRecord(short id, short size, byte [] data) | |||
public CountryRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a CountryRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0x8c or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public CountryRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -78,10 +64,10 @@ public class CountryRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_default_country = LittleEndian.getShort(data, 0 + offset); | |||
field_2_current_country = LittleEndian.getShort(data, 2 + offset); | |||
field_1_default_country = in.readShort(); | |||
field_2_current_country = in.readShort(); | |||
} | |||
/** |
@@ -32,7 +32,7 @@ public interface CustomField | |||
* @param offset of the record's data (provided a big array of the file) | |||
* @return the number of bytes read. | |||
*/ | |||
int fillField(byte [] data, short size, int offset); | |||
int fillField(RecordInputStream in); | |||
/** | |||
* Appends the string representation of this field to the supplied |
@@ -49,23 +49,9 @@ public class DBCellRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DBCellRecord(short id, short size, byte [] data) | |||
public DBCellRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DBCellRecord and sets its fields appropriately | |||
* | |||
* @param id id must be 0xd7 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DBCellRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -76,16 +62,15 @@ public class DBCellRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_row_offset = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_cell_offsets = new short[ (size - 4) / 2 ]; | |||
int element = 0; | |||
field_1_row_offset = in.readUShort(); | |||
int size = in.remaining(); | |||
field_2_cell_offsets = new short[ size / 2 ]; | |||
for (int k = 4; k < data.length; k += 2) | |||
for (int i=0;i<field_2_cell_offsets.length;i++) | |||
{ | |||
field_2_cell_offsets[ element++ ] = LittleEndian.getShort(data, | |||
k + offset); | |||
field_2_cell_offsets[ i ] = in.readShort(); | |||
} | |||
} | |||
@@ -47,23 +47,9 @@ public class DSFRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DSFRecord(short id, short size, byte [] data) | |||
public DSFRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DBCellRecord and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x161 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DSFRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -74,9 +60,9 @@ public class DSFRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_dsf = LittleEndian.getShort(data, 0 + offset); | |||
field_1_dsf = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -55,25 +54,9 @@ public class DatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DatRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Dat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1063 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DatRecord(short id, short size, byte [] data, int offset) | |||
public DatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -90,11 +73,11 @@ public class DatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_options = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -55,25 +54,9 @@ public class DataFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DataFormatRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DataFormat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1006 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DataFormatRecord(short id, short size, byte [] data, int offset) | |||
public DataFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -90,14 +73,14 @@ public class DataFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_pointNumber = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_seriesIndex = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_seriesNumber = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_formatFlags = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_1_pointNumber = in.readShort(); | |||
field_2_seriesIndex = in.readShort(); | |||
field_3_seriesNumber = in.readShort(); | |||
field_4_formatFlags = in.readShort(); | |||
} | |||
@@ -47,24 +47,9 @@ public class DateWindow1904Record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DateWindow1904Record(short id, short size, byte [] data) | |||
public DateWindow1904Record(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DateWindow1904 record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x22 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DateWindow1904Record(short id, short size, byte [] data, | |||
int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -75,9 +60,9 @@ public class DateWindow1904Record | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_window = LittleEndian.getShort(data, 0 + offset); | |||
field_1_window = in.readShort(); | |||
} | |||
/** |
@@ -48,24 +48,9 @@ public class DefaultColWidthRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DefaultColWidthRecord(short id, short size, byte [] data) | |||
public DefaultColWidthRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DefaultColumnWidth record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x55 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DefaultColWidthRecord(short id, short size, byte [] data, | |||
int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -76,9 +61,9 @@ public class DefaultColWidthRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_col_width = LittleEndian.getShort(data, 0 + offset); | |||
field_1_col_width = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -54,25 +53,9 @@ public class DefaultDataLabelTextPropertiesRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DefaultDataLabelTextPropertiesRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DefaultDataLabelTextProperties record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1024 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DefaultDataLabelTextPropertiesRecord(short id, short size, byte [] data, int offset) | |||
public DefaultDataLabelTextPropertiesRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -89,11 +72,11 @@ public class DefaultDataLabelTextPropertiesRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_categoryDataType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_categoryDataType = in.readShort(); | |||
} | |||
@@ -49,24 +49,9 @@ public class DefaultRowHeightRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DefaultRowHeightRecord(short id, short size, byte [] data) | |||
public DefaultRowHeightRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a DefaultRowHeight record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x225 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the records data | |||
*/ | |||
public DefaultRowHeightRecord(short id, short size, byte [] data, | |||
int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -77,10 +62,10 @@ public class DefaultRowHeightRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_option_flags = LittleEndian.getShort(data, 0 + offset); | |||
field_2_row_height = LittleEndian.getShort(data, 2 + offset); | |||
field_1_option_flags = in.readShort(); | |||
field_2_row_height = in.readShort(); | |||
} | |||
/** |
@@ -51,23 +51,9 @@ public class DeltaRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DeltaRecord(short id, short size, byte [] data) | |||
public DeltaRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Delta record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x10 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of record data | |||
*/ | |||
public DeltaRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -78,9 +64,9 @@ public class DeltaRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_max_change = LittleEndian.getDouble(data, 0 + offset); | |||
field_1_max_change = in.readDouble(); | |||
} | |||
/** |
@@ -52,23 +52,9 @@ public class DimensionsRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public DimensionsRecord(short id, short size, byte [] data) | |||
public DimensionsRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Dimensions record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x200 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public DimensionsRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -79,13 +65,13 @@ public class DimensionsRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_first_row = LittleEndian.getInt(data, 0 + offset); | |||
field_2_last_row = LittleEndian.getInt(data, 4 + offset); | |||
field_3_first_col = LittleEndian.getShort(data, 8 + offset); | |||
field_4_last_col = LittleEndian.getShort(data, 10 + offset); | |||
field_5_zero = LittleEndian.getShort(data, 12 + offset); | |||
field_1_first_row = in.readInt(); | |||
field_2_last_row = in.readInt(); | |||
field_3_first_col = in.readShort(); | |||
field_4_last_col = in.readShort(); | |||
field_5_zero = in.readShort(); | |||
} | |||
/** |
@@ -36,14 +36,9 @@ public class DrawingGroupRecord extends AbstractEscherHolderRecord | |||
{ | |||
} | |||
public DrawingGroupRecord( short id, short size, byte[] data ) | |||
public DrawingGroupRecord( RecordInputStream in ) | |||
{ | |||
super( id, size, data ); | |||
} | |||
public DrawingGroupRecord( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super( in ); | |||
} | |||
protected String getRecordName() |
@@ -27,14 +27,9 @@ public class DrawingRecord extends Record | |||
{ | |||
} | |||
public DrawingRecord( short id, short size, byte[] data ) | |||
public DrawingRecord( RecordInputStream in ) | |||
{ | |||
super( id, size, data ); | |||
} | |||
public DrawingRecord( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super( in ); | |||
} | |||
/** | |||
@@ -50,22 +45,9 @@ public class DrawingRecord extends Record | |||
} | |||
} | |||
protected void fillFields( byte[] data, short size, int offset ) | |||
{ | |||
if (offset == 0 && size == data.length) | |||
{ | |||
recordData = data; | |||
} | |||
else | |||
{ | |||
recordData = new byte[size]; | |||
System.arraycopy(data, offset, recordData, 0, size); | |||
} | |||
} | |||
protected void fillFields( byte[] data, short size ) | |||
protected void fillFields( RecordInputStream in ) | |||
{ | |||
recordData = data; | |||
recordData = in.readRemainder(); | |||
} | |||
public void processContinueRecord( byte[] record ) |
@@ -29,14 +29,9 @@ public class DrawingRecordForBiffViewer | |||
{ | |||
} | |||
public DrawingRecordForBiffViewer( short id, short size, byte[] data ) | |||
public DrawingRecordForBiffViewer( RecordInputStream in) | |||
{ | |||
super( id, size, data ); | |||
} | |||
public DrawingRecordForBiffViewer( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super(in); | |||
} | |||
protected String getRecordName() |
@@ -24,14 +24,9 @@ public class DrawingSelectionRecord extends AbstractEscherHolderRecord | |||
{ | |||
} | |||
public DrawingSelectionRecord( short id, short size, byte[] data ) | |||
public DrawingSelectionRecord( RecordInputStream in ) | |||
{ | |||
super( id, size, data ); | |||
} | |||
public DrawingSelectionRecord( short id, short size, byte[] data, int offset ) | |||
{ | |||
super( id, size, data, offset ); | |||
super( in ); | |||
} | |||
protected String getRecordName() |
@@ -48,23 +48,9 @@ public class EOFRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public EOFRecord(short id, short size, byte [] data) | |||
public EOFRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a EOFRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x0A or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public EOFRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -75,7 +61,7 @@ public class EOFRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
} | |||
@@ -46,24 +46,11 @@ public class EndRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public EndRecord(short id, short size, byte [] data) | |||
public EndRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs a EndRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1034 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public EndRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
} | |||
protected void validateSid(short id) | |||
{ | |||
@@ -73,7 +60,7 @@ public class EndRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -50,25 +49,9 @@ public class EndSubRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public EndSubRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a End record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x00 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public EndSubRecord(short id, short size, byte [] data, int offset) | |||
public EndSubRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -85,7 +68,7 @@ public class EndSubRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; |
@@ -49,14 +49,9 @@ public class ExtSSTInfoSubRecord | |||
{ | |||
} | |||
public ExtSSTInfoSubRecord(short id, short size, byte [] data) | |||
public ExtSSTInfoSubRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
public ExtSSTInfoSubRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -65,11 +60,11 @@ public class ExtSSTInfoSubRecord | |||
// do nothing | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_stream_pos = LittleEndian.getInt(data, 0 + offset); | |||
field_2_bucket_sst_offset = LittleEndian.getShort(data, 4 + offset); | |||
field_3_zero = LittleEndian.getShort(data, 6 + offset); | |||
field_1_stream_pos = in.readInt(); | |||
field_2_bucket_sst_offset = in.readShort(); | |||
field_3_zero = in.readShort(); | |||
} | |||
public void setStreamPos(int pos) |
@@ -60,23 +60,9 @@ public class ExtSSTRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ExtSSTRecord(short id, short size, byte [] data) | |||
public ExtSSTRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a EOFRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xff or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ExtSSTRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -87,17 +73,12 @@ public class ExtSSTRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_2_sst_info = new ArrayList(); | |||
field_1_strings_per_bucket = LittleEndian.getShort(data, 0 + offset); | |||
for (int k = 2; k < (size-offset); k += 8) | |||
{ | |||
byte[] tempdata = new byte[ 8 + offset ]; | |||
System.arraycopy(data, k, tempdata, 0, 8); | |||
ExtSSTInfoSubRecord rec = new ExtSSTInfoSubRecord(( short ) 0, | |||
( short ) 8, tempdata); | |||
field_1_strings_per_bucket = in.readShort(); | |||
while (in.remaining() > 0) { | |||
ExtSSTInfoSubRecord rec = new ExtSSTInfoSubRecord(in); | |||
field_2_sst_info.add(rec); | |||
} |
@@ -201,23 +201,9 @@ public class ExtendedFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ExtendedFormatRecord(short id, short size, byte [] data) | |||
public ExtendedFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an ExtendedFormat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xE0 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ExtendedFormatRecord(short id, short size, byte [] data, | |||
int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -228,25 +214,17 @@ public class ExtendedFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
{ | |||
field_1_font_index = LittleEndian.getShort(data, | |||
0 + offset); | |||
field_2_format_index = LittleEndian.getShort(data, | |||
2 + offset); | |||
field_3_cell_options = LittleEndian.getShort(data, | |||
4 + offset); | |||
field_4_alignment_options = LittleEndian.getShort(data, | |||
6 + offset); | |||
field_5_indention_options = LittleEndian.getShort(data, | |||
8 + offset); | |||
field_6_border_options = LittleEndian.getShort(data, | |||
10 + offset); | |||
field_7_palette_options = LittleEndian.getShort(data, | |||
12 + offset); | |||
field_8_adtl_palette_options = LittleEndian.getInt(data, 14 + offset); | |||
field_9_fill_palette_options = LittleEndian.getShort(data, | |||
18 + offset); | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_font_index = in.readShort(); | |||
field_2_format_index = in.readShort(); | |||
field_3_cell_options = in.readShort(); | |||
field_4_alignment_options = in.readShort(); | |||
field_5_indention_options = in.readShort(); | |||
field_6_border_options = in.readShort(); | |||
field_7_palette_options = in.readShort(); | |||
field_8_adtl_palette_options = in.readInt(); | |||
field_9_fill_palette_options = in.readShort(); | |||
} | |||
/** |
@@ -47,20 +47,8 @@ public class ExternSheetRecord extends Record { | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ExternSheetRecord(short id, short size, byte[] data) { | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Extern Sheet record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x16 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ExternSheetRecord(short id, short size, byte[] data, int offset) { | |||
super(id, size, data, offset); | |||
public ExternSheetRecord(RecordInputStream in) { | |||
super(in); | |||
} | |||
/** | |||
@@ -83,16 +71,13 @@ public class ExternSheetRecord extends Record { | |||
* @param size size of data | |||
* @param offset of the record's data (provided a big array of the file) | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) { | |||
protected void fillFields(RecordInputStream in) { | |||
field_2_REF_structures = new ArrayList(); | |||
field_1_number_of_REF_sturcutres = LittleEndian.getShort(data, 0 + offset); | |||
field_1_number_of_REF_sturcutres = in.readShort(); | |||
int pos = 2 + offset; | |||
for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) { | |||
ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos); | |||
pos += 6; | |||
ExternSheetSubRecord rec = new ExternSheetSubRecord(in); | |||
field_2_REF_structures.add( rec); | |||
} |
@@ -47,21 +47,10 @@ public class ExternSheetSubRecord extends Record { | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ExternSheetSubRecord(short id, short size, byte[] data) { | |||
super(id, size, data); | |||
public ExternSheetSubRecord(RecordInputStream in) { | |||
super(in); | |||
} | |||
/** | |||
* Constructs a Extern Sheet Sub Record record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x18 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ExternSheetSubRecord(short id, short size, byte[] data, int offset) { | |||
super(id, size, data, offset); | |||
} | |||
/** Sets the Index to the sup book | |||
* @param index sup book index | |||
@@ -123,10 +112,10 @@ public class ExternSheetSubRecord extends Record { | |||
* @param size size of data | |||
* @param offset of the record's data (provided a big array of the file) | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) { | |||
field_1_index_to_supbook = LittleEndian.getShort(data, 0 + offset); | |||
field_2_index_to_first_supbook_sheet = LittleEndian.getShort(data, 2 + offset); | |||
field_3_index_to_last_supbook_sheet = LittleEndian.getShort(data, 4 + offset); | |||
protected void fillFields(RecordInputStream in) { | |||
field_1_index_to_supbook = in.readShort(); | |||
field_2_index_to_first_supbook_sheet = in.readShort(); | |||
field_3_index_to_last_supbook_sheet = in.readShort(); | |||
} | |||
@@ -53,23 +53,9 @@ public class FnGroupCountRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FnGroupCountRecord(short id, short size, byte [] data) | |||
public FnGroupCountRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a FnGroupCount record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x9c or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FnGroupCountRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -80,9 +66,9 @@ public class FnGroupCountRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_count = LittleEndian.getShort(data, 0 + offset); | |||
field_1_count = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -55,25 +54,9 @@ public class FontBasisRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FontBasisRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a FontBasis record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1060 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FontBasisRecord(short id, short size, byte [] data, int offset) | |||
public FontBasisRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -90,15 +73,15 @@ public class FontBasisRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_xBasis = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_yBasis = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_heightBasis = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_scale = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_5_indexToFontTable = LittleEndian.getShort(data, pos + 0x8 + offset); | |||
field_1_xBasis = in.readShort(); | |||
field_2_yBasis = in.readShort(); | |||
field_3_heightBasis = in.readShort(); | |||
field_4_scale = in.readShort(); | |||
field_5_indexToFontTable = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -51,25 +50,9 @@ public class FontIndexRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FontIndexRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a FontIndex record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1026 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FontIndexRecord(short id, short size, byte [] data, int offset) | |||
public FontIndexRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -86,11 +69,11 @@ public class FontIndexRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_fontIndex = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_fontIndex = in.readShort(); | |||
} | |||
@@ -83,24 +83,9 @@ public class FontRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FontRecord(short id, short size, byte [] data) | |||
public FontRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Font record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x31 (NOT 0x231 see MSKB #Q184647 for an "explanation of | |||
* this bug in the documentation) or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FontRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -111,29 +96,27 @@ public class FontRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_font_height = LittleEndian.getShort(data, 0 + offset); | |||
field_2_attributes = LittleEndian.getShort(data, 2 + offset); | |||
field_3_color_palette_index = LittleEndian.getShort(data, 4 + offset); | |||
field_4_bold_weight = LittleEndian.getShort(data, 6 + offset); | |||
field_5_super_sub_script = LittleEndian.getShort(data, 8 + offset); | |||
field_6_underline = data[ 10 + offset ]; | |||
field_7_family = data[ 11 + offset ]; | |||
field_8_charset = data[ 12 + offset ]; | |||
field_9_zero = data[ 13 + offset ]; | |||
field_10_font_name_len = data[ 14 + offset ]; | |||
field_1_font_height = in.readShort(); | |||
field_2_attributes = in.readShort(); | |||
field_3_color_palette_index = in.readShort(); | |||
field_4_bold_weight = in.readShort(); | |||
field_5_super_sub_script = in.readShort(); | |||
field_6_underline = in.readByte(); | |||
field_7_family = in.readByte(); | |||
field_8_charset = in.readByte(); | |||
field_9_zero = in.readByte(); | |||
field_10_font_name_len = in.readByte(); | |||
if (field_10_font_name_len > 0) | |||
{ | |||
if (data[ 15 ] == 0) | |||
if (in.readByte() == 0) | |||
{ // is compressed unicode | |||
field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16, | |||
LittleEndian.ubyteToInt(field_10_font_name_len)); | |||
field_11_font_name = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_10_font_name_len)); | |||
} | |||
else | |||
{ // is not compressed unicode | |||
field_11_font_name = StringUtil.getFromUnicodeLE(data, 16, | |||
field_10_font_name_len); | |||
field_11_font_name = in.readUnicodeLEString(field_10_font_name_len); | |||
} | |||
} | |||
} |
@@ -36,8 +36,9 @@ public class FooterRecord | |||
{ | |||
public final static short sid = 0x15; | |||
private byte field_1_footer_len; | |||
private byte field_2_unicode_flag; | |||
private String field_3_footer; | |||
private byte field_2_reserved; | |||
private byte field_3_unicode_flag; | |||
private String field_4_footer; | |||
public FooterRecord() | |||
{ | |||
@@ -51,23 +52,9 @@ public class FooterRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FooterRecord(short id, short size, byte [] data) | |||
public FooterRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a FooterRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x15 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FooterRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -78,21 +65,22 @@ public class FooterRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
if (size > 0) | |||
if (in.remaining() > 0) | |||
{ | |||
field_1_footer_len = data[ 0 + offset ]; | |||
field_2_unicode_flag = data[ 2 + offset ]; | |||
field_1_footer_len = in.readByte(); | |||
/** These two fields are a bit odd. They are not documented*/ | |||
field_2_reserved = in.readByte(); | |||
field_3_unicode_flag = in.readByte(); // unicode | |||
if(isMultibyte()) | |||
{ | |||
field_3_footer = StringUtil.getFromUnicodeLE( | |||
data,3 + offset,LittleEndian.ubyteToInt(field_1_footer_len)); | |||
field_4_footer = in.readUnicodeLEString(LittleEndian.ubyteToInt( field_1_footer_len)); | |||
} | |||
else | |||
{ | |||
field_3_footer = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string | |||
LittleEndian.ubyteToInt( field_1_footer_len) ); | |||
field_4_footer = in.readCompressedUnicode(LittleEndian.ubyteToInt( field_1_footer_len)); | |||
} | |||
} | |||
} | |||
@@ -104,7 +92,7 @@ public class FooterRecord | |||
* true:footer string has at least one multibyte character | |||
*/ | |||
public boolean isMultibyte() { | |||
return ((field_2_unicode_flag & 0xFF) == 1); | |||
return ((field_3_unicode_flag & 0xFF) == 1); | |||
} | |||
@@ -129,9 +117,9 @@ public class FooterRecord | |||
public void setFooter(String footer) | |||
{ | |||
field_3_footer = footer; | |||
field_2_unicode_flag = | |||
(byte) (StringUtil.hasMultibyte(field_3_footer) ? 1 : 0); | |||
field_4_footer = footer; | |||
field_3_unicode_flag = | |||
(byte) (StringUtil.hasMultibyte(field_4_footer) ? 1 : 0); | |||
} | |||
/** | |||
@@ -155,7 +143,7 @@ public class FooterRecord | |||
public String getFooter() | |||
{ | |||
return field_3_footer; | |||
return field_4_footer; | |||
} | |||
public String toString() | |||
@@ -187,7 +175,7 @@ public class FooterRecord | |||
if (getFooterLength() > 0) | |||
{ | |||
data[ 4 + offset ] = (byte)getFooterLength(); | |||
data[ 6 + offset ] = field_2_unicode_flag; | |||
data[ 6 + offset ] = field_3_unicode_flag; | |||
if(isMultibyte()) | |||
{ | |||
StringUtil.putUnicodeLE(getFooter(), data, 7 + offset); | |||
@@ -220,8 +208,9 @@ public class FooterRecord | |||
public Object clone() { | |||
FooterRecord rec = new FooterRecord(); | |||
rec.field_1_footer_len = field_1_footer_len; | |||
rec.field_2_unicode_flag = field_2_unicode_flag; | |||
rec.field_3_footer = field_3_footer; | |||
rec.field_2_reserved = field_2_reserved; | |||
rec.field_3_unicode_flag = field_3_unicode_flag; | |||
rec.field_4_footer = field_4_footer; | |||
return rec; | |||
} | |||
} |
@@ -53,23 +53,9 @@ public class FormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FormatRecord(short id, short size, byte [] data) | |||
public FormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Format record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x41e or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FormatRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -80,22 +66,19 @@ public class FormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_index_code = LittleEndian.getShort(data, 0 + offset); | |||
// field_2_formatstring_len = data[ 2 + offset ]; | |||
field_3_unicode_len = LittleEndian.getShort( data, 2 + offset ); | |||
field_3_unicode_flag = ( data[ 4 + offset ] & (byte)0x01 ) != 0; | |||
field_1_index_code = in.readShort(); | |||
field_3_unicode_len = in.readShort(); | |||
field_3_unicode_flag = ( in.readByte() & (byte)0x01 ) != 0; | |||
if ( field_3_unicode_flag ) { | |||
// unicode | |||
field_4_formatstring = StringUtil.getFromUnicodeLE( data, 5 + offset, field_3_unicode_len ); | |||
field_4_formatstring = in.readUnicodeLEString( field_3_unicode_len ); | |||
} | |||
else { | |||
// not unicode | |||
field_4_formatstring = StringUtil.getFromCompressedUnicode(data, 5 + offset, field_3_unicode_len ); | |||
field_4_formatstring = in.readCompressedUnicode( field_3_unicode_len ); | |||
} | |||
} | |||
@@ -80,68 +80,40 @@ public class FormulaRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FormulaRecord(short id, short size, byte [] data) | |||
public FormulaRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs a Formula record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x06 (NOT 0x406 see MSKB #Q184647 for an "explanation of | |||
* this bug in the documentation) or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FormulaRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
try { | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_column = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf = LittleEndian.getShort(data, 4 + offset); | |||
field_4_value = LittleEndian.getDouble(data, 6 + offset); | |||
field_5_options = LittleEndian.getShort(data, 14 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_column = in.readShort(); | |||
field_3_xf = in.readShort(); | |||
field_4_value = in.readDouble(); | |||
field_5_options = in.readShort(); | |||
if (Double.isNaN(field_4_value)) { | |||
value_data = new byte[8]; | |||
System.arraycopy(data, offset+6, value_data, 0, 8); | |||
value_data = in.getNANData(); | |||
} | |||
field_6_zero = LittleEndian.getInt(data, 16 + offset); | |||
field_7_expression_len = LittleEndian.getShort(data, 20 + offset); | |||
field_8_parsed_expr = getParsedExpressionTokens(data, size, | |||
22 + offset); | |||
field_6_zero = in.readInt(); | |||
field_7_expression_len = in.readShort(); | |||
field_8_parsed_expr = getParsedExpressionTokens(in, field_7_expression_len); | |||
} catch (java.lang.UnsupportedOperationException uoe) { | |||
field_8_parsed_expr = null; | |||
all_data = new byte[size+4]; | |||
LittleEndian.putShort(all_data,0,sid); | |||
LittleEndian.putShort(all_data,2,size); | |||
System.arraycopy(data,offset,all_data,4,size); | |||
System.err.println("[WARNING] Unknown Ptg " | |||
+ uoe.getMessage() | |||
+ " at cell ("+field_1_row+","+field_2_column+")"); | |||
throw new RecordFormatException(uoe.toString()); | |||
} | |||
} | |||
private Stack getParsedExpressionTokens(byte [] data, short size, | |||
int offset) | |||
private Stack getParsedExpressionTokens(RecordInputStream in, short size) | |||
{ | |||
Stack stack = new Stack(); | |||
int pos = offset; | |||
int pos = 0; | |||
while (pos < size) | |||
{ | |||
Ptg ptg = Ptg.createPtg(data, pos); | |||
Ptg ptg = Ptg.createPtg(in); | |||
pos += ptg.getSize(); | |||
stack.push(ptg); | |||
} |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -56,25 +55,9 @@ public class FrameRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public FrameRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Frame record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1032 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public FrameRecord(short id, short size, byte [] data, int offset) | |||
public FrameRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -91,12 +74,12 @@ public class FrameRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_borderType = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_options = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_1_borderType = in.readShort(); | |||
field_2_options = in.readShort(); | |||
} | |||
@@ -51,23 +51,9 @@ public class GridsetRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public GridsetRecord(short id, short size, byte [] data) | |||
public GridsetRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a GridSet record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x82 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public GridsetRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -78,9 +64,9 @@ public class GridsetRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_gridset_flag = LittleEndian.getShort(data, 0 + offset); | |||
field_1_gridset_flag = in.readShort(); | |||
} | |||
/** |
@@ -49,25 +49,9 @@ public class GroupMarkerSubRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public GroupMarkerSubRecord(short id, short size, byte [] data) | |||
public GroupMarkerSubRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a group marker record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x00 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public GroupMarkerSubRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -84,11 +68,10 @@ public class GroupMarkerSubRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
// int pos = 0; | |||
reserved = new byte[size]; | |||
System.arraycopy(data, offset, reserved, 0, size); | |||
reserved = in.readRemainder(); | |||
} | |||
public String toString() |
@@ -50,23 +50,9 @@ public class GutsRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public GutsRecord(short id, short size, byte [] data) | |||
public GutsRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Guts record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x80 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public GutsRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -77,12 +63,12 @@ public class GutsRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_left_row_gutter = LittleEndian.getShort(data, 0 + offset); | |||
field_2_top_col_gutter = LittleEndian.getShort(data, 2 + offset); | |||
field_3_row_level_max = LittleEndian.getShort(data, 4 + offset); | |||
field_4_col_level_max = LittleEndian.getShort(data, 6 + offset); | |||
field_1_left_row_gutter = in.readShort(); | |||
field_2_top_col_gutter = in.readShort(); | |||
field_3_row_level_max = in.readShort(); | |||
field_4_col_level_max = in.readShort(); | |||
} | |||
/** |
@@ -47,23 +47,9 @@ public class HCenterRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public HCenterRecord(short id, short size, byte [] data) | |||
public HCenterRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an HCenter record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x83 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public HCenterRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -74,9 +60,9 @@ public class HCenterRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_hcenter = LittleEndian.getShort(data, 0 + offset); | |||
field_1_hcenter = in.readShort(); | |||
} | |||
/** |
@@ -36,8 +36,9 @@ public class HeaderRecord | |||
{ | |||
public final static short sid = 0x14; | |||
private byte field_1_header_len; | |||
private byte field_2_unicode_flag; | |||
private String field_3_header; | |||
private byte field_2_reserved; | |||
private byte field_3_unicode_flag; | |||
private String field_4_header; | |||
public HeaderRecord() | |||
{ | |||
@@ -51,23 +52,9 @@ public class HeaderRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public HeaderRecord(short id, short size, byte [] data) | |||
public HeaderRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an Header record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x14 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public HeaderRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -78,21 +65,22 @@ public class HeaderRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
if (size > 0) | |||
if (in.remaining() > 0) | |||
{ | |||
field_1_header_len = data[ 0 + offset ]; | |||
field_2_unicode_flag = data[ 2 + offset ]; | |||
field_1_header_len = in.readByte(); | |||
/** These two fields are a bit odd. They are not documented*/ | |||
field_2_reserved = in.readByte(); | |||
field_3_unicode_flag = in.readByte(); // unicode | |||
if(isMultibyte()) | |||
{ | |||
field_3_header = StringUtil.getFromUnicodeLE( | |||
data,3 + offset,LittleEndian.ubyteToInt(field_1_header_len)); | |||
field_4_header = in.readUnicodeLEString(LittleEndian.ubyteToInt( field_1_header_len)); | |||
} | |||
else | |||
{ | |||
field_3_header = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string | |||
LittleEndian.ubyteToInt( field_1_header_len) ); | |||
field_4_header = in.readCompressedUnicode(LittleEndian.ubyteToInt( field_1_header_len)); | |||
} | |||
} | |||
} | |||
@@ -104,7 +92,7 @@ public class HeaderRecord | |||
* true:footer string has at least one multibyte character | |||
*/ | |||
public boolean isMultibyte() { | |||
return ((field_2_unicode_flag & 0xFF) == 1); | |||
return ((field_3_unicode_flag & 0xFF) == 1); | |||
} | |||
/** | |||
@@ -128,9 +116,9 @@ public class HeaderRecord | |||
public void setHeader(String header) | |||
{ | |||
field_3_header = header; | |||
field_2_unicode_flag = | |||
(byte) (StringUtil.hasMultibyte(field_3_header) ? 1 : 0); | |||
field_4_header = header; | |||
field_3_unicode_flag = | |||
(byte) (StringUtil.hasMultibyte(field_4_header) ? 1 : 0); | |||
} | |||
/** | |||
@@ -154,7 +142,7 @@ public class HeaderRecord | |||
public String getHeader() | |||
{ | |||
return field_3_header; | |||
return field_4_header; | |||
} | |||
public String toString() | |||
@@ -187,7 +175,7 @@ public class HeaderRecord | |||
if (getHeaderLength() > 0) | |||
{ | |||
data[ 4 + offset ] = (byte)getHeaderLength(); | |||
data[ 6 + offset ] = field_2_unicode_flag; | |||
data[ 6 + offset ] = field_3_unicode_flag; | |||
if(isMultibyte()) | |||
{ | |||
StringUtil.putUnicodeLE(getHeader(), data, 7 + offset); | |||
@@ -220,8 +208,9 @@ public class HeaderRecord | |||
public Object clone() { | |||
HeaderRecord rec = new HeaderRecord(); | |||
rec.field_1_header_len = field_1_header_len; | |||
rec.field_2_unicode_flag = field_2_unicode_flag; | |||
rec.field_3_header = field_3_header; | |||
rec.field_2_reserved = field_2_reserved; | |||
rec.field_3_unicode_flag = field_3_unicode_flag; | |||
rec.field_4_header = field_4_header; | |||
return rec; | |||
} | |||
} |
@@ -49,23 +49,9 @@ public class HideObjRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public HideObjRecord(short id, short size, byte [] data) | |||
public HideObjRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an HideObj record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x8d or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public HideObjRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -76,9 +62,9 @@ public class HideObjRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_hide_obj = LittleEndian.getShort(data, 0 + offset); | |||
field_1_hide_obj = in.readShort(); | |||
} | |||
/** |
@@ -47,18 +47,8 @@ public class HorizontalPageBreakRecord extends PageBreakRecord { | |||
* @param size | |||
* @param data | |||
*/ | |||
public HorizontalPageBreakRecord(short id, short size, byte[] data) { | |||
super(id, size, data); | |||
} | |||
/** | |||
* @param id | |||
* @param size | |||
* @param data | |||
* @param offset | |||
*/ | |||
public HorizontalPageBreakRecord(short id, short size, byte[] data, int offset) { | |||
super(id, size, data, offset); | |||
public HorizontalPageBreakRecord(RecordInputStream in) { | |||
super(in); | |||
} | |||
/* (non-Javadoc) |
@@ -55,23 +55,9 @@ public class IndexRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public IndexRecord(short id, short size, byte [] data) | |||
public IndexRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an Index record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x208 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of record data | |||
*/ | |||
public IndexRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -82,19 +68,19 @@ public class IndexRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_5_dbcells = | |||
new IntList(DBCELL_CAPACITY); // initial capacity of 30 | |||
field_1_zero = LittleEndian.getInt(data, 0 + offset); | |||
field_2_first_row = LittleEndian.getInt(data, 4 + offset); | |||
field_3_last_row_add1 = LittleEndian.getInt(data, 8 + offset); | |||
field_4_zero = LittleEndian.getInt(data, 12 + offset); | |||
for (int k = 16; k < size; k = k + 4) | |||
field_1_zero = in.readInt(); | |||
field_2_first_row = in.readInt(); | |||
field_3_last_row_add1 = in.readInt(); | |||
field_4_zero = in.readInt(); | |||
while(in.remaining() > 0) | |||
{ | |||
// System.out.println("getting " + k); | |||
field_5_dbcells.add(LittleEndian.getInt(data, k + offset)); | |||
field_5_dbcells.add(in.readInt()); | |||
} | |||
} | |||
@@ -46,23 +46,9 @@ public class InterfaceEndRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public InterfaceEndRecord(short id, short size, byte [] data) | |||
public InterfaceEndRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an InterfaceEnd record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xe2 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the data | |||
*/ | |||
public InterfaceEndRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -73,7 +59,7 @@ public class InterfaceEndRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
} | |||
@@ -52,23 +52,9 @@ public class InterfaceHdrRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public InterfaceHdrRecord(short id, short size, byte [] data) | |||
public InterfaceHdrRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an Codepage record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xe1 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public InterfaceHdrRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -79,9 +65,9 @@ public class InterfaceHdrRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_codepage = LittleEndian.getShort(data, 0 + offset); | |||
field_1_codepage = in.readShort(); | |||
} | |||
/** |
@@ -50,23 +50,9 @@ public class IterationRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public IterationRecord(short id, short size, byte [] data) | |||
public IterationRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an Iteration record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x11 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public IterationRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -77,9 +63,9 @@ public class IterationRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_iteration = LittleEndian.getShort(data, 0 + offset); | |||
field_1_iteration = in.readShort(); | |||
} | |||
/** |
@@ -63,23 +63,9 @@ public class LabelRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LabelRecord(short id, short size, byte [] data) | |||
public LabelRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs an Label record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x204 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record | |||
*/ | |||
public LabelRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -105,22 +91,19 @@ public class LabelRecord | |||
* @param size size of data | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_column = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); | |||
field_4_string_len = LittleEndian.getShort(data, 6 + offset); | |||
field_5_unicode_flag = data[ 8 + offset ]; | |||
field_1_row = in.readUShort(); | |||
field_2_column = in.readShort(); | |||
field_3_xf_index = in.readShort(); | |||
field_4_string_len = in.readShort(); | |||
field_5_unicode_flag = in.readByte(); | |||
if (field_4_string_len > 0) { | |||
if (isUnCompressedUnicode()) { | |||
field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset, | |||
field_4_string_len); | |||
} | |||
else { | |||
field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, | |||
getStringLength()); | |||
field_6_value = in.readUnicodeLEString(field_4_string_len); | |||
} else { | |||
field_6_value = in.readCompressedUnicode(field_4_string_len); | |||
} | |||
} else field_6_value = null; | |||
} |
@@ -53,24 +53,11 @@ public class LabelSSTRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LabelSSTRecord(short id, short size, byte [] data) | |||
public LabelSSTRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs an LabelSST record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xfd or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public LabelSSTRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
} | |||
protected void validateSid(short id) | |||
{ | |||
@@ -80,13 +67,13 @@ public class LabelSSTRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_column = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); | |||
field_4_sst_index = LittleEndian.getInt(data, 6 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_column = in.readShort(); | |||
field_3_xf_index = in.readShort(); | |||
field_4_sst_index = in.readInt(); | |||
} | |||
//public void setRow(short row) |
@@ -38,19 +38,8 @@ public class LeftMarginRecord extends Record implements Margin | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LeftMarginRecord( short id, short size, byte[] data ) | |||
{ super( id, size, data ); } | |||
/** | |||
* Constructs a LeftMargin record and sets its fields appropriately. | |||
* @param id id must be 0x26 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public LeftMarginRecord( short id, short size, byte[] data, int offset ) | |||
{ super( id, size, data, offset ); } | |||
public LeftMarginRecord(RecordInputStream in) | |||
{ super(in); } | |||
/** | |||
* Checks the sid matches the expected side for this record | |||
@@ -65,9 +54,9 @@ public class LeftMarginRecord extends Record implements Margin | |||
} | |||
} | |||
protected void fillFields( byte[] data, short size, int offset ) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_margin = LittleEndian.getDouble( data, 0x0 + offset ); | |||
field_1_margin = in.readDouble(); | |||
} | |||
public String toString() |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -72,25 +71,9 @@ public class LegendRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LegendRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Legend record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1015 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public LegendRecord(short id, short size, byte [] data, int offset) | |||
public LegendRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -107,17 +90,17 @@ public class LegendRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_xAxisUpperLeft = LittleEndian.getInt(data, pos + 0x0 + offset); | |||
field_2_yAxisUpperLeft = LittleEndian.getInt(data, pos + 0x4 + offset); | |||
field_3_xSize = LittleEndian.getInt(data, pos + 0x8 + offset); | |||
field_4_ySize = LittleEndian.getInt(data, pos + 0xc + offset); | |||
field_5_type = data[ pos + 0x10 + offset ]; | |||
field_6_spacing = data[ pos + 0x11 + offset ]; | |||
field_7_options = LittleEndian.getShort(data, pos + 0x12 + offset); | |||
field_1_xAxisUpperLeft = in.readInt(); | |||
field_2_yAxisUpperLeft = in.readInt(); | |||
field_3_xSize = in.readInt(); | |||
field_4_ySize = in.readInt(); | |||
field_5_type = in.readByte(); | |||
field_6_spacing = in.readByte(); | |||
field_7_options = in.readShort(); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -71,25 +70,9 @@ public class LineFormatRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LineFormatRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a LineFormat record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1007 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public LineFormatRecord(short id, short size, byte [] data, int offset) | |||
public LineFormatRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -106,15 +89,15 @@ public class LineFormatRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_lineColor = LittleEndian.getInt(data, pos + 0x0 + offset); | |||
field_2_linePattern = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_3_weight = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_4_format = LittleEndian.getShort(data, pos + 0x8 + offset); | |||
field_5_colourPaletteIndex = LittleEndian.getShort(data, pos + 0xa + offset); | |||
field_1_lineColor = in.readInt(); | |||
field_2_linePattern = in.readShort(); | |||
field_3_weight = in.readShort(); | |||
field_4_format = in.readShort(); | |||
field_5_colourPaletteIndex = in.readShort(); | |||
} | |||
@@ -46,10 +46,10 @@ public class LinkedDataFormulaField | |||
return size + 2; | |||
} | |||
public int fillField( byte[] data, short size, int offset ) | |||
public int fillField( RecordInputStream in ) | |||
{ | |||
short tokenSize = LittleEndian.getShort(data, offset); | |||
formulaTokens = getParsedExpressionTokens(data, size, offset + 2); | |||
short tokenSize = in.readShort(); | |||
formulaTokens = getParsedExpressionTokens(tokenSize, in); | |||
return tokenSize + 2; | |||
} | |||
@@ -103,15 +103,13 @@ public class LinkedDataFormulaField | |||
} | |||
} | |||
private Stack getParsedExpressionTokens( byte[] data, short size, | |||
int offset ) | |||
private Stack getParsedExpressionTokens(short size, RecordInputStream in ) | |||
{ | |||
Stack stack = new Stack(); | |||
int pos = offset; | |||
int pos = 0; | |||
while ( pos < size ) | |||
{ | |||
Ptg ptg = Ptg.createPtg( data, pos ); | |||
Ptg ptg = Ptg.createPtg( in ); | |||
pos += ptg.getSize(); | |||
stack.push( ptg ); | |||
} |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -64,25 +63,9 @@ public class LinkedDataRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public LinkedDataRecord(short id, short size, byte [] data) | |||
public LinkedDataRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a LinkedData record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1051 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public LinkedDataRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -99,17 +82,14 @@ public class LinkedDataRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_linkType = data[ pos + 0x0 + offset ]; | |||
field_2_referenceType = data[ pos + 0x1 + offset ]; | |||
field_3_options = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_4_indexNumberFmtRecord = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_1_linkType = in.readByte(); | |||
field_2_referenceType = in.readByte(); | |||
field_3_options = in.readShort(); | |||
field_4_indexNumberFmtRecord = in.readShort(); | |||
field_5_formulaOfLink = new org.apache.poi.hssf.record.LinkedDataFormulaField(); | |||
pos += field_5_formulaOfLink.fillField(data,size,pos + offset + 6); | |||
field_5_formulaOfLink.fillField(in); | |||
} | |||
public String toString() |
@@ -48,23 +48,9 @@ public class MMSRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public MMSRecord(short id, short size, byte [] data) | |||
public MMSRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a MMS record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xc1 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the data | |||
*/ | |||
public MMSRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -75,10 +61,10 @@ public class MMSRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_addMenuCount = data[ 0 + offset ]; | |||
field_2_delMenuCount = data[ 1 + offset ]; | |||
field_1_addMenuCount = in.readByte(); | |||
field_2_delMenuCount = in.readByte(); | |||
} | |||
/** |
@@ -50,41 +50,22 @@ public class MergeCellsRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public MergeCellsRecord(short sid, short size, byte [] data) | |||
public MergeCellsRecord(RecordInputStream in) | |||
{ | |||
super(sid, size, data); | |||
super(in); | |||
} | |||
/** | |||
* Constructs a MergedCellsRecord and sets its fields appropriately | |||
* | |||
* @param sid id must be 0xe5 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset the offset of the record's data | |||
*/ | |||
public MergeCellsRecord(short sid, short size, byte [] data, int offset) | |||
{ | |||
super(sid, size, data, offset); | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
short numAreas = LittleEndian.getShort(data, 0 + offset); | |||
short numAreas = in.readShort(); | |||
field_2_regions = new ArrayList(numAreas + 10); | |||
int pos = 2; | |||
for (int k = 0; k < numAreas; k++) | |||
{ | |||
MergedRegion region = | |||
new MergedRegion(LittleEndian | |||
.getShort(data, pos + offset), LittleEndian | |||
.getShort(data, pos + 2 + offset), LittleEndian | |||
.getShort(data, pos + 4 + offset), LittleEndian | |||
.getShort(data, pos + 6 + offset)); | |||
new MergedRegion(in.readShort(), in.readShort(), | |||
in.readShort(), in.readShort()); | |||
pos += 8; | |||
field_2_regions.add(region); | |||
} | |||
} |
@@ -62,23 +62,9 @@ public class MulBlankRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public MulBlankRecord(short id, short size, byte [] data) | |||
public MulBlankRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a MulBlank record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xbe or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public MulBlankRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -142,31 +128,22 @@ public class MulBlankRecord | |||
* @param size size of data | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_first_col = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xfs = parseXFs(data, 4, offset, size); | |||
field_4_last_col = LittleEndian.getShort(data, | |||
(field_3_xfs.length * 2) | |||
+ 4 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_first_col = in.readShort(); | |||
field_3_xfs = parseXFs(in); | |||
field_4_last_col = in.readShort(); | |||
} | |||
private short [] parseXFs(byte [] data, int offset, int recoffset, | |||
short size) | |||
private short [] parseXFs(RecordInputStream in) | |||
{ | |||
short[] retval = new short[ ((size - offset) - 2) / 2 ]; | |||
int idx = 0; | |||
short[] retval = new short[ (in.remaining() - 2) / 2 ]; | |||
for (; offset < size - 2; ) | |||
for (int idx = 0; idx < retval.length;idx++) | |||
{ | |||
short xf = 0; | |||
xf = LittleEndian.getShort(data, offset + recoffset); | |||
offset += 2; | |||
retval[ idx ] = xf; | |||
idx++; | |||
retval[idx] = in.readShort(); | |||
} | |||
return retval; | |||
} |
@@ -60,23 +60,9 @@ public class MulRKRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public MulRKRecord(short id, short size, byte [] data) | |||
public MulRKRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a MulRK record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0xbd or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of data | |||
*/ | |||
public MulRKRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
//public short getRow() | |||
@@ -143,30 +129,23 @@ public class MulRKRecord | |||
* @param size size of data | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_first_col = LittleEndian.getShort(data, 2 + offset); | |||
field_3_rks = parseRKs(data, 4, offset, size); | |||
field_4_last_col = LittleEndian.getShort(data, | |||
(field_3_rks.size() * 6) | |||
+ 4 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_first_col = in.readShort(); | |||
field_3_rks = parseRKs(in); | |||
field_4_last_col = in.readShort(); | |||
} | |||
private ArrayList parseRKs(byte [] data, int offset, int recoffset, | |||
short size) | |||
private ArrayList parseRKs(RecordInputStream in) | |||
{ | |||
ArrayList retval = new ArrayList(); | |||
for (; offset < size - 2; ) | |||
{ | |||
while ((in.remaining()-2) > 0) { | |||
RkRec rec = new RkRec(); | |||
rec.xf = LittleEndian.getShort(data, offset + recoffset); | |||
offset += 2; | |||
rec.rk = LittleEndian.getInt(data, offset + recoffset); | |||
offset += 4; | |||
rec.xf = in.readShort(); | |||
rec.rk = in.readInt(); | |||
retval.add(rec); | |||
} | |||
return retval; |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
@@ -115,7 +114,6 @@ public class NameRecord extends Record { | |||
private byte field_12_builtIn_name; | |||
private String field_12_name_text; | |||
private Stack field_13_name_definition; | |||
private byte[] field_13_raw_name_definition; // raw data | |||
private String field_14_custom_menu_text; | |||
private String field_15_description_text; | |||
private String field_16_help_topic_text; | |||
@@ -140,20 +138,8 @@ public class NameRecord extends Record { | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public NameRecord(short id, short size, byte [] data) { | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Name record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x18 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public NameRecord(short id, short size, byte [] data, int offset) { | |||
super(id, size, data, offset); | |||
public NameRecord(RecordInputStream in) { | |||
super(in); | |||
} | |||
/** | |||
@@ -553,15 +539,7 @@ public class NameRecord extends Record { | |||
} | |||
if ( this.field_13_name_definition != null ) | |||
{ | |||
serializePtgs( data, start_of_name_definition + offset ); | |||
} | |||
else | |||
{ | |||
System.arraycopy( field_13_raw_name_definition, 0, data | |||
, start_of_name_definition + offset, field_13_raw_name_definition.length ); | |||
} | |||
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; | |||
@@ -731,97 +709,55 @@ public class NameRecord extends Record { | |||
* @param size size of data | |||
* @param offset of the record's data (provided a big array of the file) | |||
*/ | |||
protected void fillFields(byte[] data, short size, int offset) { | |||
field_1_option_flag = LittleEndian.getShort(data, 0 + offset); | |||
field_2_keyboard_shortcut = data [2 + offset]; | |||
field_3_length_name_text = data [3 + offset]; | |||
field_4_length_name_definition = LittleEndian.getShort(data, 4 + offset); | |||
field_5_index_to_sheet = LittleEndian.getShort(data, 6 + offset); | |||
field_6_equals_to_index_to_sheet= LittleEndian.getShort(data, 8 + offset); | |||
field_7_length_custom_menu = data [10 + offset]; | |||
field_8_length_description_text = data [11 + offset]; | |||
field_9_length_help_topic_text = data [12 + offset]; | |||
field_10_length_status_bar_text = data [13 + offset]; | |||
/* | |||
temp: gjs | |||
if (isBuiltInName()) { | |||
// DEBUG | |||
// System.out.println( "Built-in name" ); | |||
field_11_compressed_unicode_flag = data[ 14 + offset ]; | |||
field_12_builtIn_name = data[ 15 + offset ]; | |||
if ( (field_12_builtIn_name & (short)0x07) != 0 ) { | |||
field_12_name_text = "Print_Titles"; | |||
// DEBUG | |||
// System.out.println( field_12_name_text ); | |||
field_13_raw_name_definition = new byte[ field_4_length_name_definition ]; | |||
System.arraycopy( data, 16 + offset, field_13_raw_name_definition, 0, field_13_raw_name_definition.length ); | |||
// DEBUG | |||
// System.out.println( HexDump.toHex( field_13_raw_name_definition ) ); | |||
} | |||
} | |||
else { */ | |||
field_11_compressed_unicode_flag= data [14 + offset]; | |||
protected void fillFields(RecordInputStream in) { | |||
field_1_option_flag = in.readShort(); | |||
field_2_keyboard_shortcut = in.readByte(); | |||
field_3_length_name_text = in.readByte(); | |||
field_4_length_name_definition = in.readShort(); | |||
field_5_index_to_sheet = in.readShort(); | |||
field_6_equals_to_index_to_sheet= in.readShort(); | |||
field_7_length_custom_menu = in.readByte(); | |||
field_8_length_description_text = in.readByte(); | |||
field_9_length_help_topic_text = in.readByte(); | |||
field_10_length_status_bar_text = in.readByte(); | |||
//store the name in byte form if it's a builtin name | |||
field_11_compressed_unicode_flag= in.readByte(); | |||
if (this.isBuiltInName()) { | |||
field_12_builtIn_name = data[ 15 + offset ]; | |||
field_12_builtIn_name = in.readByte(); | |||
} else { | |||
if (field_11_compressed_unicode_flag == 1) { | |||
field_12_name_text = in.readCompressedUnicode(field_3_length_name_text); | |||
} else { | |||
field_12_name_text = in.readCompressedUnicode(field_3_length_name_text); | |||
} | |||
} | |||
field_12_name_text = StringUtil.getFromCompressedUnicode(data, 15 + offset, | |||
LittleEndian.ubyteToInt(field_3_length_name_text)); | |||
int start_of_name_definition = 15 + field_3_length_name_text; | |||
field_13_name_definition = getParsedExpressionTokens(data, field_4_length_name_definition, | |||
offset, start_of_name_definition); | |||
field_13_name_definition = getParsedExpressionTokens(in, field_4_length_name_definition); | |||
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; | |||
field_14_custom_menu_text = StringUtil.getFromCompressedUnicode(data, start_of_custom_menu_text + offset, | |||
LittleEndian.ubyteToInt(field_7_length_custom_menu)); | |||
//Who says that this can only ever be compressed unicode??? | |||
field_14_custom_menu_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_7_length_custom_menu)); | |||
int start_of_description_text = start_of_custom_menu_text + field_7_length_custom_menu;; | |||
field_15_description_text = StringUtil.getFromCompressedUnicode(data, start_of_description_text + offset, | |||
LittleEndian.ubyteToInt(field_8_length_description_text)); | |||
field_15_description_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_8_length_description_text)); | |||
int start_of_help_topic_text = start_of_description_text + field_8_length_description_text; | |||
field_16_help_topic_text = StringUtil.getFromCompressedUnicode(data, start_of_help_topic_text + offset, | |||
LittleEndian.ubyteToInt(field_9_length_help_topic_text)); | |||
field_16_help_topic_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_9_length_help_topic_text)); | |||
int start_of_status_bar_text = start_of_help_topic_text + field_9_length_help_topic_text; | |||
field_17_status_bar_text = StringUtil.getFromCompressedUnicode(data, start_of_status_bar_text + offset, | |||
LittleEndian.ubyteToInt(field_10_length_status_bar_text)); | |||
field_17_status_bar_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_10_length_status_bar_text)); | |||
/*} */ | |||
} | |||
private Stack getParsedExpressionTokens(byte [] data, short size, | |||
int offset, int start_of_expression) { | |||
private Stack getParsedExpressionTokens(RecordInputStream in, short size) { | |||
Stack stack = new Stack(); | |||
int pos = start_of_expression + offset; | |||
int sizeCounter = 0; | |||
try { | |||
while (sizeCounter < size) { | |||
Ptg ptg = Ptg.createPtg(data, pos); | |||
Ptg ptg = Ptg.createPtg(in); | |||
pos += ptg.getSize(); | |||
sizeCounter += ptg.getSize(); | |||
stack.push(ptg); | |||
field_13_raw_name_definition=new byte[size]; | |||
System.arraycopy(data,offset,field_13_raw_name_definition,0,size); | |||
} | |||
} catch (java.lang.UnsupportedOperationException uoe) { | |||
System.err.println("[WARNING] Unknown Ptg " | |||
+ uoe.getMessage() + "for named range: "+ field_12_name_text); | |||
field_13_raw_name_definition=new byte[size]; | |||
System.arraycopy(data,offset,field_13_raw_name_definition,0,size); | |||
return null; | |||
throw new RecordFormatException(uoe.toString()); | |||
} | |||
return stack; | |||
} | |||
@@ -915,10 +851,6 @@ public class NameRecord extends Record { | |||
.append("\n"); | |||
buffer.append(" .Name (Unicode text) = ").append( getNameText() ) | |||
.append("\n"); | |||
buffer.append(" .Formula data (RPN token array without size field) = ").append( HexDump.toHex( | |||
((field_13_raw_name_definition != null) ? field_13_raw_name_definition : new byte[0] ) ) ) | |||
.append("\n"); | |||
buffer.append(" .Menu text (Unicode string without length field) = ").append( field_14_custom_menu_text ) | |||
.append("\n"); | |||
buffer.append(" .Description text (Unicode string without length field) = ").append( field_15_description_text ) | |||
@@ -927,8 +859,6 @@ public class NameRecord extends Record { | |||
.append("\n"); | |||
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text ) | |||
.append("\n"); | |||
if (field_13_raw_name_definition != null) | |||
buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0)); | |||
buffer.append("[/NAME]\n"); | |||
return buffer.toString(); | |||
@@ -958,6 +888,4 @@ public class NameRecord extends Record { | |||
return "Unknown"; | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -51,25 +50,9 @@ public class NumberFormatIndexRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public NumberFormatIndexRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a NumberFormatIndex record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x104e or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public NumberFormatIndexRecord(short id, short size, byte [] data, int offset) | |||
public NumberFormatIndexRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -86,11 +69,11 @@ public class NumberFormatIndexRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_formatIndex = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_1_formatIndex = in.readShort(); | |||
} | |||
@@ -58,23 +58,9 @@ public class NumberRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public NumberRecord(short id, short size, byte [] data) | |||
public NumberRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Number record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x203 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the data | |||
*/ | |||
public NumberRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -85,13 +71,13 @@ public class NumberRecord | |||
* @param size size of data | |||
*/ | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
field_1_row = LittleEndian.getUShort(data, 0 + offset); | |||
field_2_col = LittleEndian.getShort(data, 2 + offset); | |||
field_3_xf = LittleEndian.getShort(data, 4 + offset); | |||
field_4_value = LittleEndian.getDouble(data, 6 + offset); | |||
field_1_row = in.readUShort(); | |||
field_2_col = in.readShort(); | |||
field_3_xf = in.readShort(); | |||
field_4_value = in.readDouble(); | |||
} | |||
//public void setRow(short row) |
@@ -23,6 +23,7 @@ package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.*; | |||
import java.io.ByteArrayInputStream; | |||
import java.util.List; | |||
import java.util.Iterator; | |||
import java.util.ArrayList; | |||
@@ -56,23 +57,9 @@ public class ObjRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ObjRecord(short id, short size, byte [] data) | |||
public ObjRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a obj record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x5D or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ObjRecord(short id, short size, byte[] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
/** | |||
@@ -88,9 +75,20 @@ public class ObjRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
subrecords = new ArrayList(); | |||
//Check if this can be continued, if so then the | |||
//following wont work properly | |||
byte[] subRecordData = in.readRemainder(); | |||
RecordInputStream subRecStream = new RecordInputStream(new ByteArrayInputStream(subRecordData)); | |||
while(subRecStream.hasNextRecord()) { | |||
subRecStream.nextRecord(); | |||
Record subRecord = SubRecord.createSubRecord(subRecStream); | |||
subrecords.add(subRecord); | |||
} | |||
/* JMH the size present/not present in the code below | |||
needs to be considered in the RecordInputStream?? | |||
int pos = offset; | |||
while (pos - offset <= size-2) // atleast one "short" must be present | |||
{ | |||
@@ -102,7 +100,7 @@ public class ObjRecord | |||
Record subRecord = SubRecord.createSubRecord(subRecordSid, subRecordSize, data, pos + 4); | |||
subrecords.add(subRecord); | |||
pos += subRecord.getRecordSize(); | |||
} | |||
}*/ | |||
} | |||
public String toString() | |||
@@ -175,14 +173,6 @@ public class ObjRecord | |||
return subrecords.add( o ); | |||
} | |||
// made public to satisfy biffviewer | |||
/* protected */ | |||
public void processContinueRecord( byte[] record ) | |||
{ | |||
super.processContinueRecord( record ); | |||
} | |||
public Object clone() | |||
{ | |||
ObjRecord rec = new ObjRecord(); |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -58,25 +57,9 @@ public class ObjectLinkRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public ObjectLinkRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a ObjectLink record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1027 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public ObjectLinkRecord(short id, short size, byte [] data, int offset) | |||
public ObjectLinkRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -93,13 +76,13 @@ public class ObjectLinkRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_anchorId = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_link1 = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_link2 = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_1_anchorId = in.readShort(); | |||
field_2_link1 = in.readShort(); | |||
field_3_link2 = in.readShort(); | |||
} | |||
@@ -34,8 +34,14 @@ import org.apache.poi.util.LittleEndian; | |||
* <p>REFERENCE: Microsoft Excel SDK page 322 and 420</p> | |||
* | |||
* @see HorizontalPageBreakRecord | |||
<<<<<<< PageBreakRecord.java | |||
* @see VerticalPageBreakREcord | |||
* | |||
* REFERENCE: Microsoft Excel SDK page 322 and 420 | |||
======= | |||
* @see VerticalPageBreakRecord | |||
* | |||
>>>>>>> 1.5 | |||
* @author Danny Mui (dmui at apache dot org) | |||
*/ | |||
public class PageBreakRecord extends Record { | |||
@@ -82,27 +88,19 @@ public class PageBreakRecord extends Record { | |||
this.sid = sid; | |||
} | |||
public PageBreakRecord(short id, short size, byte data[]) | |||
public PageBreakRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
this.sid = id; | |||
super(in); | |||
this.sid = in.getSid(); | |||
} | |||
public PageBreakRecord(short id, short size, byte data[], int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
this.sid = id; | |||
} | |||
protected void fillFields(byte data[], short size, int offset) | |||
{ | |||
short loadedBreaks = LittleEndian.getShort(data, 0 + offset); | |||
short loadedBreaks = in.readShort(); | |||
setNumBreaks(loadedBreaks); | |||
int pos = 2; | |||
for(int k = 0; k < loadedBreaks; k++) | |||
{ | |||
addBreak((short)(LittleEndian.getShort(data, pos + offset) - 1), LittleEndian.getShort(data, pos + 2 + offset), LittleEndian.getShort(data, pos + 4 + offset)); | |||
pos += 6; | |||
addBreak((short)(in.readShort()-1), in.readShort(), in.readShort()); | |||
} | |||
} |
@@ -44,14 +44,7 @@ public class PaletteRecord | |||
public PaletteRecord() | |||
{ | |||
} | |||
/** | |||
* Constructs a custom palette with the default set of colors | |||
*/ | |||
public PaletteRecord(short id) | |||
{ | |||
super(id, STANDARD_PALETTE_SIZE, getDefaultData()); | |||
createDefaultPalette(); | |||
} | |||
/** | |||
@@ -62,23 +55,9 @@ public class PaletteRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PaletteRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a PaletteRecord record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x0A or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public PaletteRecord(short id, short size, byte [] data, int offset) | |||
public PaletteRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -89,17 +68,19 @@ public class PaletteRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_numcolors = LittleEndian.getShort(data,offset+0); | |||
field_1_numcolors = in.readShort(); | |||
field_2_colors = new ArrayList(field_1_numcolors); | |||
for (int k = 0; k < field_1_numcolors; k++) { | |||
field_2_colors.add(new PColor( | |||
data[2+ offset+(k * 4) +0], | |||
data[2+ offset+(k * 4) +1], | |||
data[2+ offset+(k * 4) +2] | |||
in.readByte(), | |||
in.readByte(), | |||
in.readByte() | |||
) | |||
); | |||
//Read unused byte. | |||
in.readByte(); | |||
} | |||
} | |||
@@ -187,15 +168,16 @@ public class PaletteRecord | |||
} | |||
/** | |||
* Returns the default palette as PaletteRecord binary data | |||
* Creates the default palette as PaletteRecord binary data | |||
* | |||
* @see org.apache.poi.hssf.model.Workbook#createPalette | |||
*/ | |||
public static byte[] getDefaultData() | |||
private void createDefaultPalette() | |||
{ | |||
return new byte[] | |||
field_1_numcolors = STANDARD_PALETTE_SIZE; | |||
field_2_colors = new ArrayList(field_1_numcolors); | |||
byte[] palette = new byte[] | |||
{ | |||
STANDARD_PALETTE_SIZE, (byte) 0, | |||
(byte) 0, (byte) 0, (byte) 0, (byte) 0, //color 0... | |||
(byte) 255, (byte) 255, (byte) 255, (byte) 0, | |||
(byte) 255, (byte) 0, (byte) 0, (byte) 0, | |||
@@ -253,6 +235,16 @@ public class PaletteRecord | |||
(byte) 51, (byte) 51, (byte) 153, (byte) 0, | |||
(byte) 51, (byte) 51, (byte) 51, (byte) 0 | |||
}; | |||
for (int k = 0; k < field_1_numcolors; k++) { | |||
field_2_colors.add(new PColor( | |||
palette[k*4], | |||
palette[k*4+1], | |||
palette[k*4+2] | |||
) | |||
); | |||
} | |||
} | |||
} | |||
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -59,25 +58,9 @@ public class PaneRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PaneRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Pane record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x41 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public PaneRecord(short id, short size, byte [] data, int offset) | |||
public PaneRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -94,15 +77,15 @@ public class PaneRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_x = LittleEndian.getShort(data, pos + 0x0 + offset); | |||
field_2_y = LittleEndian.getShort(data, pos + 0x2 + offset); | |||
field_3_topRow = LittleEndian.getShort(data, pos + 0x4 + offset); | |||
field_4_leftColumn = LittleEndian.getShort(data, pos + 0x6 + offset); | |||
field_5_activePane = LittleEndian.getShort(data, pos + 0x8 + offset); | |||
field_1_x = in.readShort(); | |||
field_2_y = in.readShort(); | |||
field_3_topRow = in.readShort(); | |||
field_4_leftColumn = in.readShort(); | |||
field_5_activePane = in.readShort(); | |||
} | |||
@@ -46,23 +46,9 @@ public class PasswordRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PasswordRecord(short id, short size, byte [] data) | |||
public PasswordRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a Password record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x13 or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the data | |||
*/ | |||
public PasswordRecord(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -73,9 +59,9 @@ public class PasswordRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_password = LittleEndian.getShort(data, 0 + offset); | |||
field_1_password = in.readShort(); | |||
} | |||
/** |
@@ -47,23 +47,9 @@ public class PasswordRev4Record | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PasswordRev4Record(short id, short size, byte [] data) | |||
public PasswordRev4Record(RecordInputStream in) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a PasswordRev4 (PROT4REVPASS) record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1bc or an exception will be throw upon validation | |||
* @param size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the data | |||
*/ | |||
public PasswordRev4Record(short id, short size, byte [] data, int offset) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
protected void validateSid(short id) | |||
@@ -74,9 +60,9 @@ public class PasswordRev4Record | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
field_1_password = LittleEndian.getShort(data, 0 + offset); | |||
field_1_password = in.readShort(); | |||
} | |||
/** |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -50,25 +49,9 @@ public class PlotAreaRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PlotAreaRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a PlotArea record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1035 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public PlotAreaRecord(short id, short size, byte [] data, int offset) | |||
public PlotAreaRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -85,7 +68,7 @@ public class PlotAreaRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; |
@@ -1,6 +1,6 @@ | |||
/* ==================================================================== | |||
Copyright 2002-2004 Apache Software Foundation | |||
Copyright 2003-2004 Apache Software Foundation | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
@@ -16,7 +16,6 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -52,25 +51,9 @@ public class PlotGrowthRecord | |||
* @param data data of the record (should not contain sid/len) | |||
*/ | |||
public PlotGrowthRecord(short id, short size, byte [] data) | |||
{ | |||
super(id, size, data); | |||
} | |||
/** | |||
* Constructs a PlotGrowth record and sets its fields appropriately. | |||
* | |||
* @param id id must be 0x1064 or an exception | |||
* will be throw upon validation | |||
* @param size size the size of the data area of the record | |||
* @param data data of the record (should not contain sid/len) | |||
* @param offset of the record's data | |||
*/ | |||
public PlotGrowthRecord(short id, short size, byte [] data, int offset) | |||
public PlotGrowthRecord(RecordInputStream in) | |||
{ | |||
super(id, size, data, offset); | |||
super(in); | |||
} | |||
@@ -87,12 +70,12 @@ public class PlotGrowthRecord | |||
} | |||
} | |||
protected void fillFields(byte [] data, short size, int offset) | |||
protected void fillFields(RecordInputStream in) | |||
{ | |||
int pos = 0; | |||
field_1_horizontalScale = LittleEndian.getInt(data, pos + 0x0 + offset); | |||
field_2_verticalScale = LittleEndian.getInt(data, pos + 0x4 + offset); | |||
field_1_horizontalScale = in.readInt(); | |||
field_2_verticalScale = in.readInt(); | |||
} | |||