typeLookup.put(STCfType.ABOVE_AVERAGE, ConditionType.FILTER);\r
}\r
\r
- // TODO Support types beyond CELL_VALUE_IS and FORMULA\r
-\r
/*package*/ XSSFConditionalFormattingRule(XSSFSheet sh){\r
_cfRule = CTCfRule.Factory.newInstance();\r
_sh = sh;\r
}\r
\r
public XSSFColorScaleFormatting createColorScaleFormatting() {\r
- // TODO Implement\r
- return null;\r
+ // Is it already there?\r
+ if (_cfRule.isSetColorScale() && _cfRule.getType() == STCfType.COLOR_SCALE)\r
+ return getColorScaleFormatting();\r
+ \r
+ // Mark it as being a Color Scale\r
+ _cfRule.setType(STCfType.COLOR_SCALE);\r
+\r
+ // Ensure the right element\r
+ CTColorScale scale = null;\r
+ if (_cfRule.isSetColorScale()) {\r
+ scale = _cfRule.getColorScale();\r
+ } else {\r
+ scale = _cfRule.addNewColorScale();\r
+ }\r
+ \r
+ // Add a default set of thresholds and colors\r
+ if (scale.sizeOfCfvoArray() == 0) {\r
+ CTCfvo cfvo;\r
+ cfvo = scale.addNewCfvo();\r
+ cfvo.setType(STCfvoType.Enum.forString(RangeType.MIN.name));\r
+ cfvo = scale.addNewCfvo();\r
+ cfvo.setType(STCfvoType.Enum.forString(RangeType.PERCENTILE.name));\r
+ cfvo.setVal("50");\r
+ cfvo = scale.addNewCfvo();\r
+ cfvo.setType(STCfvoType.Enum.forString(RangeType.MAX.name));\r
+ \r
+ for (int i=0; i<3; i++) {\r
+ scale.addNewColor();\r
+ }\r
+ }\r
+ \r
+ // Wrap and return\r
+ return new XSSFColorScaleFormatting(scale);\r
}\r
public XSSFColorScaleFormatting getColorScaleFormatting() {\r
if (_cfRule.isSetColorScale()) {\r
// Mixed icons - Column U\r
// TODO Support EXT formattings\r
}\r
+ \r
private void assertIconSetPercentages(ConditionalFormatting cf, IconSet iconset, Double...vals) {\r
assertEquals(1, cf.getNumberOfRules());\r
ConditionalFormattingRule cr = cf.getRule(0);\r
assertEquals(null, cr.getFormula1());\r
assertEquals(null, cr.getFormula2());\r
\r
- // TODO Implement\r
-/*\r
+// TODO Finish HSSF\r
+if (cr instanceof HSSFConditionalFormattingRule) return;\r
+ \r
ColorScaleFormatting color = cr.getColorScaleFormatting();\r
assertNotNull(color);\r
assertNotNull(color.getColors());\r
} else if (i == colors.length-1) {\r
assertEquals(RangeType.MAX, th.getRangeType());\r
} else {\r
- assertEquals(RangeType.PERCENT, th.getRangeType());\r
- assertEquals(steps*i, th.getValue());\r
+ assertEquals(RangeType.PERCENTILE, th.getRangeType());\r
+ assertEquals(steps*i, th.getValue().intValue());\r
}\r
assertEquals(null, th.getFormula());\r
}\r
\r
// Colors should match\r
for (int i=0; i<colors.length; i++) {\r
- Color c = color.getColors()[i];\r
- assertEquals(colors[i], c.toString());\r
+ assertColour(colors[i], color.getColors()[i]);\r
}\r
-*/\r
}\r
\r
public void testCreateFontFormatting() {\r
assertEquals(null, iconFmt.getThresholds()[3].getValue());\r
}\r
\r
+ public void testCreateColorScaleFormatting() {\r
+ // TODO Implement then test\r
+ }\r
+ public void testCreateDataBarFormatting() {\r
+ // TODO Implement then test\r
+ }\r
+ \r
public void testBug55380() {\r
Workbook wb = _testDataProvider.createWorkbook();\r
Sheet sheet = wb.createSheet();\r