Formula changes. . Disable for 1.5...alow compile in if desired.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352431 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-04-17 22:21:16 +00:00
parent 310413425e
commit 29911b8674
3 changed files with 96 additions and 30 deletions

View File

@ -630,6 +630,11 @@ public class BiffViewer
case LinkedDataRecord.sid:
retval = new LinkedDataRecord(rectype, size, data);
break;
case FormulaRecord.sid:
retval = new FormulaRecord(rectype, size, data);
break;
default :
retval = new UnknownRecord(rectype, size, data);

View File

@ -77,8 +77,12 @@ public class FormulaRecord
extends Record
implements CellValueRecordInterface, Comparable
{
public static final boolean EXPERIMENTAL_FORMULA_SUPPORT_ENABLED=false;
public static final short sid =
0x06; // docs say 406...because of a bug Microsoft support site article #Q184647)
private short field_1_row;
private short field_2_column;
private short field_3_xf;
@ -87,6 +91,9 @@ public class FormulaRecord
private int field_6_zero;
private short field_7_expression_len;
private Stack field_8_parsed_expr;
private byte[] all_data; //if formula support is not enabled then
//we'll just store/reserialize
/** Creates new FormulaRecord */
@ -126,6 +133,7 @@ public class FormulaRecord
protected void fillFields(byte [] data, short size, int offset)
{
if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
field_1_row = LittleEndian.getShort(data, 0 + offset);
field_2_column = LittleEndian.getShort(data, 2 + offset);
field_3_xf = LittleEndian.getShort(data, 4 + offset);
@ -133,9 +141,16 @@ public class FormulaRecord
field_5_options = LittleEndian.getShort(data, 14 + offset);
field_6_zero = LittleEndian.getInt(data, 16 + offset);
field_7_expression_len = LittleEndian.getShort(data, 20 + offset);
field_8_parsed_expr = getParsedExpressionTokens(data, size,
offset);
} else {
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);
}
// field_8_parsed_expr = getParsedExpressionTokens(data, size,
// offset);
}
private Stack getParsedExpressionTokens(byte [] data, short size,
@ -332,6 +347,7 @@ public class FormulaRecord
public int serialize(int offset, byte [] data)
{
if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
int ptgSize = getTotalPtgSize();
LittleEndian.putShort(data, 0 + offset, sid);
@ -343,6 +359,9 @@ public class FormulaRecord
LittleEndian.putShort(data, 18 + offset, getOptions());
LittleEndian.putInt(data, 20 + offset, field_6_zero);
LittleEndian.putShort(data, 24 + offset, getExpressionLength());
} else {
System.arraycopy(all_data,0,data,offset,all_data.length);
}
// serializePtgs(data, 26+offset);
return getRecordSize();
@ -350,7 +369,14 @@ public class FormulaRecord
public int getRecordSize()
{
return 0;
int retval =0;
if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
retval = getTotalPtgSize() + 28;
} else {
retval =all_data.length;
}
return retval;
// return getTotalPtgSize() + 28;
}

View File

@ -77,33 +77,68 @@ import org.apache.poi.util.LittleEndian;
public class RecordFactory
{
private static int NUM_RECORDS = 10000;
private static final Class[] records = new Class[]
{
BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
InterfaceEndRecord.class, WriteAccessRecord.class,
CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
FnGroupCountRecord.class, WindowProtectRecord.class,
ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
HideObjRecord.class, DateWindow1904Record.class,
PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
PrintSetupRecord.class, DefaultColWidthRecord.class,
DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
RKRecord.class, NumberRecord.class, DBCellRecord.class,
WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
FormulaRecord.class, BoolErrRecord.class
};
private static final Class[] records;
static {
if (FormulaRecord.EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
records = new Class[]
{
BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
InterfaceEndRecord.class, WriteAccessRecord.class,
CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
FnGroupCountRecord.class, WindowProtectRecord.class,
ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
HideObjRecord.class, DateWindow1904Record.class,
PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
PrintSetupRecord.class, DefaultColWidthRecord.class,
DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
RKRecord.class, NumberRecord.class, DBCellRecord.class,
WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
FormulaRecord.class, BoolErrRecord.class
};
} else {
records = new Class[]
{
BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
InterfaceEndRecord.class, WriteAccessRecord.class,
CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
FnGroupCountRecord.class, WindowProtectRecord.class,
ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
HideObjRecord.class, DateWindow1904Record.class,
PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
PrintSetupRecord.class, DefaultColWidthRecord.class,
DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
RKRecord.class, NumberRecord.class, DBCellRecord.class,
WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
BoolErrRecord.class
};
}
}
private static Map recordsMap = recordsToMap(records);
/**