From fbf95cdb545d67d677164e111dc1f88d07f064dd Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 13 Jul 2015 19:56:09 +0000 Subject: [PATCH] Enable CF2007 test for XLSX too git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690805 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/ss/usermodel/ConditionType.java | 4 ++++ .../poi/xssf/usermodel/XSSFConditionalFormatting.java | 4 ++++ .../xssf/usermodel/TestXSSFConditionalFormatting.java | 3 +-- .../poi/ss/usermodel/BaseTestConditionalFormatting.java | 9 ++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/ss/usermodel/ConditionType.java b/src/java/org/apache/poi/ss/usermodel/ConditionType.java index 4f8de4f67..8bd61410e 100644 --- a/src/java/org/apache/poi/ss/usermodel/ConditionType.java +++ b/src/java/org/apache/poi/ss/usermodel/ConditionType.java @@ -73,6 +73,10 @@ public class ConditionType { public final byte id; public final String type; + public String toString() { + return id + " - " + type; + } + public static ConditionType forId(byte id) { return forId((int)id); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormatting.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormatting.java index 127c03783..53eb41b12 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormatting.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormatting.java @@ -98,4 +98,8 @@ public class XSSFConditionalFormatting implements ConditionalFormatting { public int getNumberOfRules(){ return _cf.sizeOfCfRuleArray(); } + + public String toString() { + return _cf.toString(); + } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java index e2fe9fff4..c6823c972 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java @@ -33,8 +33,7 @@ public class TestXSSFConditionalFormatting extends BaseTestConditionalFormatting testRead("WithConditionalFormatting.xlsx"); } - public void IGNORED_testReadOffice2007() { - // TODO Bring the XSSF support up to the same level + public void testReadOffice2007() { testReadOffice2007("NewStyleConditionalFormattings.xlsx"); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java index cb7f19aa8..902a01312 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java @@ -552,7 +552,14 @@ public abstract class BaseTestConditionalFormatting extends TestCase { if (str.contains("[CF12]")) fCF12++; if (str.contains("[CFEX]")) fCFEX++; } else { - fail("TODO!"); + ConditionType type = cf.getRule(cf.getNumberOfRules()-1).getConditionTypeType(); + if (type == ConditionType.CELL_VALUE_IS || + type == ConditionType.FORMULA) { + fCF++; + } else { + // TODO Detect Ext ones + fCF12++; + } } } assertEquals(numCF, fCF);