Major landing of the following changes:

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-ffa450edef68
This commit is contained in:
Jason Height 2005-08-18 07:06:44 +00:00
parent d9c74c316c
commit 07f76e4bb6
265 changed files with 3915 additions and 5345 deletions

View File

@ -355,6 +355,7 @@
<exclude name="**/AllTests.java"/> <exclude name="**/AllTests.java"/>
<exclude name="**/TestEmptyDocument.java"/> <exclude name="**/TestEmptyDocument.java"/>
<exclude name="**/TestUnfixedBugs.java"/> <exclude name="**/TestUnfixedBugs.java"/>
<exclude name="**/TestcaseRecordInputStream.java"/>
</fileset> </fileset>
</batchtest> </batchtest>
</junit> </junit>

View File

@ -90,64 +90,27 @@ public class BiffViewer {
public static Record[] createRecords(InputStream in, boolean dump) public static Record[] createRecords(InputStream in, boolean dump)
throws RecordFormatException { throws RecordFormatException {
ArrayList records = new ArrayList(); ArrayList records = new ArrayList();
// Record last_record = null;
int loc = 0;
RecordDetails activeRecord = null; RecordDetails activeRecord = null;
try { try {
// long offset = 0; BiffviewRecordInputStream recStream = new BiffviewRecordInputStream(in);
short rectype = 0; while (recStream.hasNextRecord()) {
recStream.nextRecord();
do { if (recStream.getSid() != 0) {
rectype = LittleEndian.readShort(in); Record record = createRecord (recStream);
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
if (record.getSid() != ContinueRecord.sid) if (record.getSid() != ContinueRecord.sid)
{ {
records.add(record); records.add(record);
if (activeRecord != null) if (activeRecord != null)
activeRecord.dump(); activeRecord.dump();
activeRecord = new RecordDetails(rectype, recsize, startloc, data, record); activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), (int)recStream.getPos(), record);
}
else
{
activeRecord.getRecord().processContinueRecord(data);
} }
if (dump) { if (dump) {
dumpRaw(rectype, recsize, data); recStream.dumpBytes();
}
} }
} }
} while (rectype != 0);
activeRecord.dump(); activeRecord.dump();
} catch (IOException e) { } catch (IOException e) {
throw new RecordFormatException("Error reading bytes"); 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 * Essentially a duplicate of RecordFactory. Kept seperate as not to screw
* up non-debug operations. * up non-debug operations.
* *
*/ */
private static Record createRecord( short rectype, short size, private static Record createRecord( RecordInputStream in )
byte[] data )
{ {
Record retval = null; Record retval = null;
switch ( rectype ) switch ( in.getSid() )
{ {
case ChartRecord.sid: case ChartRecord.sid:
retval = new ChartRecord( rectype, size, data ); retval = new ChartRecord( in );
break; break;
case ChartFormatRecord.sid: case ChartFormatRecord.sid:
retval = new ChartFormatRecord( rectype, size, data ); retval = new ChartFormatRecord( in );
break; break;
case SeriesRecord.sid: case SeriesRecord.sid:
retval = new SeriesRecord( rectype, size, data ); retval = new SeriesRecord( in );
break; break;
case BeginRecord.sid: case BeginRecord.sid:
retval = new BeginRecord( rectype, size, data ); retval = new BeginRecord( in );
break; break;
case EndRecord.sid: case EndRecord.sid:
retval = new EndRecord( rectype, size, data ); retval = new EndRecord( in );
break; break;
case BOFRecord.sid: case BOFRecord.sid:
retval = new BOFRecord( rectype, size, data ); retval = new BOFRecord( in );
break; break;
case InterfaceHdrRecord.sid: case InterfaceHdrRecord.sid:
retval = new InterfaceHdrRecord( rectype, size, data ); retval = new InterfaceHdrRecord( in );
break; break;
case MMSRecord.sid: case MMSRecord.sid:
retval = new MMSRecord( rectype, size, data ); retval = new MMSRecord( in );
break; break;
case InterfaceEndRecord.sid: case InterfaceEndRecord.sid:
retval = new InterfaceEndRecord( rectype, size, data ); retval = new InterfaceEndRecord( in );
break; break;
case WriteAccessRecord.sid: case WriteAccessRecord.sid:
retval = new WriteAccessRecord( rectype, size, data ); retval = new WriteAccessRecord( in );
break; break;
case CodepageRecord.sid: case CodepageRecord.sid:
retval = new CodepageRecord( rectype, size, data ); retval = new CodepageRecord( in );
break; break;
case DSFRecord.sid: case DSFRecord.sid:
retval = new DSFRecord( rectype, size, data ); retval = new DSFRecord( in );
break; break;
case TabIdRecord.sid: case TabIdRecord.sid:
retval = new TabIdRecord( rectype, size, data ); retval = new TabIdRecord( in );
break; break;
case FnGroupCountRecord.sid: case FnGroupCountRecord.sid:
retval = new FnGroupCountRecord( rectype, size, data ); retval = new FnGroupCountRecord( in );
break; break;
case WindowProtectRecord.sid: case WindowProtectRecord.sid:
retval = new WindowProtectRecord( rectype, size, data ); retval = new WindowProtectRecord( in );
break; break;
case ProtectRecord.sid: case ProtectRecord.sid:
retval = new ProtectRecord( rectype, size, data ); retval = new ProtectRecord( in );
break; break;
case PasswordRecord.sid: case PasswordRecord.sid:
retval = new PasswordRecord( rectype, size, data ); retval = new PasswordRecord( in );
break; break;
case ProtectionRev4Record.sid: case ProtectionRev4Record.sid:
retval = new ProtectionRev4Record( rectype, size, data ); retval = new ProtectionRev4Record( in );
break; break;
case PasswordRev4Record.sid: case PasswordRev4Record.sid:
retval = new PasswordRev4Record( rectype, size, data ); retval = new PasswordRev4Record( in );
break; break;
case WindowOneRecord.sid: case WindowOneRecord.sid:
retval = new WindowOneRecord( rectype, size, data ); retval = new WindowOneRecord( in );
break; break;
case BackupRecord.sid: case BackupRecord.sid:
retval = new BackupRecord( rectype, size, data ); retval = new BackupRecord( in );
break; break;
case HideObjRecord.sid: case HideObjRecord.sid:
retval = new HideObjRecord( rectype, size, data ); retval = new HideObjRecord( in );
break; break;
case DateWindow1904Record.sid: case DateWindow1904Record.sid:
retval = new DateWindow1904Record( rectype, size, data ); retval = new DateWindow1904Record( in );
break; break;
case PrecisionRecord.sid: case PrecisionRecord.sid:
retval = new PrecisionRecord( rectype, size, data ); retval = new PrecisionRecord( in );
break; break;
case RefreshAllRecord.sid: case RefreshAllRecord.sid:
retval = new RefreshAllRecord( rectype, size, data ); retval = new RefreshAllRecord( in );
break; break;
case BookBoolRecord.sid: case BookBoolRecord.sid:
retval = new BookBoolRecord( rectype, size, data ); retval = new BookBoolRecord( in );
break; break;
case FontRecord.sid: case FontRecord.sid:
retval = new FontRecord( rectype, size, data ); retval = new FontRecord( in );
break; break;
case FormatRecord.sid: case FormatRecord.sid:
retval = new FormatRecord( rectype, size, data ); retval = new FormatRecord( in );
break; break;
case ExtendedFormatRecord.sid: case ExtendedFormatRecord.sid:
retval = new ExtendedFormatRecord( rectype, size, data ); retval = new ExtendedFormatRecord( in );
break; break;
case StyleRecord.sid: case StyleRecord.sid:
retval = new StyleRecord( rectype, size, data ); retval = new StyleRecord( in );
break; break;
case UseSelFSRecord.sid: case UseSelFSRecord.sid:
retval = new UseSelFSRecord( rectype, size, data ); retval = new UseSelFSRecord( in );
break; break;
case BoundSheetRecord.sid: case BoundSheetRecord.sid:
retval = new BoundSheetRecord( rectype, size, data ); retval = new BoundSheetRecord( in );
break; break;
case CountryRecord.sid: case CountryRecord.sid:
retval = new CountryRecord( rectype, size, data ); retval = new CountryRecord( in );
break; break;
case SSTRecord.sid: case SSTRecord.sid:
retval = new SSTRecord( rectype, size, data ); retval = new SSTRecord( in );
break; break;
case ExtSSTRecord.sid: case ExtSSTRecord.sid:
retval = new ExtSSTRecord( rectype, size, data ); retval = new ExtSSTRecord( in );
break; break;
case EOFRecord.sid: case EOFRecord.sid:
retval = new EOFRecord( rectype, size, data ); retval = new EOFRecord( in );
break; break;
case IndexRecord.sid: case IndexRecord.sid:
retval = new IndexRecord( rectype, size, data ); retval = new IndexRecord( in );
break; break;
case CalcModeRecord.sid: case CalcModeRecord.sid:
retval = new CalcModeRecord( rectype, size, data ); retval = new CalcModeRecord( in );
break; break;
case CalcCountRecord.sid: case CalcCountRecord.sid:
retval = new CalcCountRecord( rectype, size, data ); retval = new CalcCountRecord( in );
break; break;
case RefModeRecord.sid: case RefModeRecord.sid:
retval = new RefModeRecord( rectype, size, data ); retval = new RefModeRecord( in );
break; break;
case IterationRecord.sid: case IterationRecord.sid:
retval = new IterationRecord( rectype, size, data ); retval = new IterationRecord( in );
break; break;
case DeltaRecord.sid: case DeltaRecord.sid:
retval = new DeltaRecord( rectype, size, data ); retval = new DeltaRecord( in );
break; break;
case SaveRecalcRecord.sid: case SaveRecalcRecord.sid:
retval = new SaveRecalcRecord( rectype, size, data ); retval = new SaveRecalcRecord( in );
break; break;
case PrintHeadersRecord.sid: case PrintHeadersRecord.sid:
retval = new PrintHeadersRecord( rectype, size, data ); retval = new PrintHeadersRecord( in );
break; break;
case PrintGridlinesRecord.sid: case PrintGridlinesRecord.sid:
retval = new PrintGridlinesRecord( rectype, size, data ); retval = new PrintGridlinesRecord( in );
break; break;
case GridsetRecord.sid: case GridsetRecord.sid:
retval = new GridsetRecord( rectype, size, data ); retval = new GridsetRecord( in );
break; break;
case DrawingGroupRecord.sid: case DrawingGroupRecord.sid:
retval = new DrawingGroupRecord( rectype, size, data ); retval = new DrawingGroupRecord( in );
break; break;
case DrawingRecordForBiffViewer.sid: case DrawingRecordForBiffViewer.sid:
retval = new DrawingRecordForBiffViewer( rectype, size, data ); retval = new DrawingRecordForBiffViewer( in );
break; break;
case DrawingSelectionRecord.sid: case DrawingSelectionRecord.sid:
retval = new DrawingSelectionRecord( rectype, size, data ); retval = new DrawingSelectionRecord( in );
break; break;
case GutsRecord.sid: case GutsRecord.sid:
retval = new GutsRecord( rectype, size, data ); retval = new GutsRecord( in );
break; break;
case DefaultRowHeightRecord.sid: case DefaultRowHeightRecord.sid:
retval = new DefaultRowHeightRecord( rectype, size, data ); retval = new DefaultRowHeightRecord( in );
break; break;
case WSBoolRecord.sid: case WSBoolRecord.sid:
retval = new WSBoolRecord( rectype, size, data ); retval = new WSBoolRecord( in );
break; break;
case HeaderRecord.sid: case HeaderRecord.sid:
retval = new HeaderRecord( rectype, size, data ); retval = new HeaderRecord( in );
break; break;
case FooterRecord.sid: case FooterRecord.sid:
retval = new FooterRecord( rectype, size, data ); retval = new FooterRecord( in );
break; break;
case HCenterRecord.sid: case HCenterRecord.sid:
retval = new HCenterRecord( rectype, size, data ); retval = new HCenterRecord( in );
break; break;
case VCenterRecord.sid: case VCenterRecord.sid:
retval = new VCenterRecord( rectype, size, data ); retval = new VCenterRecord( in );
break; break;
case PrintSetupRecord.sid: case PrintSetupRecord.sid:
retval = new PrintSetupRecord( rectype, size, data ); retval = new PrintSetupRecord( in );
break; break;
case DefaultColWidthRecord.sid: case DefaultColWidthRecord.sid:
retval = new DefaultColWidthRecord( rectype, size, data ); retval = new DefaultColWidthRecord( in );
break; break;
case DimensionsRecord.sid: case DimensionsRecord.sid:
retval = new DimensionsRecord( rectype, size, data ); retval = new DimensionsRecord( in );
break; break;
case RowRecord.sid: case RowRecord.sid:
retval = new RowRecord( rectype, size, data ); retval = new RowRecord( in );
break; break;
case LabelSSTRecord.sid: case LabelSSTRecord.sid:
retval = new LabelSSTRecord( rectype, size, data ); retval = new LabelSSTRecord( in );
break; break;
case RKRecord.sid: case RKRecord.sid:
retval = new RKRecord( rectype, size, data ); retval = new RKRecord( in );
break; break;
case NumberRecord.sid: case NumberRecord.sid:
retval = new NumberRecord( rectype, size, data ); retval = new NumberRecord( in );
break; break;
case DBCellRecord.sid: case DBCellRecord.sid:
retval = new DBCellRecord( rectype, size, data ); retval = new DBCellRecord( in );
break; break;
case WindowTwoRecord.sid: case WindowTwoRecord.sid:
retval = new WindowTwoRecord( rectype, size, data ); retval = new WindowTwoRecord( in );
break; break;
case SelectionRecord.sid: case SelectionRecord.sid:
retval = new SelectionRecord( rectype, size, data ); retval = new SelectionRecord( in );
break; break;
case ContinueRecord.sid: case ContinueRecord.sid:
retval = new ContinueRecord( rectype, size, data ); retval = new ContinueRecord( in );
break; break;
case LabelRecord.sid: case LabelRecord.sid:
retval = new LabelRecord( rectype, size, data ); retval = new LabelRecord( in );
break; break;
case MulRKRecord.sid: case MulRKRecord.sid:
retval = new MulRKRecord( rectype, size, data ); retval = new MulRKRecord( in );
break; break;
case MulBlankRecord.sid: case MulBlankRecord.sid:
retval = new MulBlankRecord( rectype, size, data ); retval = new MulBlankRecord( in );
break; break;
case BlankRecord.sid: case BlankRecord.sid:
retval = new BlankRecord( rectype, size, data ); retval = new BlankRecord( in );
break; break;
case BoolErrRecord.sid: case BoolErrRecord.sid:
retval = new BoolErrRecord( rectype, size, data ); retval = new BoolErrRecord( in );
break; break;
case ColumnInfoRecord.sid: case ColumnInfoRecord.sid:
retval = new ColumnInfoRecord( rectype, size, data ); retval = new ColumnInfoRecord( in );
break; break;
case MergeCellsRecord.sid: case MergeCellsRecord.sid:
retval = new MergeCellsRecord( rectype, size, data ); retval = new MergeCellsRecord( in );
break; break;
case AreaRecord.sid: case AreaRecord.sid:
retval = new AreaRecord( rectype, size, data ); retval = new AreaRecord( in );
break; break;
case DataFormatRecord.sid: case DataFormatRecord.sid:
retval = new DataFormatRecord( rectype, size, data ); retval = new DataFormatRecord( in );
break; break;
case BarRecord.sid: case BarRecord.sid:
retval = new BarRecord( rectype, size, data ); retval = new BarRecord( in );
break; break;
case DatRecord.sid: case DatRecord.sid:
retval = new DatRecord( rectype, size, data ); retval = new DatRecord( in );
break; break;
case PlotGrowthRecord.sid: case PlotGrowthRecord.sid:
retval = new PlotGrowthRecord( rectype, size, data ); retval = new PlotGrowthRecord( in );
break; break;
case UnitsRecord.sid: case UnitsRecord.sid:
retval = new UnitsRecord( rectype, size, data ); retval = new UnitsRecord( in );
break; break;
case FrameRecord.sid: case FrameRecord.sid:
retval = new FrameRecord( rectype, size, data ); retval = new FrameRecord( in );
break; break;
case ValueRangeRecord.sid: case ValueRangeRecord.sid:
retval = new ValueRangeRecord( rectype, size, data ); retval = new ValueRangeRecord( in );
break; break;
case SeriesListRecord.sid: case SeriesListRecord.sid:
retval = new SeriesListRecord( rectype, size, data ); retval = new SeriesListRecord( in );
break; break;
case FontBasisRecord.sid: case FontBasisRecord.sid:
retval = new FontBasisRecord( rectype, size, data ); retval = new FontBasisRecord( in );
break; break;
case FontIndexRecord.sid: case FontIndexRecord.sid:
retval = new FontIndexRecord( rectype, size, data ); retval = new FontIndexRecord( in );
break; break;
case LineFormatRecord.sid: case LineFormatRecord.sid:
retval = new LineFormatRecord( rectype, size, data ); retval = new LineFormatRecord( in );
break; break;
case AreaFormatRecord.sid: case AreaFormatRecord.sid:
retval = new AreaFormatRecord( rectype, size, data ); retval = new AreaFormatRecord( in );
break; break;
case LinkedDataRecord.sid: case LinkedDataRecord.sid:
retval = new LinkedDataRecord( rectype, size, data ); retval = new LinkedDataRecord( in );
break; break;
case FormulaRecord.sid: case FormulaRecord.sid:
retval = new FormulaRecord( rectype, size, data ); retval = new FormulaRecord( in );
break; break;
case SheetPropertiesRecord.sid: case SheetPropertiesRecord.sid:
retval = new SheetPropertiesRecord( rectype, size, data ); retval = new SheetPropertiesRecord( in );
break; break;
case DefaultDataLabelTextPropertiesRecord.sid: case DefaultDataLabelTextPropertiesRecord.sid:
retval = new DefaultDataLabelTextPropertiesRecord( rectype, size, data ); retval = new DefaultDataLabelTextPropertiesRecord( in );
break; break;
case TextRecord.sid: case TextRecord.sid:
retval = new TextRecord( rectype, size, data ); retval = new TextRecord( in );
break; break;
case AxisParentRecord.sid: case AxisParentRecord.sid:
retval = new AxisParentRecord( rectype, size, data ); retval = new AxisParentRecord( in );
break; break;
case AxisLineFormatRecord.sid: case AxisLineFormatRecord.sid:
retval = new AxisLineFormatRecord( rectype, size, data ); retval = new AxisLineFormatRecord( in );
break; break;
case SupBookRecord.sid: case SupBookRecord.sid:
retval = new SupBookRecord( rectype, size, data ); retval = new SupBookRecord( in );
break; break;
case ExternSheetRecord.sid: case ExternSheetRecord.sid:
retval = new ExternSheetRecord( rectype, size, data ); retval = new ExternSheetRecord( in );
break; break;
case SCLRecord.sid: case SCLRecord.sid:
retval = new SCLRecord( rectype, size, data ); retval = new SCLRecord( in );
break; break;
case SeriesToChartGroupRecord.sid: case SeriesToChartGroupRecord.sid:
retval = new SeriesToChartGroupRecord( rectype, size, data ); retval = new SeriesToChartGroupRecord( in );
break; break;
case AxisUsedRecord.sid: case AxisUsedRecord.sid:
retval = new AxisUsedRecord( rectype, size, data ); retval = new AxisUsedRecord( in );
break; break;
case AxisRecord.sid: case AxisRecord.sid:
retval = new AxisRecord( rectype, size, data ); retval = new AxisRecord( in );
break; break;
case CategorySeriesAxisRecord.sid: case CategorySeriesAxisRecord.sid:
retval = new CategorySeriesAxisRecord( rectype, size, data ); retval = new CategorySeriesAxisRecord( in );
break; break;
case AxisOptionsRecord.sid: case AxisOptionsRecord.sid:
retval = new AxisOptionsRecord( rectype, size, data ); retval = new AxisOptionsRecord( in );
break; break;
case TickRecord.sid: case TickRecord.sid:
retval = new TickRecord( rectype, size, data ); retval = new TickRecord( in );
break; break;
case SeriesTextRecord.sid: case SeriesTextRecord.sid:
retval = new SeriesTextRecord( rectype, size, data ); retval = new SeriesTextRecord( in );
break; break;
case ObjectLinkRecord.sid: case ObjectLinkRecord.sid:
retval = new ObjectLinkRecord( rectype, size, data ); retval = new ObjectLinkRecord( in );
break; break;
case PlotAreaRecord.sid: case PlotAreaRecord.sid:
retval = new PlotAreaRecord( rectype, size, data ); retval = new PlotAreaRecord( in );
break; break;
case SeriesIndexRecord.sid: case SeriesIndexRecord.sid:
retval = new SeriesIndexRecord( rectype, size, data ); retval = new SeriesIndexRecord( in );
break; break;
case LegendRecord.sid: case LegendRecord.sid:
retval = new LegendRecord( rectype, size, data ); retval = new LegendRecord( in );
break; break;
case LeftMarginRecord.sid: case LeftMarginRecord.sid:
retval = new LeftMarginRecord( rectype, size, data ); retval = new LeftMarginRecord( in );
break; break;
case RightMarginRecord.sid: case RightMarginRecord.sid:
retval = new RightMarginRecord( rectype, size, data ); retval = new RightMarginRecord( in );
break; break;
case TopMarginRecord.sid: case TopMarginRecord.sid:
retval = new TopMarginRecord( rectype, size, data ); retval = new TopMarginRecord( in );
break; break;
case BottomMarginRecord.sid: case BottomMarginRecord.sid:
retval = new BottomMarginRecord( rectype, size, data ); retval = new BottomMarginRecord( in );
break; break;
case PaletteRecord.sid: case PaletteRecord.sid:
retval = new PaletteRecord( rectype, size, data ); retval = new PaletteRecord( in );
break; break;
case StringRecord.sid: case StringRecord.sid:
retval = new StringRecord( rectype, size, data ); retval = new StringRecord( in );
break; break;
case NameRecord.sid: case NameRecord.sid:
retval = new NameRecord( rectype, size, data ); retval = new NameRecord( in );
break; break;
case PaneRecord.sid: case PaneRecord.sid:
retval = new PaneRecord( rectype, size, data ); retval = new PaneRecord( in );
break; break;
case SharedFormulaRecord.sid: case SharedFormulaRecord.sid:
retval = new SharedFormulaRecord( rectype, size, data); retval = new SharedFormulaRecord( in);
break; break;
case ObjRecord.sid: case ObjRecord.sid:
retval = new ObjRecord( rectype, size, data); retval = new ObjRecord( in);
break; break;
case TextObjectRecord.sid: case TextObjectRecord.sid:
retval = new TextObjectRecord( rectype, size, data); retval = new TextObjectRecord( in);
break; break;
case HorizontalPageBreakRecord.sid: case HorizontalPageBreakRecord.sid:
retval = new HorizontalPageBreakRecord( rectype, size, data); retval = new HorizontalPageBreakRecord( in);
break; break;
case VerticalPageBreakRecord.sid: case VerticalPageBreakRecord.sid:
retval = new VerticalPageBreakRecord( rectype, size, data); retval = new VerticalPageBreakRecord( in);
break; break;
default: default:
retval = new UnknownRecord( rectype, size, data ); retval = new UnknownRecord( in );
} }
return retval; return retval;
} }
@ -684,15 +576,13 @@ public class BiffViewer {
{ {
short rectype, recsize; short rectype, recsize;
int startloc; int startloc;
byte[] data;
Record record; 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.rectype = rectype;
this.recsize = recsize; this.recsize = recsize;
this.startloc = startloc; this.startloc = startloc;
this.data = data;
this.record = record; this.record = record;
} }
@ -706,11 +596,6 @@ public class BiffViewer {
return recsize; return recsize;
} }
public byte[] getData()
{
return data;
}
public Record getRecord() public Record getRecord()
{ {
return record; return record;
@ -718,12 +603,18 @@ public class BiffViewer {
public void dump() throws IOException public void dump() throws IOException
{ {
if (record instanceof UnknownRecord)
dumpUnknownRecord(data);
else
dumpNormal(record, startloc, rectype, recsize); 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);
}
}
} }

View File

@ -36,159 +36,159 @@ import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
* Event Factory version of HSSF test class. * Event Factory version of HSSF test class.
* @author andy * @author andy
*/ */
//JMH
public class EFHSSF //public class EFHSSF
{ //{
String infile; // String infile;
String outfile; // String outfile;
HSSFWorkbook workbook = null; // HSSFWorkbook workbook = null;
HSSFSheet cursheet = null; // HSSFSheet cursheet = null;
//
/** Creates a new instance of EFHSSF */ // /** Creates a new instance of EFHSSF */
//
public EFHSSF() // public EFHSSF()
{ // {
} // }
//
public void setInputFile(String infile) // public void setInputFile(String infile)
{ // {
this.infile = infile; // this.infile = infile;
} // }
//
public void setOutputFile(String outfile) // public void setOutputFile(String outfile)
{ // {
this.outfile = outfile; // this.outfile = outfile;
} // }
//
public void run() // public void run()
throws IOException // throws IOException
{ // {
FileInputStream fin = new FileInputStream(infile); // FileInputStream fin = new FileInputStream(infile);
POIFSFileSystem poifs = new POIFSFileSystem(fin); // POIFSFileSystem poifs = new POIFSFileSystem(fin);
InputStream din = poifs.createDocumentInputStream("Workbook"); // InputStream din = poifs.createDocumentInputStream("Workbook");
HSSFRequest req = new HSSFRequest(); // HSSFRequest req = new HSSFRequest();
//
req.addListenerForAllRecords(new EFHSSFListener(this)); // req.addListenerForAllRecords(new EFHSSFListener(this));
HSSFEventFactory factory = new HSSFEventFactory(); // HSSFEventFactory factory = new HSSFEventFactory();
//
factory.processEvents(req, din); // factory.processEvents(req, din);
fin.close(); // fin.close();
din.close(); // din.close();
FileOutputStream fout = new FileOutputStream(outfile); // FileOutputStream fout = new FileOutputStream(outfile);
//
workbook.write(fout); // workbook.write(fout);
fout.close(); // fout.close();
System.out.println("done."); // System.out.println("done.");
} // }
//
public void recordHandler(Record record) // public void recordHandler(Record record)
{ // {
HSSFRow row = null; // HSSFRow row = null;
HSSFCell cell = null; // HSSFCell cell = null;
int sheetnum = -1; // int sheetnum = -1;
//
switch (record.getSid()) // switch (record.getSid())
{ // {
//
case BOFRecord.sid : // case BOFRecord.sid :
BOFRecord bof = ( BOFRecord ) record; // BOFRecord bof = ( BOFRecord ) record;
//
if (bof.getType() == bof.TYPE_WORKBOOK) // if (bof.getType() == bof.TYPE_WORKBOOK)
{ // {
workbook = new HSSFWorkbook(); // workbook = new HSSFWorkbook();
} // }
else if (bof.getType() == bof.TYPE_WORKSHEET) // else if (bof.getType() == bof.TYPE_WORKSHEET)
{ // {
sheetnum++; // sheetnum++;
cursheet = workbook.getSheetAt(sheetnum); // cursheet = workbook.getSheetAt(sheetnum);
} // }
break; // break;
//
case BoundSheetRecord.sid : // case BoundSheetRecord.sid :
BoundSheetRecord bsr = ( BoundSheetRecord ) record; // BoundSheetRecord bsr = ( BoundSheetRecord ) record;
//
workbook.createSheet(bsr.getSheetname()); // workbook.createSheet(bsr.getSheetname());
break; // break;
//
case RowRecord.sid : // case RowRecord.sid :
RowRecord rowrec = ( RowRecord ) record; // RowRecord rowrec = ( RowRecord ) record;
//
cursheet.createRow(rowrec.getRowNumber()); // cursheet.createRow(rowrec.getRowNumber());
break; // break;
//
case NumberRecord.sid : // case NumberRecord.sid :
NumberRecord numrec = ( NumberRecord ) record; // NumberRecord numrec = ( NumberRecord ) record;
//
row = cursheet.getRow(numrec.getRow()); // row = cursheet.getRow(numrec.getRow());
cell = row.createCell(numrec.getColumn(), // cell = row.createCell(numrec.getColumn(),
HSSFCell.CELL_TYPE_NUMERIC); // HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(numrec.getValue()); // cell.setCellValue(numrec.getValue());
break; // break;
//
case SSTRecord.sid : // case SSTRecord.sid :
SSTRecord sstrec = ( SSTRecord ) record; // SSTRecord sstrec = ( SSTRecord ) record;
//
for (int k = 0; k < sstrec.getNumUniqueStrings(); k++) // for (int k = 0; k < sstrec.getNumUniqueStrings(); k++)
{ // {
workbook.addSSTString(sstrec.getString(k)); // workbook.addSSTString(new UnicodeString(sstrec.getString(k)));
} // }
break; // break;
//
case LabelSSTRecord.sid : // case LabelSSTRecord.sid :
LabelSSTRecord lrec = ( LabelSSTRecord ) record; // LabelSSTRecord lrec = ( LabelSSTRecord ) record;
//
row = cursheet.getRow(lrec.getRow()); // row = cursheet.getRow(lrec.getRow());
cell = row.createCell(lrec.getColumn(), // cell = row.createCell(lrec.getColumn(),
HSSFCell.CELL_TYPE_STRING); // HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(workbook.getSSTString(lrec.getSSTIndex())); // cell.setCellValue(workbook.getSSTString(lrec.getSSTIndex()));
break; // break;
} // }
} // }
//
public static void main(String [] args) // public static void main(String [] args)
{ // {
if ((args.length < 2) || !args[ 0 ].equals("--help")) // if ((args.length < 2) || !args[ 0 ].equals("--help"))
{ // {
try // try
{ // {
EFHSSF viewer = new EFHSSF(); // EFHSSF viewer = new EFHSSF();
//
viewer.setInputFile(args[ 0 ]); // viewer.setInputFile(args[ 0 ]);
viewer.setOutputFile(args[ 1 ]); // viewer.setOutputFile(args[ 1 ]);
viewer.run(); // viewer.run();
} // }
catch (IOException e) // catch (IOException e)
{ // {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
else // else
{ // {
System.out.println("EFHSSF"); // System.out.println("EFHSSF");
System.out.println( // System.out.println(
"General testbed for HSSFEventFactory based testing and " // "General testbed for HSSFEventFactory based testing and "
+ "Code examples"); // + "Code examples");
System.out.println("Usage: java org.apache.poi.hssf.dev.EFHSSF " // System.out.println("Usage: java org.apache.poi.hssf.dev.EFHSSF "
+ "file1 file2"); // + "file1 file2");
System.out.println( // System.out.println(
" --will rewrite the file reading with the event api"); // " --will rewrite the file reading with the event api");
System.out.println("and writing with the standard API"); // System.out.println("and writing with the standard API");
} // }
} // }
} //}
//
class EFHSSFListener //class EFHSSFListener
implements HSSFListener // implements HSSFListener
{ //{
EFHSSF efhssf; // EFHSSF efhssf;
//
public EFHSSFListener(EFHSSF efhssf) // public EFHSSFListener(EFHSSF efhssf)
{ // {
this.efhssf = efhssf; // this.efhssf = efhssf;
} // }
//
public void processRecord(Record record) // public void processRecord(Record record)
{ // {
efhssf.recordHandler(record); // efhssf.recordHandler(record);
} // }
} //}

View File

@ -83,6 +83,7 @@ import org.apache.poi.hssf.record.ProtectionRev4Record;
import org.apache.poi.hssf.record.RKRecord; import org.apache.poi.hssf.record.RKRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFormatException; 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.RefModeRecord;
import org.apache.poi.hssf.record.RefreshAllRecord; import org.apache.poi.hssf.record.RefreshAllRecord;
import org.apache.poi.hssf.record.RightMarginRecord; import org.apache.poi.hssf.record.RightMarginRecord;
@ -262,22 +263,11 @@ public class EventRecordFactory
{ {
Record last_record = null; Record last_record = null;
try RecordInputStream recStream = new RecordInputStream(in);
{
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
while (recStream.hasNextRecord()) {
recStream.nextRecord();
Record[] recs = createRecord(recStream); // handle MulRK records
if (recs.length > 1) if (recs.length > 1)
{ {
for (int k = 0; k < recs.length; k++) for (int k = 0; k < recs.length; k++)
@ -288,8 +278,6 @@ public class EventRecordFactory
break; break;
} }
} }
// records.add(
// recs[ k ]); // these will be number records
last_record = last_record =
recs[ k ]; // do to keep the algorythm homogenous...you can't recs[ k ]; // do to keep the algorythm homogenous...you can't
} // actually continue a number record anyhow. } // actually continue a number record anyhow.
@ -300,19 +288,6 @@ public class EventRecordFactory
if (record != null) 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 (last_record != null) {
if (throwRecordEvent(last_record) == false && abortable == true) { if (throwRecordEvent(last_record) == false && abortable == true) {
last_record = null; last_record = null;
@ -321,35 +296,21 @@ public class EventRecordFactory
} }
last_record = record; last_record = record;
//records.add(record);
} }
} }
} }
}
}
while (rectype != 0);
if (last_record != null) { if (last_record != null) {
throwRecordEvent(last_record); 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 * create a record, if there are MUL records than multiple records
* are returned digested into the non-mul form. * are returned digested into the non-mul form.
*/ */
public static Record [] createRecord(short rectype, short size, public static Record [] createRecord(RecordInputStream in)
byte [] data)
{ {
Record retval = null; Record retval = null;
Record[] realretval = null; Record[] realretval = null;
@ -357,18 +318,18 @@ public class EventRecordFactory
try try
{ {
Constructor constructor = Constructor constructor =
( Constructor ) recordsMap.get(new Short(rectype)); ( Constructor ) recordsMap.get(new Short(in.getSid()));
if (constructor != null) if (constructor != null)
{ {
retval = ( Record ) constructor.newInstance(new Object[] retval = ( Record ) constructor.newInstance(new Object[]
{ {
new Short(rectype), new Short(size), data in
}); });
} }
else else
{ {
retval = new UnknownRecord(rectype, size, data); retval = new UnknownRecord(in);
} }
} }
catch (Exception introspectionException) catch (Exception introspectionException)
@ -470,7 +431,7 @@ public class EventRecordFactory
sid = record.getField("sid").getShort(null); sid = record.getField("sid").getShort(null);
constructor = record.getConstructor(new Class[] constructor = record.getConstructor(new Class[]
{ {
short.class, short.class, byte [].class RecordInputStream.class
}); });
} }
catch (Exception illegalArgumentException) catch (Exception illegalArgumentException)

View File

@ -24,6 +24,7 @@ import org.apache.poi.util.LittleEndian;
import org.apache.poi.hssf.eventusermodel.HSSFUserException; import org.apache.poi.hssf.eventusermodel.HSSFUserException;
import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.hssf.record.RecordFormatException;
import org.apache.poi.hssf.record.Record; 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.RecordFactory;
import org.apache.poi.hssf.record.ContinueRecord; import org.apache.poi.hssf.record.ContinueRecord;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@ -98,7 +99,7 @@ public class HSSFEventFactory
{ {
try try
{ {
genericProcessEvents(req, in); genericProcessEvents(req, new RecordInputStream(in));
} }
catch (HSSFUserException hue) catch (HSSFUserException hue)
{/*If an HSSFUserException user exception is thrown, ignore it.*/ } {/*If an HSSFUserException user exception is thrown, ignore it.*/ }
@ -117,7 +118,7 @@ public class HSSFEventFactory
public short abortableProcessEvents(HSSFRequest req, InputStream in) public short abortableProcessEvents(HSSFRequest req, InputStream in)
throws IOException, HSSFUserException 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. * @return numeric user-specified result code.
*/ */
protected short genericProcessEvents(HSSFRequest req, InputStream in) protected short genericProcessEvents(HSSFRequest req, RecordInputStream in)
throws IOException, HSSFUserException throws IOException, HSSFUserException
{ {
short userCode = 0; short userCode = 0;
short sid = 0; short sid = 0;
process: process:
try
{ {
byte[] sidbytes = new byte[ 2 ];
int bytesread = in.read(sidbytes);
Record rec = null; 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 // 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) 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); //System.out.println("creating "+sid);
Record[] recs = RecordFactory.createRecord(sid, size, Record[] recs = RecordFactory.createRecord(in);
data);
if (recs.length > 1) if (recs.length > 1)
{ // we know that the multiple { // we know that the multiple
@ -199,17 +191,9 @@ public class HSSFEventFactory
// records, it will go here too. // records, it will go here too.
} }
else else
{ // we do have a continue record
short size = LittleEndian.readShort(in);
byte[] data = new byte[ size ];
if (data.length > 0)
{ {
in.read(data); throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception");
}
rec.processContinueRecord(data);
} }
bytesread = in.read(sidbytes); // read next record sid
} }
if (rec != null) if (rec != null)
{ {
@ -217,11 +201,7 @@ public class HSSFEventFactory
if (userCode != 0) break process; if (userCode != 0) break process;
} }
} }
catch (IOException e)
{
throw new RecordFormatException("Error reading bytes" +
"while processing record sid="+sid);
}
return userCode; return userCode;
// Record[] retval = new Record[ records.size() ]; // Record[] retval = new Record[ records.size() ];

View File

@ -609,7 +609,7 @@ public class Sheet implements Model
records.remove(k); records.remove(k);
LabelSSTRecord newrec = new LabelSSTRecord(); LabelSSTRecord newrec = new LabelSSTRecord();
int stringid = int stringid =
wb.addSSTString(oldrec.getValue()); wb.addSSTString(new UnicodeString(oldrec.getValue()));
newrec.setRow(oldrec.getRow()); newrec.setRow(oldrec.getRow());
newrec.setColumn(oldrec.getColumn()); newrec.setColumn(oldrec.getColumn());

View File

@ -623,25 +623,6 @@ public class Workbook implements Model
return xf; return xf;
} }
/**
* Adds a string to the SST table and returns its index (if its a duplicate
* just returns its index and update the counts)
*
* @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) {
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "insert to sst string='", string, "' and use16bits= ",
new Boolean(use16bits));
if (sst == null) {
insertSST();
}
return sst.addString(string, use16bits);
}
/** /**
* Adds a string to the SST table and returns its index (if its a duplicate * 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 * just returns its index and update the counts) ASSUMES compressed unicode
@ -652,8 +633,13 @@ public class Workbook implements Model
* @return index of the string within the SSTRecord * @return index of the string within the SSTRecord
*/ */
public int addSSTString(String string) { public int addSSTString(UnicodeString string) {
return addSSTString(string, false); if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "insert to sst string='", string);
if (sst == null) {
insertSST();
}
return sst.addString(string);
} }
/** /**
@ -661,11 +647,11 @@ public class Workbook implements Model
* @return String containing the SST String * @return String containing the SST String
*/ */
public String getSSTString(int str) { public UnicodeString getSSTString(int str) {
if (sst == null) { if (sst == null) {
insertSST(); insertSST();
} }
String retval = sst.getString(str); UnicodeString retval = sst.getString(str);
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "Returning SST for index=", new Integer(str), log.log(DEBUG, "Returning SST for index=", new Integer(str),
@ -1631,7 +1617,7 @@ public class Workbook implements Model
*/ */
protected PaletteRecord createPalette() protected PaletteRecord createPalette()
{ {
return new PaletteRecord(PaletteRecord.sid); return new PaletteRecord();
} }
/** /**

View File

@ -57,25 +57,9 @@ public abstract class AbstractEscherHolderRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
@ -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(); escherRecords = new ArrayList();
if (! DESERIALISE ) if (! DESERIALISE )
{ {
rawData = new byte[size]; rawData = in.readRemainder();
System.arraycopy(data, offset, rawData, 0, size);
} }
else else
{ {
convertToEscherRecords( offset, size, data ); byte[] data = in.readAllContinuedRemainder();
convertToEscherRecords( 0, data.length, data );
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -58,25 +57,9 @@ public class AreaFormatRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AreaFormatRecord(short id, short size, byte [] data) public AreaFormatRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -93,16 +76,16 @@ public class AreaFormatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_foregroundColor = LittleEndian.getInt(data, pos + 0x0 + offset); field_1_foregroundColor = in.readInt();
field_2_backgroundColor = LittleEndian.getInt(data, pos + 0x4 + offset); field_2_backgroundColor = in.readInt();
field_3_pattern = LittleEndian.getShort(data, pos + 0x8 + offset); field_3_pattern = in.readShort();
field_4_formatFlags = LittleEndian.getShort(data, pos + 0xa + offset); field_4_formatFlags = in.readShort();
field_5_forecolorIndex = LittleEndian.getShort(data, pos + 0xc + offset); field_5_forecolorIndex = in.readShort();
field_6_backcolorIndex = LittleEndian.getShort(data, pos + 0xe + offset); field_6_backcolorIndex = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -54,25 +53,9 @@ public class AreaRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AreaRecord(short id, short size, byte [] data) public AreaRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -89,11 +72,11 @@ public class AreaRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_formatFlags = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_formatFlags = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -55,25 +54,9 @@ public class AxisLineFormatRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AxisLineFormatRecord(short id, short size, byte [] data) public AxisLineFormatRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -90,11 +73,11 @@ public class AxisLineFormatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_axisType = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -67,25 +66,9 @@ public class AxisOptionsRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AxisOptionsRecord(short id, short size, byte [] data) public AxisOptionsRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -102,19 +85,19 @@ public class AxisOptionsRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_minimumCategory = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_minimumCategory = in.readShort();
field_2_maximumCategory = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_maximumCategory = in.readShort();
field_3_majorUnitValue = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_majorUnitValue = in.readShort();
field_4_majorUnit = LittleEndian.getShort(data, pos + 0x6 + offset); field_4_majorUnit = in.readShort();
field_5_minorUnitValue = LittleEndian.getShort(data, pos + 0x8 + offset); field_5_minorUnitValue = in.readShort();
field_6_minorUnit = LittleEndian.getShort(data, pos + 0xa + offset); field_6_minorUnit = in.readShort();
field_7_baseUnit = LittleEndian.getShort(data, pos + 0xc + offset); field_7_baseUnit = in.readShort();
field_8_crossingPoint = LittleEndian.getShort(data, pos + 0xe + offset); field_8_crossingPoint = in.readShort();
field_9_options = LittleEndian.getShort(data, pos + 0x10 + offset); field_9_options = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -57,25 +56,9 @@ public class AxisParentRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AxisParentRecord(short id, short size, byte [] data) public AxisParentRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -92,15 +75,15 @@ public class AxisParentRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_axisType = in.readShort();
field_2_x = LittleEndian.getInt(data, pos + 0x2 + offset); field_2_x = in.readInt();
field_3_y = LittleEndian.getInt(data, pos + 0x6 + offset); field_3_y = in.readInt();
field_4_width = LittleEndian.getInt(data, pos + 0xa + offset); field_4_width = in.readInt();
field_5_height = LittleEndian.getInt(data, pos + 0xe + offset); field_5_height = in.readInt();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -58,25 +57,9 @@ public class AxisRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AxisRecord(short id, short size, byte [] data) public AxisRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -93,15 +76,15 @@ public class AxisRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_axisType = in.readShort();
field_2_reserved1 = LittleEndian.getInt(data, pos + 0x2 + offset); field_2_reserved1 = in.readInt();
field_3_reserved2 = LittleEndian.getInt(data, pos + 0x6 + offset); field_3_reserved2 = in.readInt();
field_4_reserved3 = LittleEndian.getInt(data, pos + 0xa + offset); field_4_reserved3 = in.readInt();
field_5_reserved4 = LittleEndian.getInt(data, pos + 0xe + offset); field_5_reserved4 = in.readInt();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -51,25 +50,9 @@ public class AxisUsedRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public AxisUsedRecord(short id, short size, byte [] data) public AxisUsedRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -86,11 +69,11 @@ public class AxisUsedRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_numAxis = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_numAxis = in.readShort();
} }

View File

@ -93,25 +93,9 @@ public class BOFRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
// 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);
// fillFields(data,size); // 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_1_version = in.readShort();
field_2_type = LittleEndian.getShort(data, 2 + offset); field_2_type = in.readShort();
field_3_build = LittleEndian.getShort(data, 4 + offset); field_3_build = in.readShort();
field_4_year = LittleEndian.getShort(data, 6 + offset); field_4_year = in.readShort();
field_5_history = LittleEndian.getInt(data, 8 + offset); field_5_history = in.readInt();
field_6_rversion = LittleEndian.getInt(data, 12 + offset); field_6_rversion = in.readInt();
} }
/** /**

View File

@ -47,23 +47,9 @@ public class BackupRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -57,25 +56,9 @@ public class BarRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public BarRecord(short id, short size, byte [] data) public BarRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -92,13 +75,13 @@ public class BarRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_barSpace = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_barSpace = in.readShort();
field_2_categorySpace = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_categorySpace = in.readShort();
field_3_formatFlags = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_formatFlags = in.readShort();
} }

View File

@ -46,23 +46,9 @@ public class BeginRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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)
{ {
} }

View File

@ -58,31 +58,17 @@ public class BlankRecord
* @param data data of the record (should not contain sid/len) * @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);
} }
/** protected void fillFields(RecordInputStream 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)
{ {
//field_1_row = LittleEndian.getShort(data, 0 + offset); //field_1_row = LittleEndian.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_col = LittleEndian.getShort(data, 2 + offset); field_2_col = in.readShort();
field_3_xf = LittleEndian.getShort(data, 4 + offset); field_3_xf = in.readShort();
} }
/** /**

View File

@ -47,23 +47,9 @@ public class BookBoolRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -59,23 +59,9 @@ public class BoolErrRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -86,14 +72,14 @@ public class BoolErrRecord
* @param size size of data * @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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_column = LittleEndian.getShort(data, 2 + offset); field_2_column = in.readShort();
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); field_3_xf_index = in.readShort();
field_4_bBoolErr = data[ 6 + offset ]; field_4_bBoolErr = in.readByte();
field_5_fError = data[ 7 + offset ]; field_5_fError = in.readByte();
} }
//public void setRow(short row) //public void setRow(short row)

View File

@ -46,23 +46,9 @@ public class BottomMarginRecord
* @param size size the size of the data area of the record * @param size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @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 ); super( in );
}
/**
* 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 );
} }
/** /**
@ -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() public String toString()

View File

@ -54,23 +54,9 @@ public class BoundSheetRecord
* @param data data of the record (should not contain sid/len) * @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 ); super( in );
}
/**
* 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 );
} }
protected void validateSid( short id ) 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_1_position_of_BOF = in.readInt(); // bof
field_2_option_flags = LittleEndian.getShort( data, 4 + offset ); // flags field_2_option_flags = in.readShort(); // flags
field_3_sheetname_length = data[6 + offset]; // len(str) field_3_sheetname_length = in.readByte(); // len(str)
field_4_compressed_unicode_flag = data[7 + offset]; // unicode field_4_compressed_unicode_flag = in.readByte(); // unicode
int nameLength = LittleEndian.ubyteToInt( field_3_sheetname_length ); int nameLength = LittleEndian.ubyteToInt( field_3_sheetname_length );
if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 ) if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
{ {
field_5_sheetname = StringUtil.getFromUnicodeLE( data, 8 + offset, nameLength ); field_5_sheetname = in.readUnicodeLEString(nameLength);
} }
else 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) * Set the sheetname for this sheet. (this appears in the tabs at the bottom)
* @param sheetname the name of the sheet * @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. * @throws IllegalArgumentException if sheet name will cause excel to crash.
>>>>>>> 1.14
*/ */
public void setSheetname( String sheetname ) public void setSheetname( String sheetname )

View File

@ -53,23 +53,9 @@ public class CalcCountRecord
* *
*/ */
public CalcCountRecord(short id, short size, byte [] data) public CalcCountRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -68,23 +68,9 @@ public class CalcModeRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -57,25 +56,9 @@ public class CategorySeriesAxisRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public CategorySeriesAxisRecord(short id, short size, byte [] data) public CategorySeriesAxisRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -92,14 +75,14 @@ public class CategorySeriesAxisRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_crossingPoint = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_crossingPoint = in.readShort();
field_2_labelFrequency = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_labelFrequency = in.readShort();
field_3_tickMarkFrequency = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_tickMarkFrequency = in.readShort();
field_4_options = LittleEndian.getShort(data, pos + 0x6 + offset); field_4_options = in.readShort();
} }

View File

@ -54,23 +54,9 @@ public class ChartFormatRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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); field1_x_position = in.readInt();
field2_y_position = LittleEndian.getInt(data, 4 + offset); field2_y_position = in.readInt();
field3_width = LittleEndian.getInt(data, 8 + offset); field3_width = in.readInt();
field4_height = LittleEndian.getInt(data, 12 + offset); field4_height = in.readInt();
field5_grbit = LittleEndian.getShort(data, 16 + offset); field5_grbit = in.readShort();
} }
public String toString() public String toString()

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -54,25 +53,9 @@ public class ChartRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public ChartRecord(short id, short size, byte [] data) public ChartRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -89,14 +72,14 @@ public class ChartRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_x = LittleEndian.getInt(data, pos + 0x0 + offset); field_1_x = in.readInt();
field_2_y = LittleEndian.getInt(data, pos + 0x4 + offset); field_2_y = in.readInt();
field_3_width = LittleEndian.getInt(data, pos + 0x8 + offset); field_3_width = in.readInt();
field_4_height = LittleEndian.getInt(data, pos + 0xc + offset); field_4_height = in.readInt();
} }

