]> source.dussan.org Git - poi.git/commitdiff
bug 55555: set fill pattern, foreground color, and background color order correctly...
authorJaven O'Neal <onealj@apache.org>
Fri, 8 Jul 2016 18:45:15 +0000 (18:45 +0000)
committerJaven O'Neal <onealj@apache.org>
Fri, 8 Jul 2016 18:45:15 +0000 (18:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751955 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/CellUtil.java
src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java

index 5963e7d7dd01d0644c52398f2087d1d36398d8d7..4f8c9cd1836c06c8d7b6c565b61eaee2f6070901 100644 (file)
@@ -331,9 +331,9 @@ public final class CellUtil {
         putBorderStyle(properties, BORDER_TOP, style.getBorderTop());
         putShort(properties, BOTTOM_BORDER_COLOR, style.getBottomBorderColor());
         putShort(properties, DATA_FORMAT, style.getDataFormat());
-        putShort(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor());
-        putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
         putShort(properties, FILL_PATTERN, style.getFillPattern());
+        putShort(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
+        putShort(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor());
         putShort(properties, FONT, style.getFontIndex());
         putBoolean(properties, HIDDEN, style.getHidden());
         putShort(properties, INDENTION, style.getIndention());
@@ -363,9 +363,9 @@ public final class CellUtil {
         style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
         style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
         style.setDataFormat(getShort(properties, DATA_FORMAT));
-        style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
-        style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
         style.setFillPattern(getShort(properties, FILL_PATTERN));
+        style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
+        style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
         style.setFont(workbook.getFontAt(getShort(properties, FONT)));
         style.setHidden(getBoolean(properties, HIDDEN));
         style.setIndention(getShort(properties, INDENTION));
index 59609bfbe2b1d5a6d1a97d46218583ec9674a932..5caf980b07fd219f6d8bd69a3c9df65d0fd308db 100644 (file)
@@ -31,7 +31,9 @@ import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.usermodel.BorderStyle;\r
 import org.apache.poi.ss.usermodel.Cell;\r
 import org.apache.poi.ss.usermodel.CellStyle;\r
+import org.apache.poi.ss.usermodel.FillPatternType;\r
 import org.apache.poi.ss.usermodel.Font;\r
+import org.apache.poi.ss.usermodel.IndexedColors;\r
 import org.apache.poi.ss.usermodel.Row;\r
 import org.apache.poi.ss.usermodel.Sheet;\r
 import org.apache.poi.ss.usermodel.Workbook;\r
@@ -260,4 +262,23 @@ public class BaseTestCellUtil {
             wb2.close();\r
         }\r
     }\r
+    \r
+    // bug 55555\r
+    @Test\r
+    public void setFillForegroundColorBeforeFillBackgroundColor() {\r
+        Workbook wb1 = _testDataProvider.createWorkbook();\r
+        Cell A1 = wb1.createSheet().createRow(0).createCell(0);\r
+        Map<String, Object> properties = new HashMap<String, Object>();\r
+        // FIXME: Use FillPatternType.BRICKS enum\r
+        properties.put(CellUtil.FILL_PATTERN, CellStyle.BRICKS);\r
+        properties.put(CellUtil.FILL_FOREGROUND_COLOR, IndexedColors.BLUE.index);\r
+        properties.put(CellUtil.FILL_BACKGROUND_COLOR, IndexedColors.RED.index);\r
+        \r
+        CellUtil.setCellStyleProperties(A1, properties);\r
+        CellStyle style = A1.getCellStyle();\r
+        // FIXME: Use FillPatternType.BRICKS enum\r
+        assertEquals("fill pattern", CellStyle.BRICKS, style.getFillPattern());\r
+        assertEquals("fill foreground color", IndexedColors.BLUE, IndexedColors.fromInt(style.getFillForegroundColor()));\r
+        assertEquals("fill background color", IndexedColors.RED, IndexedColors.fromInt(style.getFillBackgroundColor()));\r
+    }\r
 }\r