mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Avoid two NPEs which were currently "expected" in tests
When things go wrong, we always want to give an explanation via an exception instead of an NPE.
This commit is contained in:
parent
fb75600872
commit
ddf71d0984
@ -39,7 +39,7 @@ import org.apache.poi.util.RecordFormatException;
|
||||
public final class FormulaRecordAggregate extends RecordAggregate implements CellValueRecordInterface {
|
||||
|
||||
private final FormulaRecord _formulaRecord;
|
||||
private SharedValueManager _sharedValueManager;
|
||||
private final SharedValueManager _sharedValueManager;
|
||||
/** caches the calculated result of the formula */
|
||||
private StringRecord _stringRecord;
|
||||
private SharedFormulaRecord _sharedFormulaRecord;
|
||||
@ -195,6 +195,9 @@ public final class FormulaRecordAggregate extends RecordAggregate implements Cel
|
||||
CellReference expRef = _formulaRecord.getFormula().getExpReference();
|
||||
if (expRef != null) {
|
||||
ArrayRecord arec = _sharedValueManager.getArrayRecord(expRef.getRow(), expRef.getCol());
|
||||
if (arec == null) {
|
||||
throw new IllegalStateException("Could not get ArrayRecord for cell-reference " + expRef.formatAsString());
|
||||
}
|
||||
return arec.getFormulaTokens();
|
||||
}
|
||||
return _formulaRecord.getParsedExpression();
|
||||
|
||||
@ -285,7 +285,11 @@ public class HSSFComment extends HSSFTextbox implements Comment {
|
||||
byte [] inSp = getEscherContainer().serialize();
|
||||
spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
|
||||
ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
|
||||
NoteRecord note = (NoteRecord) getNoteRecord().cloneViaReserialise();
|
||||
NoteRecord noteRecord = getNoteRecord();
|
||||
if (noteRecord == null) {
|
||||
throw new IllegalStateException("Could not clone the note record for this comment because it is null");
|
||||
}
|
||||
NoteRecord note = (NoteRecord) noteRecord.cloneViaReserialise();
|
||||
return new HSSFComment(spContainer, obj, txo, note);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user