]> source.dussan.org Git - poi.git/commitdiff
#58130 Fix the icon formatting read/write CF test
authorNick Burch <nick@apache.org>
Sun, 19 Jul 2015 02:35:04 +0000 (02:35 +0000)
committerNick Burch <nick@apache.org>
Sun, 19 Jul 2015 02:35:04 +0000 (02:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691788 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/cf/Threshold.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java

index 462027807c179ab4186db33a70bdcde9a4cab9be..414bf0f4ca0d0583f0278e49280e278b4eeca94b 100644 (file)
@@ -73,6 +73,14 @@ public final class Threshold {
     }
     public void setType(byte type) {
         this.type = type;
+
+        // Ensure the value presense / absense is consistent for the new type
+        if (type == RangeType.MIN.id || type == RangeType.MAX.id ||
+               type == RangeType.FORMULA.id) {
+            this.value = null;
+        } else if (value == null) {
+            this.value = 0d;
+        }
     }
     public void setType(int type) {
         this.type = (byte)type;
@@ -86,6 +94,9 @@ public final class Threshold {
     }
     public void setParsedExpression(Ptg[] ptgs) {
         formula = Formula.create(ptgs);
+        if (ptgs.length > 0) {
+            this.value = null;
+        }
     }
 
     public Double getValue() {
index 1204355fae91016f4ed92aa039b14668b607fdba..602c334958b09368beffeeff0a8663e8184022ec 100644 (file)
@@ -555,11 +555,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
         assertEquals("Values", s.getRow(0).getCell(0).toString());\r
         assertEquals("10.0", s.getRow(2).getCell(0).toString());\r
 \r
-        // Check we found all the conditional formattings rules we should have\r
+        // Check we found all the conditional formatting rules we should have\r
         SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();\r
         int numCF = 3;\r
         int numCF12 = 15;\r
-        int numCFEX = 0; // TODO This should be 1, but we don't support CFEX formattings yet\r
+        int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet\r
         assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());\r
         \r
         int fCF = 0, fCF12 = 0, fCFEX = 0;\r
@@ -982,8 +982,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
         assertEquals(BorderFormatting.BORDER_HAIR, r1fp.getBorderRight());\r
     }\r
     \r
-    // TODO Fix this test to work for HSSF\r
-    public void DISABLEDtestCreateIconFormatting() {\r
+    public void testCreateIconFormatting() {\r
         Workbook workbook = _testDataProvider.createWorkbook();\r
         Sheet sheet = workbook.createSheet();\r
 \r