aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-01-21 23:11:45 +0000
committerJosh Micich <josh@apache.org>2009-01-21 23:11:45 +0000
commitb5a5ac13dbc7ae5e52ecf2cc651c80e4ee420699 (patch)
tree8d173f88969a1e32898c7a95b63a2ca81beb966e /src/java/org/apache
parentbd48c3cf1e0af94b46bd70cc49ff691bf212bd3b (diff)
downloadpoi-b5a5ac13dbc7ae5e52ecf2cc651c80e4ee420699.tar.gz
poi-b5a5ac13dbc7ae5e52ecf2cc651c80e4ee420699.zip
Fixed HSSFCell/FormulaRecordAggregate to properly remove StringRecord when cached result type changes.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@736476 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java6
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCell.java8
2 files changed, 8 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
index 83a4ce7e0e..73869e193b 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
@@ -147,7 +147,7 @@ public final class FormulaRecordAggregate extends RecordAggregate implements Cel
rv.visitRecord(sharedFormulaRecord);
}
}
- if (_stringRecord != null) {
+ if (_formulaRecord.hasCachedResultString() && _stringRecord != null) {
rv.visitRecord(_stringRecord);
}
}
@@ -180,6 +180,10 @@ public final class FormulaRecordAggregate extends RecordAggregate implements Cel
_stringRecord = null;
_formulaRecord.setCachedResultErrorCode(errorCode);
}
+ public void setCachedDoubleResult(double value) {
+ _stringRecord = null;
+ _formulaRecord.setValue(value);
+ }
public Ptg[] getFormulaTokens() {
if (_sharedFormulaRecord == null) {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
index 03c514b47b..4e84926e1d 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
@@ -72,7 +72,6 @@ import org.apache.poi.ss.formula.FormulaType;
* @author Dan Sherman (dsherman at isisph.com)
* @author Brian Sanders (kestrel at burdell dot org) Active Cell support
* @author Yegor Kozlov cell comments support
- * @version 1.0-pre
*/
public class HSSFCell implements Cell {
/** Numeric Cell type (0) @see #setCellType(int) @see #getCellType() */
@@ -481,7 +480,7 @@ public class HSSFCell implements Cell {
(( NumberRecord ) record).setValue(value);
break;
case CELL_TYPE_FORMULA:
- ((FormulaRecordAggregate)record).getFormulaRecord().setValue(value);
+ ((FormulaRecordAggregate)record).setCachedDoubleResult(value);
break;
}
}
@@ -743,7 +742,6 @@ public class HSSFCell implements Cell {
* precalculated value, for booleans we'll set its value. For other types we
* will change the cell to a boolean cell and set its value.
*/
-
public void setCellValue(boolean value) {
int row=record.getRow();
short col=record.getColumn();
@@ -756,7 +754,7 @@ public class HSSFCell implements Cell {
(( BoolErrRecord ) record).setValue(value);
break;
case CELL_TYPE_FORMULA:
- ((FormulaRecordAggregate)record).getFormulaRecord().setCachedResultBoolean(value);
+ ((FormulaRecordAggregate)record).setCachedBooleanResult(value);
break;
}
}
@@ -780,7 +778,7 @@ public class HSSFCell implements Cell {
(( BoolErrRecord ) record).setValue(errorCode);
break;
case CELL_TYPE_FORMULA:
- ((FormulaRecordAggregate)record).getFormulaRecord().setCachedResultErrorCode(errorCode);
+ ((FormulaRecordAggregate)record).setCachedErrorResult(errorCode);
break;
}
}