You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/08 18:45:15 UTC
svn commit: r1751955 - in /poi/trunk/src:
java/org/apache/poi/ss/util/CellUtil.java
testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
Author: onealj
Date: Fri Jul 8 18:45:15 2016
New Revision: 1751955
URL: http://svn.apache.org/viewvc?rev=1751955&view=rev
Log:
bug 55555: set fill pattern, foreground color, and background color order correctly to follow HSSFCellStyle's order requirement; patch from Qualtagh. This closes #33 on Github
Modified:
poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1751955&r1=1751954&r2=1751955&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Fri Jul 8 18:45:15 2016
@@ -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));
Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java?rev=1751955&r1=1751954&r2=1751955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Fri Jul 8 18:45:15 2016
@@ -31,7 +31,9 @@ import org.apache.poi.ss.ITestDataProvid
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -260,4 +262,23 @@ public class BaseTestCellUtil {
wb2.close();
}
}
+
+ // bug 55555
+ @Test
+ public void setFillForegroundColorBeforeFillBackgroundColor() {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Cell A1 = wb1.createSheet().createRow(0).createCell(0);
+ Map<String, Object> properties = new HashMap<String, Object>();
+ // FIXME: Use FillPatternType.BRICKS enum
+ properties.put(CellUtil.FILL_PATTERN, CellStyle.BRICKS);
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR, IndexedColors.BLUE.index);
+ properties.put(CellUtil.FILL_BACKGROUND_COLOR, IndexedColors.RED.index);
+
+ CellUtil.setCellStyleProperties(A1, properties);
+ CellStyle style = A1.getCellStyle();
+ // FIXME: Use FillPatternType.BRICKS enum
+ assertEquals("fill pattern", CellStyle.BRICKS, style.getFillPattern());
+ assertEquals("fill foreground color", IndexedColors.BLUE, IndexedColors.fromInt(style.getFillForegroundColor()));
+ assertEquals("fill background color", IndexedColors.RED, IndexedColors.fromInt(style.getFillBackgroundColor()));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org