In setCellFormula(String) the Ptg stack in FormulaRecord is cleared before filling it with new values. Prior to this fix, repeated calls to setCellFormula would keep accumulating Ptgs in the stack although only the topmost "size" number of Ptgs would ever be used.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@430137 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c17abf116c
commit
ab27ce3720
@ -597,8 +597,9 @@ public class HSSFCell
|
|||||||
} else {
|
} else {
|
||||||
setCellType(CELL_TYPE_FORMULA,false,row,col,styleIndex);
|
setCellType(CELL_TYPE_FORMULA,false,row,col,styleIndex);
|
||||||
FormulaRecordAggregate rec = (FormulaRecordAggregate) record;
|
FormulaRecordAggregate rec = (FormulaRecordAggregate) record;
|
||||||
rec.getFormulaRecord().setOptions(( short ) 2);
|
FormulaRecord frec = rec.getFormulaRecord();
|
||||||
rec.getFormulaRecord().setValue(0);
|
frec.setOptions(( short ) 2);
|
||||||
|
frec.setValue(0);
|
||||||
|
|
||||||
//only set to default if there is no extended format index already set
|
//only set to default if there is no extended format index already set
|
||||||
if (rec.getXFIndex() == (short)0) rec.setXFIndex(( short ) 0x0f);
|
if (rec.getXFIndex() == (short)0) rec.setXFIndex(( short ) 0x0f);
|
||||||
@ -606,10 +607,16 @@ public class HSSFCell
|
|||||||
fp.parse();
|
fp.parse();
|
||||||
Ptg[] ptg = fp.getRPNPtg();
|
Ptg[] ptg = fp.getRPNPtg();
|
||||||
int size = 0;
|
int size = 0;
|
||||||
//System.out.println("got Ptgs " + ptg.length);
|
|
||||||
|
// clear the Ptg Stack
|
||||||
|
for (int i=0, iSize=frec.getNumberOfExpressionTokens(); i<iSize; i++) {
|
||||||
|
frec.popExpressionToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill the Ptg Stack with Ptgs of new formula
|
||||||
for (int k = 0; k < ptg.length; k++) {
|
for (int k = 0; k < ptg.length; k++) {
|
||||||
size += ptg[ k ].getSize();
|
size += ptg[ k ].getSize();
|
||||||
rec.getFormulaRecord().pushExpressionToken(ptg[ k ]);
|
frec.pushExpressionToken(ptg[ k ]);
|
||||||
}
|
}
|
||||||
rec.getFormulaRecord().setExpressionLength(( short ) size);
|
rec.getFormulaRecord().setExpressionLength(( short ) size);
|
||||||
//Workbook.currentBook = null;
|
//Workbook.currentBook = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user