Author: yegor
Date: Wed Oct 10 15:41:35 2012
New Revision: 1396650
URL: http://svn.apache.org/viewvc?rev=1396650&view=rev
Log:
Bug 53965: Fixed XmlValueOutOfRangeExceptio calling getDataValidations for
custom validations with XSSFSheet
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL:
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1396650&r1=1396649&r2=1396650&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Oct 10 15:41:35
2012
@@ -34,6 +34,7 @@
<changes>
<release version="3.9-beta1" date="2012-??-??">
+ <action dev="poi-developers" type="fix">53965 - Fixed
XmlValueOutOfRangeExceptio calling getDataValidations for custom validations
with XSSFSheet </action>
<action dev="poi-developers" type="fix">53974 - Avoid NPE when
constructing HSSFWorbook on Google App Engine</action>
<action dev="poi-developers" type="fix">53568 - Fixed null returned
by XSSFPicture.getPictureData()</action>
<action dev="poi-developers" type="fix">53950 - fixed
setForceFormulaRecalculation to reset workbook-level "manual" flag</action>
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java?rev=1396650&r1=1396649&r2=1396650&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java
Wed Oct 10 15:41:35 2012
@@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.DataV
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidation;
+import
org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationOperator;
import
org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationType;
/**
@@ -146,7 +147,10 @@ public class XSSFDataValidationHelper im
}
if (validationType!=ValidationType.ANY &&
validationType!=ValidationType.LIST) {
-
newDataValidation.setOperator(XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator()));
+ STDataValidationOperator.Enum op =
XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator());
+ if(op != null) {
+ newDataValidation.setOperator(op);
+ }
if (constraint.getFormula1() != null) {
newDataValidation.setFormula1(constraint.getFormula1());
}
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java?rev=1396650&r1=1396649&r2=1396650&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
Wed Oct 10 15:41:35 2012
@@ -16,6 +16,7 @@
==================================================================== */
package org.apache.poi.xssf.usermodel;
+import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.List;
@@ -239,4 +240,25 @@ public class TestXSSFDataValidation exte
validation.createPromptBox("Prompt", "Enter some value");
validation.setSuppressDropDownArrow(yesNo);
}
+
+ public void test53965() throws Exception {
+
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ List<XSSFDataValidation> lst = sheet.getDataValidations(); //<--
works
+ assertEquals(0, lst.size());
+
+ //create the cell that will have the validation applied
+ sheet.createRow(0).createCell(0);
+
+ DataValidationHelper dataValidationHelper =
sheet.getDataValidationHelper();
+ DataValidationConstraint constraint =
dataValidationHelper.createCustomConstraint("SUM($A$1:$A$1) <= 3500");
+ CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0,
0);
+ DataValidation validation =
dataValidationHelper.createValidation(constraint, addressList);
+ sheet.addValidationData(validation);
+
+ // this line caused XmlValueOutOfRangeException , see Bugzilla 3965
+ lst = sheet.getDataValidations();
+ assertEquals(1, lst.size());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]