Methods Summary |
---|
public java.lang.Object | clone()
//Because this record is converted to individual Formula records, this method is not required.
throw new UnsupportedOperationException("Cannot clone a SharedFormulaRecord");
|
public void | convertSharedFormulaRecord(org.apache.poi.hssf.record.FormulaRecord formula)Creates a non shared formula from the shared formula counter part
//Sanity checks
final int formulaRow = formula.getRow();
final int formulaColumn = formula.getColumn();
if (isFormulaInShared(formula)) {
formula.setExpressionLength(getExpressionLength());
Stack newPtgStack = new Stack();
if (field_7_parsed_expr != null)
for (int k = 0; k < field_7_parsed_expr.size(); k++) {
Ptg ptg = (Ptg) field_7_parsed_expr.get(k);
if (ptg instanceof RefNPtg) {
RefNPtg refNPtg = (RefNPtg)ptg;
ptg = new ReferencePtg( (short)(formulaRow + refNPtg.getRow()),
(byte)(formulaColumn + refNPtg.getColumn()),
refNPtg.isRowRelative(),
refNPtg.isColRelative());
} else if (ptg instanceof RefNVPtg) {
RefNVPtg refNVPtg = (RefNVPtg)ptg;
ptg = new RefVPtg( (short)(formulaRow + refNVPtg.getRow()),
(byte)(formulaColumn + refNVPtg.getColumn()),
refNVPtg.isRowRelative(),
refNVPtg.isColRelative());
} else if (ptg instanceof RefNAPtg) {
RefNAPtg refNAPtg = (RefNAPtg)ptg;
ptg = new RefAPtg( (short)(formulaRow + refNAPtg.getRow()),
(byte)(formulaColumn + refNAPtg.getColumn()),
refNAPtg.isRowRelative(),
refNAPtg.isColRelative());
} else if (ptg instanceof AreaNPtg) {
AreaNPtg areaNPtg = (AreaNPtg)ptg;
ptg = new AreaPtg((short)(formulaRow + areaNPtg.getFirstRow()),
(short)(formulaRow + areaNPtg.getLastRow()),
(short)(formulaColumn + areaNPtg.getFirstColumn()),
(short)(formulaColumn + areaNPtg.getLastColumn()),
areaNPtg.isFirstRowRelative(),
areaNPtg.isLastRowRelative(),
areaNPtg.isFirstColRelative(),
areaNPtg.isLastColRelative());
} else if (ptg instanceof AreaNVPtg) {
AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
ptg = new AreaVPtg((short)(formulaRow + areaNVPtg.getFirstRow()),
(short)(formulaRow + areaNVPtg.getLastRow()),
(short)(formulaColumn + areaNVPtg.getFirstColumn()),
(short)(formulaColumn + areaNVPtg.getLastColumn()),
areaNVPtg.isFirstRowRelative(),
areaNVPtg.isLastRowRelative(),
areaNVPtg.isFirstColRelative(),
areaNVPtg.isLastColRelative());
} else if (ptg instanceof AreaNAPtg) {
AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
ptg = new AreaAPtg((short)(formulaRow + areaNAPtg.getFirstRow()),
(short)(formulaRow + areaNAPtg.getLastRow()),
(short)(formulaColumn + areaNAPtg.getFirstColumn()),
(short)(formulaColumn + areaNAPtg.getLastColumn()),
areaNAPtg.isFirstRowRelative(),
areaNAPtg.isLastRowRelative(),
areaNAPtg.isFirstColRelative(),
areaNAPtg.isLastColRelative());
}
newPtgStack.add(ptg);
}
formula.setParsedExpression(newPtgStack);
//Now its not shared!
formula.setSharedFormula(false);
} else {
throw new RuntimeException("Shared Formula Conversion: Coding Error");
}
|
protected void | fillFields(org.apache.poi.hssf.record.RecordInputStream in)Shared formulas are to treated like unknown records, and as a result d
field_1_first_row = in.readShort();
field_2_last_row = in.readShort();
field_3_first_column = in.readByte();
field_4_last_column = in.readByte();
field_5_reserved = in.readShort();
field_6_expression_len = in.readShort();
field_7_parsed_expr = getParsedExpressionTokens(in);
|
public short | getExpressionLength()
return field_6_expression_len;
|
public short | getFirstColumn()
return field_3_first_column;
|
public int | getFirstRow()
return field_1_first_row;
|
public short | getLastColumn()
return field_4_last_column;
|
public int | getLastRow()
return field_2_last_row;
|
private java.util.Stack | getParsedExpressionTokens(org.apache.poi.hssf.record.RecordInputStream in)
Stack stack = new Stack();
while (in.remaining() != 0) {
Ptg ptg = Ptg.createPtg(in);
stack.push(ptg);
}
return stack;
|
public int | getRecordSize()
//Because this record is converted to individual Formula records, this method is not required.
throw new UnsupportedOperationException("Cannot get the size for a SharedFormulaRecord");
|
public short | getSid()
return sid;
|
public boolean | isFormulaInShared(org.apache.poi.hssf.record.FormulaRecord formula)
final int formulaRow = formula.getRow();
final int formulaColumn = formula.getColumn();
return ((getFirstRow() <= formulaRow) && (getLastRow() >= formulaRow) &&
(getFirstColumn() <= formulaColumn) && (getLastColumn() >= formulaColumn));
|
public boolean | isInValueSection()Mirroring formula records so it is registered in the ValueRecordsAggregate
return true;
|
public boolean | isValue()Register it in the ValueRecordsAggregate so it can go into the FormulaRecordAggregate
return true;
|
public int | serialize(int offset, byte[] data)spit the record out AS IS. no interperatation or identification
//Because this record is converted to individual Formula records, this method is not required.
throw new UnsupportedOperationException("Cannot serialize a SharedFormulaRecord");
|
public java.lang.String | toString()print a sort of string representation ([SHARED FORMULA RECORD] id = x [/SHARED FORMULA RECORD])
StringBuffer buffer = new StringBuffer();
buffer.append("[SHARED FORMULA RECORD:" + Integer.toHexString(sid) + "]\n");
buffer.append(" .id = ").append(Integer.toHexString(sid))
.append("\n");
buffer.append(" .first_row = ")
.append(Integer.toHexString(getFirstRow())).append("\n");
buffer.append(" .last_row = ")
.append(Integer.toHexString(getLastRow()))
.append("\n");
buffer.append(" .first_column = ")
.append(Integer.toHexString(getFirstColumn())).append("\n");
buffer.append(" .last_column = ")
.append(Integer.toHexString(getLastColumn()))
.append("\n");
buffer.append(" .reserved = ")
.append(Integer.toHexString(field_5_reserved))
.append("\n");
buffer.append(" .expressionlength= ").append(getExpressionLength())
.append("\n");
buffer.append(" .numptgsinarray = ").append(field_7_parsed_expr.size())
.append("\n");
for (int k = 0; k < field_7_parsed_expr.size(); k++ ) {
buffer.append("Formula ")
.append(k)
.append("\n")
.append(field_7_parsed_expr.get(k).toString())
.append("\n");
}
buffer.append("[/SHARED FORMULA RECORD]\n");
return buffer.toString();
|
protected void | validateSid(short id)
if (id != this.sid)
{
throw new RecordFormatException("Not a valid SharedFormula");
}
|