poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r682230 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/DVConstraint.java testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
Date Sun, 03 Aug 2008 23:13:17 GMT
Author: josh
Date: Sun Aug  3 16:13:17 2008
New Revision: 682230

URL: http://svn.apache.org/viewvc?rev=682230&view=rev
Log:
Small tweaks for data validation (bug 44953)

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java?rev=682230&r1=682229&r2=682230&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java Sun Aug  3 16:13:17
2008
@@ -37,22 +37,22 @@
 		private ValidationType() {
 			// no instances of this class
 		}
-    	/** 'Any value' type - value not restricted */
-    	public static final int ANY         = 0x00;
-    	/** Integer ('Whole number') type */
-    	public static final int INTEGER     = 0x01;
-    	/** Decimal type */
-    	public static final int DECIMAL     = 0x02;
-    	/** List type ( combo box type ) */
-    	public static final int LIST        = 0x03;
-    	/** Date type */
-    	public static final int DATE        = 0x04;
-    	/** Time type */
-    	public static final int TIME        = 0x05;
-    	/** String length type */
-    	public static final int TEXT_LENGTH = 0x06;
-    	/** Formula ( 'Custom' ) type */
-    	public static final int FORMULA     = 0x07;
+		/** 'Any value' type - value not restricted */
+		public static final int ANY         = 0x00;
+		/** Integer ('Whole number') type */
+		public static final int INTEGER     = 0x01;
+		/** Decimal type */
+		public static final int DECIMAL     = 0x02;
+		/** List type ( combo box type ) */
+		public static final int LIST        = 0x03;
+		/** Date type */
+		public static final int DATE        = 0x04;
+		/** Time type */
+		public static final int TIME        = 0x05;
+		/** String length type */
+		public static final int TEXT_LENGTH = 0x06;
+		/** Formula ( 'Custom' ) type */
+		public static final int FORMULA     = 0x07;
 	}
 	/**
 	 * Condition operator enum
@@ -312,7 +312,7 @@
 		return new Double(HSSFDateUtil.getExcelDate(dateVal));
 	}
 
-	public static DVConstraint createFormulaConstraint(String formula) {
+	public static DVConstraint createCustomFormulaConstraint(String formula) {
 		if (formula == null) {
 			throw new IllegalArgumentException("formula must be supplied");
 		}
@@ -329,8 +329,8 @@
 			formula1 = createListFormula(workbook);
 			formula2 = Ptg.EMPTY_PTG_ARRAY;
 		} else {
-    		formula1 = convertDoubleFormula(_formula1, _value1, workbook);
-    		formula2 = convertDoubleFormula(_formula2, _value2, workbook);
+			formula1 = convertDoubleFormula(_formula1, _value1, workbook);
+			formula2 = convertDoubleFormula(_formula2, _value2, workbook);
 		}
 		return new FormulaPair(formula1, formula2);
 	}

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java?rev=682230&r1=682229&r2=682230&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java Sun Aug
 3 16:13:17 2008
@@ -45,11 +45,11 @@
 public final class TestDataValidation extends TestCase {
 
 	/** Convenient access to ERROR_STYLE constants */
-	private static final HSSFDataValidation.ErrorStyle ES = null;
+	/*package*/ static final HSSFDataValidation.ErrorStyle ES = null;
 	/** Convenient access to OPERATOR constants */
-	private static final DVConstraint.ValidationType VT = null;
+	/*package*/ static final DVConstraint.ValidationType VT = null;
 	/** Convenient access to OPERATOR constants */
-	private static final DVConstraint.OperatorType OP = null;
+	/*package*/ static final DVConstraint.OperatorType OP = null;
 
 	private static void log(String msg) {
 		if (false) { // successful tests should be silent
@@ -130,7 +130,7 @@
 				return DVConstraint.createDateConstraint(operatorType, firstFormula, secondFormula, null);
 			}
 			if (_validationType == VT.FORMULA) {
-				return DVConstraint.createFormulaConstraint(firstFormula);
+				return DVConstraint.createCustomFormulaConstraint(firstFormula);
 			}
 			return DVConstraint.createNumericConstraint(_validationType, operatorType, firstFormula,
secondFormula);
 		}
@@ -573,23 +573,8 @@
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("dvEmpty.xls");  
 		int dvRow = 0;
 		HSSFSheet sheet = wb.getSheetAt(0);
-		sheet.createRow(dvRow).createCell((short)0);
-		DVConstraint dc = DVConstraint.createNumericConstraint(VT.INTEGER, OP.EQUAL, "402", null);
-		HSSFDataValidation dv = new HSSFDataValidation(new CellRangeAddressList(dvRow, 0, dvRow,
0), dc);
-
-		
-		dv.setEmptyCellAllowed(false);
-		dv.setErrorStyle(ES.STOP);
-		dv.setShowPromptBox(true);
-		dv.createErrorBox("Error", "The value is wrong");
-		dv.setSuppressDropDownArrow(true);
-
-	//	sheet.addValidationData(dv);
-
-		
-		dc = DVConstraint.createNumericConstraint(VT.INTEGER, OP.EQUAL, "42", null);
-		dv = new HSSFDataValidation(new CellRangeAddressList(0, 0, 0, 0), dc);
-
+		DVConstraint dc = DVConstraint.createNumericConstraint(VT.INTEGER, OP.EQUAL, "42", null);
+		HSSFDataValidation dv = new HSSFDataValidation(new CellRangeAddressList(dvRow, dvRow, 0,
0), dc);
 		
 		dv.setEmptyCellAllowed(false);
 		dv.setErrorStyle(ES.STOP);
@@ -599,8 +584,6 @@
 
 		sheet.addValidationData(dv);
 		
-		
-		
 		ByteArrayOutputStream baos = new ByteArrayOutputStream();
 		try {
 			wb.write(baos);
@@ -637,22 +620,9 @@
 		// and the DV records, Excel will not be able to open the workbook without error.
 		
 		if (nextSid == 0x0867) {
-			throw new AssertionFailedError("Identified bug XXXX");
+			throw new AssertionFailedError("Identified bug 45519");
 		}
 		assertEquals(DVRecord.sid, nextSid);
-		
-		
-		
-		File tempDir = new File("c:/josh/temp");
-		File generatedFile = new File(tempDir, "dvEx2.xls");
-		try {
-			FileOutputStream fileOut = new FileOutputStream(generatedFile);
-			wb.write(fileOut);
-			fileOut.close();
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		
 	}
 	private int findIndex(byte[] largeData, byte[] searchPattern) {
 		byte firstByte = searchPattern[0];



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


Mime
View raw message