View File

@ -54,23 +54,9 @@ public class CodepageRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -60,33 +60,19 @@ public class ColumnInfoRecord
* @param data data of the record (should not contain sid/len) * @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);
} }
/** protected void fillFields(RecordInputStream 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); field_1_first_col = in.readShort();
} field_2_last_col = in.readShort();
field_3_col_width = in.readShort();
protected void fillFields(byte [] data, short size, int offset) field_4_xf_index = in.readShort();
{ field_5_options = in.readShort();
field_1_first_col = LittleEndian.getShort(data, 0 + offset); field_6_reserved = in.readShort();
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 ];
} }
protected void validateSid(short id) protected void validateSid(short id)

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -91,26 +90,9 @@ public class CommonObjectDataSubRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -126,16 +108,16 @@ public class CommonObjectDataSubRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_objectType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_objectType = in.readShort();
field_2_objectId = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_objectId = in.readShort();
field_3_option = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_option = in.readShort();
field_4_reserved1 = LittleEndian.getInt(data, pos + 0x6 + offset); field_4_reserved1 = in.readInt();
field_5_reserved2 = LittleEndian.getInt(data, pos + 0xa + offset); field_5_reserved2 = in.readInt();
field_6_reserved3 = LittleEndian.getInt(data, pos + 0xe + offset); field_6_reserved3 = in.readInt();
} }

View File

@ -54,23 +54,9 @@ public class ContinueRecord
* @param data raw data * @param data raw data
*/ */
public ContinueRecord(short id, short size, byte [] data) public ContinueRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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);
} }
/** /**
@ -115,74 +101,6 @@ public class ContinueRecord
return field_1_data; 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 * Make sure we have a good id
* *
@ -227,8 +145,9 @@ public class ContinueRecord
* @param ignored_parm3 Ignored * @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();
} }
/** /**

View File

@ -51,23 +51,9 @@ public class CountryRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_default_country = in.readShort();
field_2_current_country = LittleEndian.getShort(data, 2 + offset); field_2_current_country = in.readShort();
} }
/** /**

View File

@ -32,7 +32,7 @@ public interface CustomField
* @param offset of the record's data (provided a big array of the file) * @param offset of the record's data (provided a big array of the file)
* @return the number of bytes read. * @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 * Appends the string representation of this field to the supplied

View File

@ -49,23 +49,9 @@ public class DBCellRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_row_offset = in.readUShort();
field_2_cell_offsets = new short[ (size - 4) / 2 ]; int size = in.remaining();
int element = 0; 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, field_2_cell_offsets[ i ] = in.readShort();
k + offset);
} }
} }

View File

@ -47,23 +47,9 @@ public class DSFRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -55,25 +54,9 @@ public class DatRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public DatRecord(short id, short size, byte [] data) public DatRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -90,11 +73,11 @@ public class DatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_options = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -55,25 +54,9 @@ public class DataFormatRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public DataFormatRecord(short id, short size, byte [] data) public DataFormatRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -90,14 +73,14 @@ public class DataFormatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_pointNumber = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_pointNumber = in.readShort();
field_2_seriesIndex = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_seriesIndex = in.readShort();
field_3_seriesNumber = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_seriesNumber = in.readShort();
field_4_formatFlags = LittleEndian.getShort(data, pos + 0x6 + offset); field_4_formatFlags = in.readShort();
} }

View File

@ -47,24 +47,9 @@ public class DateWindow1904Record
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -48,24 +48,9 @@ public class DefaultColWidthRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -54,25 +53,9 @@ public class DefaultDataLabelTextPropertiesRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public DefaultDataLabelTextPropertiesRecord(short id, short size, byte [] data) public DefaultDataLabelTextPropertiesRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -89,11 +72,11 @@ public class DefaultDataLabelTextPropertiesRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_categoryDataType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_categoryDataType = in.readShort();
} }

View File

@ -49,24 +49,9 @@ public class DefaultRowHeightRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_option_flags = in.readShort();
field_2_row_height = LittleEndian.getShort(data, 2 + offset); field_2_row_height = in.readShort();
} }
/** /**

View File

@ -51,23 +51,9 @@ public class DeltaRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -52,23 +52,9 @@ public class DimensionsRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_first_row = in.readInt();
field_2_last_row = LittleEndian.getInt(data, 4 + offset); field_2_last_row = in.readInt();
field_3_first_col = LittleEndian.getShort(data, 8 + offset); field_3_first_col = in.readShort();
field_4_last_col = LittleEndian.getShort(data, 10 + offset); field_4_last_col = in.readShort();
field_5_zero = LittleEndian.getShort(data, 12 + offset); field_5_zero = in.readShort();
} }
/** /**

View File

@ -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 ); super( in );
}
public DrawingGroupRecord( short id, short size, byte[] data, int offset )
{
super( id, size, data, offset );
} }
protected String getRecordName() protected String getRecordName()

View File

@ -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 ); super( in );
}
public DrawingRecord( short id, short size, byte[] data, int offset )
{
super( id, size, data, offset );
} }
/** /**
@ -50,22 +45,9 @@ public class DrawingRecord extends Record
} }
} }
protected void fillFields( byte[] data, short size, int offset ) protected void fillFields( RecordInputStream in )
{ {
if (offset == 0 && size == data.length) recordData = in.readRemainder();
{
recordData = data;
}
else
{
recordData = new byte[size];
System.arraycopy(data, offset, recordData, 0, size);
}
}
protected void fillFields( byte[] data, short size )
{
recordData = data;
} }
public void processContinueRecord( byte[] record ) public void processContinueRecord( byte[] record )

View File

@ -29,14 +29,9 @@ public class DrawingRecordForBiffViewer
{ {
} }
public DrawingRecordForBiffViewer( short id, short size, byte[] data ) public DrawingRecordForBiffViewer( RecordInputStream in)
{ {
super( id, size, data ); super(in);
}
public DrawingRecordForBiffViewer( short id, short size, byte[] data, int offset )
{
super( id, size, data, offset );
} }
protected String getRecordName() protected String getRecordName()

View File

@ -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 ); super( in );
}
public DrawingSelectionRecord( short id, short size, byte[] data, int offset )
{
super( id, size, data, offset );
} }
protected String getRecordName() protected String getRecordName()

View File

@ -48,23 +48,9 @@ public class EOFRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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)
{ {
} }

View File

@ -46,24 +46,11 @@ public class EndRecord
* @param data data of the record (should not contain sid/len) * @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) 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)
{ {
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -50,25 +49,9 @@ public class EndSubRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public EndSubRecord(short id, short size, byte [] data) public EndSubRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -85,7 +68,7 @@ public class EndSubRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;

View File

@ -49,14 +49,9 @@ public class ExtSSTInfoSubRecord
{ {
} }
public ExtSSTInfoSubRecord(short id, short size, byte [] data) public ExtSSTInfoSubRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
public ExtSSTInfoSubRecord(short id, short size, byte [] data, int offset)
{
super(id, size, data, offset);
} }
protected void validateSid(short id) protected void validateSid(short id)
@ -65,11 +60,11 @@ public class ExtSSTInfoSubRecord
// do nothing // 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_1_stream_pos = in.readInt();
field_2_bucket_sst_offset = LittleEndian.getShort(data, 4 + offset); field_2_bucket_sst_offset = in.readShort();
field_3_zero = LittleEndian.getShort(data, 6 + offset); field_3_zero = in.readShort();
} }
public void setStreamPos(int pos) public void setStreamPos(int pos)

View File

@ -60,23 +60,9 @@ public class ExtSSTRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_2_sst_info = new ArrayList();
field_1_strings_per_bucket = LittleEndian.getShort(data, 0 + offset); field_1_strings_per_bucket = in.readShort();
for (int k = 2; k < (size-offset); k += 8) while (in.remaining() > 0) {
{ ExtSSTInfoSubRecord rec = new ExtSSTInfoSubRecord(in);
byte[] tempdata = new byte[ 8 + offset ];
System.arraycopy(data, k, tempdata, 0, 8);
ExtSSTInfoSubRecord rec = new ExtSSTInfoSubRecord(( short ) 0,
( short ) 8, tempdata);
field_2_sst_info.add(rec); field_2_sst_info.add(rec);
} }

View File

@ -201,23 +201,9 @@ public class ExtendedFormatRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) protected void validateSid(short id)
@ -228,25 +214,17 @@ public class ExtendedFormatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
field_1_font_index = LittleEndian.getShort(data, field_1_font_index = in.readShort();
0 + offset); field_2_format_index = in.readShort();
field_2_format_index = LittleEndian.getShort(data, field_3_cell_options = in.readShort();
2 + offset); field_4_alignment_options = in.readShort();
field_3_cell_options = LittleEndian.getShort(data, field_5_indention_options = in.readShort();
4 + offset); field_6_border_options = in.readShort();
field_4_alignment_options = LittleEndian.getShort(data, field_7_palette_options = in.readShort();
6 + offset); field_8_adtl_palette_options = in.readInt();
field_5_indention_options = LittleEndian.getShort(data, field_9_fill_palette_options = in.readShort();
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);
} }
/** /**

View File

@ -47,20 +47,8 @@ public class ExternSheetRecord extends Record {
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public ExternSheetRecord(short id, short size, byte[] data) { public ExternSheetRecord(RecordInputStream in) {
super(id, size, data); super(in);
}
/**
* 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);
} }
/** /**
@ -83,16 +71,13 @@ public class ExternSheetRecord extends Record {
* @param size size of data * @param size size of data
* @param offset of the record's data (provided a big array of the file) * @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_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) { for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) {
ExternSheetSubRecord rec = new ExternSheetSubRecord((short)0, (short)6 , data , pos); ExternSheetSubRecord rec = new ExternSheetSubRecord(in);
pos += 6;
field_2_REF_structures.add( rec); field_2_REF_structures.add( rec);
} }

View File

@ -47,21 +47,10 @@ public class ExternSheetSubRecord extends Record {
* @param size the size of the data area of the record * @param size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public ExternSheetSubRecord(short id, short size, byte[] data) { public ExternSheetSubRecord(RecordInputStream in) {
super(id, size, data); 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 /** Sets the Index to the sup book
* @param index sup book index * @param index sup book index
@ -123,10 +112,10 @@ public class ExternSheetSubRecord extends Record {
* @param size size of data * @param size size of data
* @param offset of the record's data (provided a big array of the file) * @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_1_index_to_supbook = LittleEndian.getShort(data, 0 + offset); field_1_index_to_supbook = in.readShort();
field_2_index_to_first_supbook_sheet = LittleEndian.getShort(data, 2 + offset); field_2_index_to_first_supbook_sheet = in.readShort();
field_3_index_to_last_supbook_sheet = LittleEndian.getShort(data, 4 + offset); field_3_index_to_last_supbook_sheet = in.readShort();
} }

View File

@ -53,23 +53,9 @@ public class FnGroupCountRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -55,25 +54,9 @@ public class FontBasisRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public FontBasisRecord(short id, short size, byte [] data) public FontBasisRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -90,15 +73,15 @@ public class FontBasisRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_xBasis = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_xBasis = in.readShort();
field_2_yBasis = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_yBasis = in.readShort();
field_3_heightBasis = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_heightBasis = in.readShort();
field_4_scale = LittleEndian.getShort(data, pos + 0x6 + offset); field_4_scale = in.readShort();
field_5_indexToFontTable = LittleEndian.getShort(data, pos + 0x8 + offset); field_5_indexToFontTable = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -51,25 +50,9 @@ public class FontIndexRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public FontIndexRecord(short id, short size, byte [] data) public FontIndexRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -86,11 +69,11 @@ public class FontIndexRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_fontIndex = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_fontIndex = in.readShort();
} }

View File

@ -83,24 +83,9 @@ public class FontRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_font_height = in.readShort();
field_2_attributes = LittleEndian.getShort(data, 2 + offset); field_2_attributes = in.readShort();
field_3_color_palette_index = LittleEndian.getShort(data, 4 + offset); field_3_color_palette_index = in.readShort();
field_4_bold_weight = LittleEndian.getShort(data, 6 + offset); field_4_bold_weight = in.readShort();
field_5_super_sub_script = LittleEndian.getShort(data, 8 + offset); field_5_super_sub_script = in.readShort();
field_6_underline = data[ 10 + offset ]; field_6_underline = in.readByte();
field_7_family = data[ 11 + offset ]; field_7_family = in.readByte();
field_8_charset = data[ 12 + offset ]; field_8_charset = in.readByte();
field_9_zero = data[ 13 + offset ]; field_9_zero = in.readByte();
field_10_font_name_len = data[ 14 + offset ]; field_10_font_name_len = in.readByte();
if (field_10_font_name_len > 0) if (field_10_font_name_len > 0)
{ {
if (data[ 15 ] == 0) if (in.readByte() == 0)
{ // is compressed unicode { // is compressed unicode
field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16, field_11_font_name = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_10_font_name_len));
LittleEndian.ubyteToInt(field_10_font_name_len));
} }
else else
{ // is not compressed unicode { // is not compressed unicode
field_11_font_name = StringUtil.getFromUnicodeLE(data, 16, field_11_font_name = in.readUnicodeLEString(field_10_font_name_len);
field_10_font_name_len);
} }
} }
} }

View File

@ -36,8 +36,9 @@ public class FooterRecord
{ {
public final static short sid = 0x15; public final static short sid = 0x15;
private byte field_1_footer_len; private byte field_1_footer_len;
private byte field_2_unicode_flag; private byte field_2_reserved;
private String field_3_footer; private byte field_3_unicode_flag;
private String field_4_footer;
public FooterRecord() public FooterRecord()
{ {
@ -51,23 +52,9 @@ public class FooterRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_footer_len = in.readByte();
field_2_unicode_flag = data[ 2 + offset ]; /** 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()) if(isMultibyte())
{ {
field_3_footer = StringUtil.getFromUnicodeLE( field_4_footer = in.readUnicodeLEString(LittleEndian.ubyteToInt( field_1_footer_len));
data,3 + offset,LittleEndian.ubyteToInt(field_1_footer_len));
} }
else else
{ {
field_3_footer = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string field_4_footer = in.readCompressedUnicode(LittleEndian.ubyteToInt( field_1_footer_len));
LittleEndian.ubyteToInt( field_1_footer_len) );
} }
} }
} }
@ -104,7 +92,7 @@ public class FooterRecord
* true:footer string has at least one multibyte character * true:footer string has at least one multibyte character
*/ */
public boolean isMultibyte() { 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) public void setFooter(String footer)
{ {
field_3_footer = footer; field_4_footer = footer;
field_2_unicode_flag = field_3_unicode_flag =
(byte) (StringUtil.hasMultibyte(field_3_footer) ? 1 : 0); (byte) (StringUtil.hasMultibyte(field_4_footer) ? 1 : 0);
} }
/** /**
@ -155,7 +143,7 @@ public class FooterRecord
public String getFooter() public String getFooter()
{ {
return field_3_footer; return field_4_footer;
} }
public String toString() public String toString()
@ -187,7 +175,7 @@ public class FooterRecord
if (getFooterLength() > 0) if (getFooterLength() > 0)
{ {
data[ 4 + offset ] = (byte)getFooterLength(); data[ 4 + offset ] = (byte)getFooterLength();
data[ 6 + offset ] = field_2_unicode_flag; data[ 6 + offset ] = field_3_unicode_flag;
if(isMultibyte()) if(isMultibyte())
{ {
StringUtil.putUnicodeLE(getFooter(), data, 7 + offset); StringUtil.putUnicodeLE(getFooter(), data, 7 + offset);
@ -220,8 +208,9 @@ public class FooterRecord
public Object clone() { public Object clone() {
FooterRecord rec = new FooterRecord(); FooterRecord rec = new FooterRecord();
rec.field_1_footer_len = field_1_footer_len; rec.field_1_footer_len = field_1_footer_len;
rec.field_2_unicode_flag = field_2_unicode_flag; rec.field_2_reserved = field_2_reserved;
rec.field_3_footer = field_3_footer; rec.field_3_unicode_flag = field_3_unicode_flag;
rec.field_4_footer = field_4_footer;
return rec; return rec;
} }
} }

View File

@ -53,23 +53,9 @@ public class FormatRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_index_code = in.readShort();
// field_2_formatstring_len = data[ 2 + offset ]; field_3_unicode_len = in.readShort();
field_3_unicode_len = LittleEndian.getShort( data, 2 + offset ); field_3_unicode_flag = ( in.readByte() & (byte)0x01 ) != 0;
field_3_unicode_flag = ( data[ 4 + offset ] & (byte)0x01 ) != 0;
if ( field_3_unicode_flag ) { if ( field_3_unicode_flag ) {
// unicode // unicode
field_4_formatstring = StringUtil.getFromUnicodeLE( data, 5 + offset, field_3_unicode_len ); field_4_formatstring = in.readUnicodeLEString( field_3_unicode_len );
} }
else { else {
// not unicode // not unicode
field_4_formatstring = StringUtil.getFromCompressedUnicode(data, 5 + offset, field_3_unicode_len ); field_4_formatstring = in.readCompressedUnicode( field_3_unicode_len );
} }
} }

View File

@ -80,68 +80,40 @@ public class FormulaRecord
* @param data data of the record (should not contain sid/len) * @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);
} }
/** protected void fillFields(RecordInputStream 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)
{ {
try { try {
//field_1_row = LittleEndian.getShort(data, 0 + offset); field_1_row = in.readUShort();
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_2_column = in.readShort();
field_2_column = LittleEndian.getShort(data, 2 + offset); field_3_xf = in.readShort();
field_3_xf = LittleEndian.getShort(data, 4 + offset); field_4_value = in.readDouble();
field_4_value = LittleEndian.getDouble(data, 6 + offset); field_5_options = in.readShort();
field_5_options = LittleEndian.getShort(data, 14 + offset);
if (Double.isNaN(field_4_value)) { if (Double.isNaN(field_4_value)) {
value_data = new byte[8]; value_data = in.getNANData();
System.arraycopy(data, offset+6, value_data, 0, 8);
} }
field_6_zero = LittleEndian.getInt(data, 16 + offset); field_6_zero = in.readInt();
field_7_expression_len = LittleEndian.getShort(data, 20 + offset); field_7_expression_len = in.readShort();
field_8_parsed_expr = getParsedExpressionTokens(data, size, field_8_parsed_expr = getParsedExpressionTokens(in, field_7_expression_len);
22 + offset);
} catch (java.lang.UnsupportedOperationException uoe) { } catch (java.lang.UnsupportedOperationException uoe) {
field_8_parsed_expr = null; throw new RecordFormatException(uoe.toString());
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+")");
} }
} }
private Stack getParsedExpressionTokens(byte [] data, short size, private Stack getParsedExpressionTokens(RecordInputStream in, short size)
int offset)
{ {
Stack stack = new Stack(); Stack stack = new Stack();
int pos = offset; int pos = 0;
while (pos < size) while (pos < size)
{ {
Ptg ptg = Ptg.createPtg(data, pos); Ptg ptg = Ptg.createPtg(in);
pos += ptg.getSize(); pos += ptg.getSize();
stack.push(ptg); stack.push(ptg);
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -56,25 +55,9 @@ public class FrameRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public FrameRecord(short id, short size, byte [] data) public FrameRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -91,12 +74,12 @@ public class FrameRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_borderType = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_borderType = in.readShort();
field_2_options = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_options = in.readShort();
} }

View File

@ -51,23 +51,9 @@ public class GridsetRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -49,25 +49,9 @@ public class GroupMarkerSubRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
@ -84,11 +68,10 @@ public class GroupMarkerSubRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
// int pos = 0; // int pos = 0;
reserved = new byte[size]; reserved = in.readRemainder();
System.arraycopy(data, offset, reserved, 0, size);
} }
public String toString() public String toString()

View File

@ -50,23 +50,9 @@ public class GutsRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_left_row_gutter = in.readShort();
field_2_top_col_gutter = LittleEndian.getShort(data, 2 + offset); field_2_top_col_gutter = in.readShort();
field_3_row_level_max = LittleEndian.getShort(data, 4 + offset); field_3_row_level_max = in.readShort();
field_4_col_level_max = LittleEndian.getShort(data, 6 + offset); field_4_col_level_max = in.readShort();
} }
/** /**

View File

@ -47,23 +47,9 @@ public class HCenterRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -36,8 +36,9 @@ public class HeaderRecord
{ {
public final static short sid = 0x14; public final static short sid = 0x14;
private byte field_1_header_len; private byte field_1_header_len;
private byte field_2_unicode_flag; private byte field_2_reserved;
private String field_3_header; private byte field_3_unicode_flag;
private String field_4_header;
public HeaderRecord() public HeaderRecord()
{ {
@ -51,23 +52,9 @@ public class HeaderRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_header_len = in.readByte();
field_2_unicode_flag = data[ 2 + offset ]; /** 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()) if(isMultibyte())
{ {
field_3_header = StringUtil.getFromUnicodeLE( field_4_header = in.readUnicodeLEString(LittleEndian.ubyteToInt( field_1_header_len));
data,3 + offset,LittleEndian.ubyteToInt(field_1_header_len));
} }
else else
{ {
field_3_header = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string field_4_header = in.readCompressedUnicode(LittleEndian.ubyteToInt( field_1_header_len));
LittleEndian.ubyteToInt( field_1_header_len) );
} }
} }
} }
@ -104,7 +92,7 @@ public class HeaderRecord
* true:footer string has at least one multibyte character * true:footer string has at least one multibyte character
*/ */
public boolean isMultibyte() { 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) public void setHeader(String header)
{ {
field_3_header = header; field_4_header = header;
field_2_unicode_flag = field_3_unicode_flag =
(byte) (StringUtil.hasMultibyte(field_3_header) ? 1 : 0); (byte) (StringUtil.hasMultibyte(field_4_header) ? 1 : 0);
} }
/** /**
@ -154,7 +142,7 @@ public class HeaderRecord
public String getHeader() public String getHeader()
{ {
return field_3_header; return field_4_header;
} }
public String toString() public String toString()
@ -187,7 +175,7 @@ public class HeaderRecord
if (getHeaderLength() > 0) if (getHeaderLength() > 0)
{ {
data[ 4 + offset ] = (byte)getHeaderLength(); data[ 4 + offset ] = (byte)getHeaderLength();
data[ 6 + offset ] = field_2_unicode_flag; data[ 6 + offset ] = field_3_unicode_flag;
if(isMultibyte()) if(isMultibyte())
{ {
StringUtil.putUnicodeLE(getHeader(), data, 7 + offset); StringUtil.putUnicodeLE(getHeader(), data, 7 + offset);
@ -220,8 +208,9 @@ public class HeaderRecord
public Object clone() { public Object clone() {
HeaderRecord rec = new HeaderRecord(); HeaderRecord rec = new HeaderRecord();
rec.field_1_header_len = field_1_header_len; rec.field_1_header_len = field_1_header_len;
rec.field_2_unicode_flag = field_2_unicode_flag; rec.field_2_reserved = field_2_reserved;
rec.field_3_header = field_3_header; rec.field_3_unicode_flag = field_3_unicode_flag;
rec.field_4_header = field_4_header;
return rec; return rec;
} }
} }

View File

@ -49,23 +49,9 @@ public class HideObjRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -47,18 +47,8 @@ public class HorizontalPageBreakRecord extends PageBreakRecord {
* @param size * @param size
* @param data * @param data
*/ */
public HorizontalPageBreakRecord(short id, short size, byte[] data) { public HorizontalPageBreakRecord(RecordInputStream in) {
super(id, size, data); super(in);
}
/**
* @param id
* @param size
* @param data
* @param offset
*/
public HorizontalPageBreakRecord(short id, short size, byte[] data, int offset) {
super(id, size, data, offset);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -55,23 +55,9 @@ public class IndexRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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 = field_5_dbcells =
new IntList(DBCELL_CAPACITY); // initial capacity of 30 new IntList(DBCELL_CAPACITY); // initial capacity of 30
field_1_zero = LittleEndian.getInt(data, 0 + offset); field_1_zero = in.readInt();
field_2_first_row = LittleEndian.getInt(data, 4 + offset); field_2_first_row = in.readInt();
field_3_last_row_add1 = LittleEndian.getInt(data, 8 + offset); field_3_last_row_add1 = in.readInt();
field_4_zero = LittleEndian.getInt(data, 12 + offset); field_4_zero = in.readInt();
for (int k = 16; k < size; k = k + 4) while(in.remaining() > 0)
{ {
// System.out.println("getting " + k); // System.out.println("getting " + k);
field_5_dbcells.add(LittleEndian.getInt(data, k + offset)); field_5_dbcells.add(in.readInt());
} }
} }

