You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/13 10:53:03 UTC

svn commit: r1748174 - in /poi/trunk/src/java/org/apache/poi/hssf: record/BoolErrRecord.java record/aggregates/FormulaRecordAggregate.java usermodel/HSSFCell.java

Author: onealj
Date: Mon Jun 13 10:53:03 2016
New Revision: 1748174

URL: http://svn.apache.org/viewvc?rev=1748174&view=rev
Log:
add HSSFCell.setCachedErrorResult(FormulaError)

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/BoolErrRecord.java?rev=1748174&r1=1748173&r2=1748174&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/BoolErrRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/BoolErrRecord.java Mon Jun 13 10:53:03 2016
@@ -81,14 +81,25 @@ public final class BoolErrRecord extends
 	}
 
 	/**
-	 * set the error value for the cell
+	 * set the error value for the cell. See {@link FormulaError} for valid codes.
 	 *
 	 * @param value     error representing the error value
 	 *                  this value can only be 0,7,15,23,29,36 or 42
 	 *                  see bugzilla bug 16560 for an explanation
 	 */
 	public void setValue(byte value) {
-		switch(FormulaError.forInt(value)) {
+		setValue(FormulaError.forInt(value));
+	}
+
+	/**
+	 * set the error value for the cell
+	 *
+	 * @param value     error representing the error value
+	 *                  this value can only be 0,7,15,23,29,36 or 42
+	 *                  see bugzilla bug 16560 for an explanation
+	 */
+	public void setValue(FormulaError value) {
+		switch(value) {
 			case NULL:
 			case DIV0:
 			case VALUE:
@@ -96,11 +107,11 @@ public final class BoolErrRecord extends
 			case NAME:
 			case NUM:
 			case NA:
-				_value = value;
+				_value = value.getCode();
 				_isError = true;
 				return;
 			default:
-		        throw new IllegalArgumentException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value);
+		        throw new IllegalArgumentException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value.getCode()+" ("+value+")");
 		}
 	}
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java?rev=1748174&r1=1748173&r2=1748174&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java Mon Jun 13 10:53:03 2016
@@ -24,12 +24,13 @@ import org.apache.poi.hssf.record.Record
 import org.apache.poi.hssf.record.RecordFormatException;
 import org.apache.poi.hssf.record.SharedFormulaRecord;
 import org.apache.poi.hssf.record.StringRecord;
+import org.apache.poi.hssf.util.CellRangeAddress8Bit;
 import org.apache.poi.ss.formula.ptg.ExpPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.hssf.util.CellRangeAddress8Bit;
-import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.ss.formula.Formula;
+import org.apache.poi.ss.usermodel.FormulaError;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.CellReference;
 
 /**
  * The formula record aggregate is used to join together the formula record and it's
@@ -180,6 +181,9 @@ public final class FormulaRecordAggregat
 		_stringRecord = null;
 		_formulaRecord.setCachedResultErrorCode(errorCode);
 	}
+	public void setCachedErrorResult(FormulaError error) {
+		setCachedErrorResult(error.getCode());
+	}
 	public void setCachedDoubleResult(double value) {
 		_stringRecord = null;
 		_formulaRecord.setValue(value);

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1748174&r1=1748173&r2=1748174&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Mon Jun 13 10:53:03 2016
@@ -791,16 +791,15 @@ public class HSSFCell implements Cell {
         int row=_record.getRow();
         short col=_record.getColumn();
         short styleIndex=_record.getXFIndex();
-        byte code = error.getCode();
         switch (_cellType) {
             default:
                 setCellType(CELL_TYPE_ERROR, false, row, col, styleIndex);
                 // fall through
             case CELL_TYPE_ERROR:
-                (( BoolErrRecord ) _record).setValue(code);
+                (( BoolErrRecord ) _record).setValue(error);
                 break;
             case CELL_TYPE_FORMULA:
-                ((FormulaRecordAggregate)_record).setCachedErrorResult(code);
+                ((FormulaRecordAggregate)_record).setCachedErrorResult(error.getCode());
                 break;
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org