aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-05 14:38:55 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-05 14:38:55 +0000
commitee8781d7b52f13b1991ee2bd843e4006ed600983 (patch)
tree044ae7d185aa3767beb40d42a07fb628eab029f9
parent9e367160561ebf291e01e6924e2cc90707802bf4 (diff)
downloadpoi-ee8781d7b52f13b1991ee2bd843e4006ed600983.tar.gz
poi-ee8781d7b52f13b1991ee2bd843e4006ed600983.zip
extend tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903883 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
index d9aba70e50..58b93c6047 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
@@ -123,4 +123,86 @@ class TestXSSFCellUtil extends BaseTestCellUtil {
assertEquals(FillPatternType.NO_FILL, cell.getCellStyle().getFillPattern());
}
}
+
+ @Test
+ public void testBug66052WithWorkaround() throws IOException, DecoderException {
+
+ try (Workbook workbook = new XSSFWorkbook()) {
+
+ final Sheet sheet = workbook.createSheet("Sheet");
+ final Row row = sheet.createRow(0);
+ final Cell cell = row.createCell(0);
+ final XSSFColor color = new XSSFColor(Hex.decodeHex("FFAAAA"));
+
+ assertNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertNull(cell.getCellStyle().getFillBackgroundColorColor());
+
+ {
+ Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, color);
+ properties.put(CellUtil.FILL_BACKGROUND_COLOR_COLOR, null); // WORKAROUND
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.SOLID_FOREGROUND);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+
+ assertNotNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertNull(cell.getCellStyle().getFillBackgroundColorColor());
+
+ {
+ Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, null);
+ properties.put(CellUtil.FILL_BACKGROUND_COLOR_COLOR, null); // WORKAROUND
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.NO_FILL);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+
+ assertNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertNull(cell.getCellStyle().getFillBackgroundColorColor());
+ }
+ }
+
+ @Test
+ public void testBug66052WithoutWorkaround() throws IOException, DecoderException {
+
+ try (Workbook workbook = new XSSFWorkbook()) {
+
+ final Sheet sheet = workbook.createSheet("Sheet");
+ final Row row = sheet.createRow(0);
+ final Cell cell = row.createCell(0);
+ final XSSFColor color = new XSSFColor(Hex.decodeHex("FFAAAA"));
+
+ assertNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertNull(cell.getCellStyle().getFillBackgroundColorColor());
+
+ {
+ Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, color);
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.SOLID_FOREGROUND);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+
+ assertEquals(color, cell.getCellStyle().getFillForegroundColorColor());
+ assertEquals(IndexedColors.AUTOMATIC.getIndex(),
+ ((XSSFColor) cell.getCellStyle().getFillBackgroundColorColor()).getIndex());
+
+ {
+ Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, null);
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.NO_FILL);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+
+ assertNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertEquals(IndexedColors.AUTOMATIC.getIndex(),
+ ((XSSFColor) cell.getCellStyle().getFillBackgroundColorColor()).getIndex());
+ }
+ }
} \ No newline at end of file