View File

@ -46,23 +46,9 @@ public class InterfaceEndRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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)
{ {
} }

View File

@ -52,23 +52,9 @@ public class InterfaceHdrRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -50,23 +50,9 @@ public class IterationRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -63,23 +63,9 @@ public class LabelRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -105,22 +91,19 @@ public class LabelRecord
* @param size size of data * @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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_column = LittleEndian.getShort(data, 2 + offset); field_2_column = in.readShort();
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); field_3_xf_index = in.readShort();
field_4_string_len = LittleEndian.getShort(data, 6 + offset); field_4_string_len = in.readShort();
field_5_unicode_flag = data[ 8 + offset ]; field_5_unicode_flag = in.readByte();
if (field_4_string_len > 0) { if (field_4_string_len > 0) {
if (isUnCompressedUnicode()) { if (isUnCompressedUnicode()) {
field_6_value = StringUtil.getFromUnicodeLE(data, 9 + offset, field_6_value = in.readUnicodeLEString(field_4_string_len);
field_4_string_len); } else {
} field_6_value = in.readCompressedUnicode(field_4_string_len);
else {
field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset,
getStringLength());
} }
} else field_6_value = null; } else field_6_value = null;
} }

View File

@ -53,24 +53,11 @@ public class LabelSSTRecord
* @param data data of the record (should not contain sid/len) * @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) 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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_column = LittleEndian.getShort(data, 2 + offset); field_2_column = in.readShort();
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); field_3_xf_index = in.readShort();
field_4_sst_index = LittleEndian.getInt(data, 6 + offset); field_4_sst_index = in.readInt();
} }
//public void setRow(short row) //public void setRow(short row)

