poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1690796 - in /poi/trunk/src: java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
Date Mon, 13 Jul 2015 18:55:42 GMT
Author: nick
Date: Mon Jul 13 18:55:42 2015
New Revision: 1690796

URL: http://svn.apache.org/r1690796
Log:
Have the HSSF ConditionalFormattingTable look for CF12 records as well, and begin more detailed
testing of the high level rules #58130

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java?rev=1690796&r1=1690795&r2=1690796&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
(original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
Mon Jul 13 18:55:42 2015
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.poi.hssf.model.RecordStream;
+import org.apache.poi.hssf.record.CFHeader12Record;
 import org.apache.poi.hssf.record.CFHeaderRecord;
 import org.apache.poi.ss.formula.FormulaShifter;
 
@@ -28,11 +29,8 @@ import org.apache.poi.ss.formula.Formula
  * Holds all the conditional formatting for a workbook sheet.<p/>
  * 
  * See OOO exelfileformat.pdf sec 4.12 'Conditional Formatting Table'
- * 
- * @author Josh Micich
  */
 public final class ConditionalFormattingTable extends RecordAggregate {
-
 	private final List<CFRecordsAggregate> _cfHeaders;
 
 	/**
@@ -45,7 +43,8 @@ public final class ConditionalFormatting
 	public ConditionalFormattingTable(RecordStream rs) {
 
 		List<CFRecordsAggregate> temp = new ArrayList<CFRecordsAggregate>();
-		while (rs.peekNextClass() == CFHeaderRecord.class) {
+		while (rs.peekNextClass() == CFHeaderRecord.class ||
+		       rs.peekNextClass() == CFHeader12Record.class) {
 			temp.add(CFRecordsAggregate.createCFAggregate(rs));
 		}
 		_cfHeaders = temp;

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java?rev=1690796&r1=1690795&r2=1690796&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
Mon Jul 13 18:55:42 2015
@@ -20,6 +20,8 @@
 package org.apache.poi.ss.usermodel;
 
 import junit.framework.TestCase;
+
+import org.apache.poi.hssf.usermodel.HSSFConditionalFormatting;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.util.CellRangeAddress;
 
@@ -528,6 +530,7 @@ public abstract class BaseTestConditiona
         Workbook wb = _testDataProvider.openSampleWorkbook(filename);
         Sheet s = wb.getSheet("CF");
         ConditionalFormatting cf = null;
+        ConditionalFormattingRule cr = null;
         
         // Sanity check data
         assertEquals("Values", s.getRow(0).getCell(0).toString());
@@ -535,16 +538,38 @@ public abstract class BaseTestConditiona
 
         // Check we found all the conditional formattings rules we should have
         SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();
-        assertEquals(1, sheetCF.getNumConditionalFormattings()); // TODO Should be more!
+        int numCF = 3;
+        int numCF12 = 15;
+        int numCFEX = 0; // TODO This should be 1, but we don't support CFEX formattings
yet
+        assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());
         
-        cf = sheetCF.getConditionalFormattingAt(0);
-        //System.out.println(cf);
+        int fCF = 0, fCF12 = 0, fCFEX = 0;
+        for (int i=0; i<sheetCF.getNumConditionalFormattings(); i++) {
+            cf = sheetCF.getConditionalFormattingAt(i);
+            if (cf instanceof HSSFConditionalFormatting) {
+                String str = cf.toString();
+                if (str.contains("[CF]")) fCF++;
+                if (str.contains("[CF12]")) fCF12++;
+                if (str.contains("[CFEX]")) fCFEX++;
+            } else {
+                fail("TODO!"); 
+            }
+        }
+        assertEquals(numCF, fCF);
+        assertEquals(numCF12, fCF12);
+        assertEquals(numCFEX, fCFEX);
         
         
         // Check the rules / values in detail
         
         // Highlight Positive values - Column C
-        // TODO
+        cf = sheetCF.getConditionalFormattingAt(0);
+        assertEquals(1, cf.getFormattingRanges().length);
+        assertEquals("C2:C17", cf.getFormattingRanges()[0].formatAsString());
+        
+        assertEquals(1, cf.getNumberOfRules());
+        cr = cf.getRule(0);
+        // TODO Check the rest of this
         
         // Highlight 10-30 - Column D
         // TODO



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


Mime
View raw message