View File

@ -38,19 +38,8 @@ public class LeftMarginRecord extends Record implements Margin
* @param size size the size of the data area of the record * @param size size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public LeftMarginRecord( short id, short size, byte[] data ) public LeftMarginRecord(RecordInputStream in)
{ super( id, size, data ); } { super(in); }
/**
* 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 ); }
/** /**
* Checks the sid matches the expected side for this record * 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() public String toString()

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -72,25 +71,9 @@ public class LegendRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public LegendRecord(short id, short size, byte [] data) public LegendRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -107,17 +90,17 @@ public class LegendRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_xAxisUpperLeft = LittleEndian.getInt(data, pos + 0x0 + offset); field_1_xAxisUpperLeft = in.readInt();
field_2_yAxisUpperLeft = LittleEndian.getInt(data, pos + 0x4 + offset); field_2_yAxisUpperLeft = in.readInt();
field_3_xSize = LittleEndian.getInt(data, pos + 0x8 + offset); field_3_xSize = in.readInt();
field_4_ySize = LittleEndian.getInt(data, pos + 0xc + offset); field_4_ySize = in.readInt();
field_5_type = data[ pos + 0x10 + offset ]; field_5_type = in.readByte();
field_6_spacing = data[ pos + 0x11 + offset ]; field_6_spacing = in.readByte();
field_7_options = LittleEndian.getShort(data, pos + 0x12 + offset); field_7_options = in.readShort();
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -71,25 +70,9 @@ public class LineFormatRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public LineFormatRecord(short id, short size, byte [] data) public LineFormatRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -106,15 +89,15 @@ public class LineFormatRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_lineColor = LittleEndian.getInt(data, pos + 0x0 + offset); field_1_lineColor = in.readInt();
field_2_linePattern = LittleEndian.getShort(data, pos + 0x4 + offset); field_2_linePattern = in.readShort();
field_3_weight = LittleEndian.getShort(data, pos + 0x6 + offset); field_3_weight = in.readShort();
field_4_format = LittleEndian.getShort(data, pos + 0x8 + offset); field_4_format = in.readShort();
field_5_colourPaletteIndex = LittleEndian.getShort(data, pos + 0xa + offset); field_5_colourPaletteIndex = in.readShort();
} }

View File

@ -46,10 +46,10 @@ public class LinkedDataFormulaField
return size + 2; return size + 2;
} }
public int fillField( byte[] data, short size, int offset ) public int fillField( RecordInputStream in )
{ {
short tokenSize = LittleEndian.getShort(data, offset); short tokenSize = in.readShort();
formulaTokens = getParsedExpressionTokens(data, size, offset + 2); formulaTokens = getParsedExpressionTokens(tokenSize, in);
return tokenSize + 2; return tokenSize + 2;
} }
@ -103,15 +103,13 @@ public class LinkedDataFormulaField
} }
} }
private Stack getParsedExpressionTokens( byte[] data, short size, private Stack getParsedExpressionTokens(short size, RecordInputStream in )
int offset )
{ {
Stack stack = new Stack(); Stack stack = new Stack();
int pos = offset; int pos = 0;
while ( pos < size ) while ( pos < size )
{ {
Ptg ptg = Ptg.createPtg( data, pos ); Ptg ptg = Ptg.createPtg( in );
pos += ptg.getSize(); pos += ptg.getSize();
stack.push( ptg ); stack.push( ptg );
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -64,25 +63,9 @@ public class LinkedDataRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
@ -99,17 +82,14 @@ public class LinkedDataRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
field_1_linkType = in.readByte();
int pos = 0; field_2_referenceType = in.readByte();
field_1_linkType = data[ pos + 0x0 + offset ]; field_3_options = in.readShort();
field_2_referenceType = data[ pos + 0x1 + offset ]; field_4_indexNumberFmtRecord = in.readShort();
field_3_options = LittleEndian.getShort(data, pos + 0x2 + offset);
field_4_indexNumberFmtRecord = LittleEndian.getShort(data, pos + 0x4 + offset);
field_5_formulaOfLink = new org.apache.poi.hssf.record.LinkedDataFormulaField(); 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() public String toString()

View File

@ -48,23 +48,9 @@ public class MMSRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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_1_addMenuCount = in.readByte();
field_2_delMenuCount = data[ 1 + offset ]; field_2_delMenuCount = in.readByte();
} }
/** /**

View File

@ -50,41 +50,22 @@ public class MergeCellsRecord
* @param data data of the record (should not contain sid/len) * @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);
} }
/** protected void fillFields(RecordInputStream 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); short numAreas = in.readShort();
}
protected void fillFields(byte [] data, short size, int offset)
{
short numAreas = LittleEndian.getShort(data, 0 + offset);
field_2_regions = new ArrayList(numAreas + 10); field_2_regions = new ArrayList(numAreas + 10);
int pos = 2;
for (int k = 0; k < numAreas; k++) for (int k = 0; k < numAreas; k++)
{ {
MergedRegion region = MergedRegion region =
new MergedRegion(LittleEndian new MergedRegion(in.readShort(), in.readShort(),
.getShort(data, pos + offset), LittleEndian in.readShort(), in.readShort());
.getShort(data, pos + 2 + offset), LittleEndian
.getShort(data, pos + 4 + offset), LittleEndian
.getShort(data, pos + 6 + offset));
pos += 8;
field_2_regions.add(region); field_2_regions.add(region);
} }
} }

View File

@ -62,23 +62,9 @@ public class MulBlankRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -142,31 +128,22 @@ public class MulBlankRecord
* @param size size of data * @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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_first_col = LittleEndian.getShort(data, 2 + offset); field_2_first_col = in.readShort();
field_3_xfs = parseXFs(data, 4, offset, size); field_3_xfs = parseXFs(in);
field_4_last_col = LittleEndian.getShort(data, field_4_last_col = in.readShort();
(field_3_xfs.length * 2)
+ 4 + offset);
} }
private short [] parseXFs(byte [] data, int offset, int recoffset, private short [] parseXFs(RecordInputStream in)
short size)
{ {
short[] retval = new short[ ((size - offset) - 2) / 2 ]; short[] retval = new short[ (in.remaining() - 2) / 2 ];
int idx = 0;
for (; offset < size - 2; ) for (int idx = 0; idx < retval.length;idx++)
{ {
short xf = 0; retval[idx] = in.readShort();
xf = LittleEndian.getShort(data, offset + recoffset);
offset += 2;
retval[ idx ] = xf;
idx++;
} }
return retval; return retval;
} }

View File

@ -60,23 +60,9 @@ public class MulRKRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
//public short getRow() //public short getRow()
@ -143,30 +129,23 @@ public class MulRKRecord
* @param size size of data * @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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_first_col = LittleEndian.getShort(data, 2 + offset); field_2_first_col = in.readShort();
field_3_rks = parseRKs(data, 4, offset, size); field_3_rks = parseRKs(in);
field_4_last_col = LittleEndian.getShort(data, field_4_last_col = in.readShort();
(field_3_rks.size() * 6)
+ 4 + offset);
} }
private ArrayList parseRKs(byte [] data, int offset, int recoffset, private ArrayList parseRKs(RecordInputStream in)
short size)
{ {
ArrayList retval = new ArrayList(); ArrayList retval = new ArrayList();
while ((in.remaining()-2) > 0) {
for (; offset < size - 2; )
{
RkRec rec = new RkRec(); RkRec rec = new RkRec();
rec.xf = LittleEndian.getShort(data, offset + recoffset); rec.xf = in.readShort();
offset += 2; rec.rk = in.readInt();
rec.rk = LittleEndian.getInt(data, offset + recoffset);
offset += 4;
retval.add(rec); retval.add(rec);
} }
return retval; return retval;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Copyright 2002-2004 Apache Software Foundation Copyright 2002-2004 Apache Software Foundation
@ -115,7 +114,6 @@ public class NameRecord extends Record {
private byte field_12_builtIn_name; private byte field_12_builtIn_name;
private String field_12_name_text; private String field_12_name_text;
private Stack field_13_name_definition; 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_14_custom_menu_text;
private String field_15_description_text; private String field_15_description_text;
private String field_16_help_topic_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 size the size of the data area of the record
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public NameRecord(short id, short size, byte [] data) { public NameRecord(RecordInputStream in) {
super(id, size, data); super(in);
}
/**
* 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);
} }
/** /**
@ -553,15 +539,7 @@ public class NameRecord extends Record {
} }
if ( this.field_13_name_definition != null )
{
serializePtgs( data, start_of_name_definition + offset ); 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; 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 size size of data
* @param offset of the record's data (provided a big array of the file) * @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_1_option_flag = LittleEndian.getShort(data, 0 + offset); field_1_option_flag = in.readShort();
field_2_keyboard_shortcut = data [2 + offset]; field_2_keyboard_shortcut = in.readByte();
field_3_length_name_text = data [3 + offset]; field_3_length_name_text = in.readByte();
field_4_length_name_definition = LittleEndian.getShort(data, 4 + offset); field_4_length_name_definition = in.readShort();
field_5_index_to_sheet = LittleEndian.getShort(data, 6 + offset); field_5_index_to_sheet = in.readShort();
field_6_equals_to_index_to_sheet= LittleEndian.getShort(data, 8 + offset); field_6_equals_to_index_to_sheet= in.readShort();
field_7_length_custom_menu = data [10 + offset]; field_7_length_custom_menu = in.readByte();
field_8_length_description_text = data [11 + offset]; field_8_length_description_text = in.readByte();
field_9_length_help_topic_text = data [12 + offset]; field_9_length_help_topic_text = in.readByte();
field_10_length_status_bar_text = data [13 + offset]; field_10_length_status_bar_text = in.readByte();
/*
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];
//store the name in byte form if it's a builtin name //store the name in byte form if it's a builtin name
field_11_compressed_unicode_flag= in.readByte();
if (this.isBuiltInName()) { 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, field_13_name_definition = getParsedExpressionTokens(in, field_4_length_name_definition);
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);
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; //Who says that this can only ever be compressed unicode???
field_14_custom_menu_text = StringUtil.getFromCompressedUnicode(data, start_of_custom_menu_text + offset, field_14_custom_menu_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_7_length_custom_menu));
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 = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_8_length_description_text));
field_15_description_text = StringUtil.getFromCompressedUnicode(data, start_of_description_text + offset,
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 = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_9_length_help_topic_text));
field_16_help_topic_text = StringUtil.getFromCompressedUnicode(data, start_of_help_topic_text + offset,
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 = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_10_length_status_bar_text));
field_17_status_bar_text = StringUtil.getFromCompressedUnicode(data, start_of_status_bar_text + offset,
LittleEndian.ubyteToInt(field_10_length_status_bar_text));
/*} */ /*} */
} }
private Stack getParsedExpressionTokens(byte [] data, short size, private Stack getParsedExpressionTokens(RecordInputStream in, short size) {
int offset, int start_of_expression) {
Stack stack = new Stack(); Stack stack = new Stack();
int pos = start_of_expression + offset;
int sizeCounter = 0; int sizeCounter = 0;
try { try {
while (sizeCounter < size) { while (sizeCounter < size) {
Ptg ptg = Ptg.createPtg(data, pos); Ptg ptg = Ptg.createPtg(in);
pos += ptg.getSize();
sizeCounter += ptg.getSize(); sizeCounter += ptg.getSize();
stack.push(ptg); 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) { } catch (java.lang.UnsupportedOperationException uoe) {
System.err.println("[WARNING] Unknown Ptg " throw new RecordFormatException(uoe.toString());
+ 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;
} }
return stack; return stack;
} }
@ -915,10 +851,6 @@ public class NameRecord extends Record {
.append("\n"); .append("\n");
buffer.append(" .Name (Unicode text) = ").append( getNameText() ) buffer.append(" .Name (Unicode text) = ").append( getNameText() )
.append("\n"); .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 ) buffer.append(" .Menu text (Unicode string without length field) = ").append( field_14_custom_menu_text )
.append("\n"); .append("\n");
buffer.append(" .Description text (Unicode string without length field) = ").append( field_15_description_text ) 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"); .append("\n");
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text ) buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text )
.append("\n"); .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"); buffer.append("[/NAME]\n");
return buffer.toString(); return buffer.toString();
@ -958,6 +888,4 @@ public class NameRecord extends Record {
return "Unknown"; return "Unknown";
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -51,25 +50,9 @@ public class NumberFormatIndexRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public NumberFormatIndexRecord(short id, short size, byte [] data) public NumberFormatIndexRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -86,11 +69,11 @@ public class NumberFormatIndexRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_formatIndex = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_formatIndex = in.readShort();
} }

View File

@ -58,23 +58,9 @@ public class NumberRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -85,13 +71,13 @@ public class NumberRecord
* @param size size of data * @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.getShort(data, 0 + offset);
field_1_row = LittleEndian.getUShort(data, 0 + offset); field_1_row = in.readUShort();
field_2_col = LittleEndian.getShort(data, 2 + offset); field_2_col = in.readShort();
field_3_xf = LittleEndian.getShort(data, 4 + offset); field_3_xf = in.readShort();
field_4_value = LittleEndian.getDouble(data, 6 + offset); field_4_value = in.readDouble();
} }
//public void setRow(short row) //public void setRow(short row)

View File

@ -23,6 +23,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.*; import org.apache.poi.util.*;
import java.io.ByteArrayInputStream;
import java.util.List; import java.util.List;
import java.util.Iterator; import java.util.Iterator;
import java.util.ArrayList; import java.util.ArrayList;
@ -56,23 +57,9 @@ public class ObjRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
/** /**
@ -88,9 +75,20 @@ public class ObjRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
subrecords = new ArrayList(); 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; int pos = offset;
while (pos - offset <= size-2) // atleast one "short" must be present 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); Record subRecord = SubRecord.createSubRecord(subRecordSid, subRecordSize, data, pos + 4);
subrecords.add(subRecord); subrecords.add(subRecord);
pos += subRecord.getRecordSize(); pos += subRecord.getRecordSize();
} }*/
} }
public String toString() public String toString()
@ -175,14 +173,6 @@ public class ObjRecord
return subrecords.add( o ); return subrecords.add( o );
} }
// made public to satisfy biffviewer
/* protected */
public void processContinueRecord( byte[] record )
{
super.processContinueRecord( record );
}
public Object clone() public Object clone()
{ {
ObjRecord rec = new ObjRecord(); ObjRecord rec = new ObjRecord();

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -58,25 +57,9 @@ public class ObjectLinkRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public ObjectLinkRecord(short id, short size, byte [] data) public ObjectLinkRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -93,13 +76,13 @@ public class ObjectLinkRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_anchorId = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_anchorId = in.readShort();
field_2_link1 = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_link1 = in.readShort();
field_3_link2 = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_link2 = in.readShort();
} }

View File

@ -34,8 +34,14 @@ import org.apache.poi.util.LittleEndian;
* <p>REFERENCE: Microsoft Excel SDK page 322 and 420</p> * <p>REFERENCE: Microsoft Excel SDK page 322 and 420</p>
* *
* @see HorizontalPageBreakRecord * @see HorizontalPageBreakRecord
<<<<<<< PageBreakRecord.java
* @see VerticalPageBreakREcord
*
* REFERENCE: Microsoft Excel SDK page 322 and 420
=======
* @see VerticalPageBreakRecord * @see VerticalPageBreakRecord
* *
>>>>>>> 1.5
* @author Danny Mui (dmui at apache dot org) * @author Danny Mui (dmui at apache dot org)
*/ */
public class PageBreakRecord extends Record { public class PageBreakRecord extends Record {
@ -82,27 +88,19 @@ public class PageBreakRecord extends Record {
this.sid = sid; this.sid = sid;
} }
public PageBreakRecord(short id, short size, byte data[]) public PageBreakRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
this.sid = id; this.sid = in.getSid();
} }
public PageBreakRecord(short id, short size, byte data[], int offset) protected void fillFields(RecordInputStream in)
{ {
super(id, size, data, offset); short loadedBreaks = in.readShort();
this.sid = id;
}
protected void fillFields(byte data[], short size, int offset)
{
short loadedBreaks = LittleEndian.getShort(data, 0 + offset);
setNumBreaks(loadedBreaks); setNumBreaks(loadedBreaks);
int pos = 2;
for(int k = 0; k < loadedBreaks; k++) 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)); addBreak((short)(in.readShort()-1), in.readShort(), in.readShort());
pos += 6;
} }
} }

View File

@ -44,14 +44,7 @@ public class PaletteRecord
public PaletteRecord() public PaletteRecord()
{ {
} createDefaultPalette();
/**
* Constructs a custom palette with the default set of colors
*/
public PaletteRecord(short id)
{
super(id, STANDARD_PALETTE_SIZE, getDefaultData());
} }
/** /**
@ -62,23 +55,9 @@ public class PaletteRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public PaletteRecord(short id, short size, byte [] data) public PaletteRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
protected void validateSid(short id) 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); field_2_colors = new ArrayList(field_1_numcolors);
for (int k = 0; k < field_1_numcolors; k++) { for (int k = 0; k < field_1_numcolors; k++) {
field_2_colors.add(new PColor( field_2_colors.add(new PColor(
data[2+ offset+(k * 4) +0], in.readByte(),
data[2+ offset+(k * 4) +1], in.readByte(),
data[2+ offset+(k * 4) +2] 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 * @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) 0, (byte) 0, (byte) 0, (byte) 0, //color 0...
(byte) 255, (byte) 255, (byte) 255, (byte) 0, (byte) 255, (byte) 255, (byte) 255, (byte) 0,
(byte) 255, (byte) 0, (byte) 0, (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) 153, (byte) 0,
(byte) 51, (byte) 51, (byte) 51, (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]
)
);
}
} }
} }

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -59,25 +58,9 @@ public class PaneRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public PaneRecord(short id, short size, byte [] data) public PaneRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -94,15 +77,15 @@ public class PaneRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_x = LittleEndian.getShort(data, pos + 0x0 + offset); field_1_x = in.readShort();
field_2_y = LittleEndian.getShort(data, pos + 0x2 + offset); field_2_y = in.readShort();
field_3_topRow = LittleEndian.getShort(data, pos + 0x4 + offset); field_3_topRow = in.readShort();
field_4_leftColumn = LittleEndian.getShort(data, pos + 0x6 + offset); field_4_leftColumn = in.readShort();
field_5_activePane = LittleEndian.getShort(data, pos + 0x8 + offset); field_5_activePane = in.readShort();
} }

View File

@ -46,23 +46,9 @@ public class PasswordRecord
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -47,23 +47,9 @@ public class PasswordRev4Record
* @param data data of the record (should not contain sid/len) * @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); super(in);
}
/**
* 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);
} }
protected void validateSid(short id) 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();
} }
/** /**

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -50,25 +49,9 @@ public class PlotAreaRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public PlotAreaRecord(short id, short size, byte [] data) public PlotAreaRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -85,7 +68,7 @@ public class PlotAreaRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -52,25 +51,9 @@ public class PlotGrowthRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public PlotGrowthRecord(short id, short size, byte [] data) public PlotGrowthRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* 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)
{
super(id, size, data, offset);
} }
@ -87,12 +70,12 @@ public class PlotGrowthRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
int pos = 0; int pos = 0;
field_1_horizontalScale = LittleEndian.getInt(data, pos + 0x0 + offset); field_1_horizontalScale = in.readInt();
field_2_verticalScale = LittleEndian.getInt(data, pos + 0x4 + offset); field_2_verticalScale = in.readInt();
} }

View File

@ -47,23 +47,9 @@ public class PrecisionRecord
* @param data data of the record (should not contain sid/len) * @param data data of the record (should not contain sid/len)
*/ */
public PrecisionRecord(short id, short size, byte [] data) public PrecisionRecord(RecordInputStream in)
{ {
super(id, size, data); super(in);
}
/**
* Constructs a Precision record and sets its fields appropriately.
*
* @param id id must be 0xe 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 PrecisionRecord(short id, short size, byte [] data, int offset)
{
super(id, size, data, offset);
} }
protected void validateSid(short id) protected void validateSid(short id)
@ -74,9 +60,9 @@ public class PrecisionRecord
} }
} }
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(RecordInputStream in)
{ {
field_1_precision = LittleEndian.getShort(data, 0 + offset); field_1_precision = in.readShort();
} }
/** /**

Some files were not shown because too many files have changed in this diff Show More