You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/02/18 17:44:06 UTC
svn commit: r1072053 - in /poi/trunk:
src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/50299.xlsx
Author: nick
Date: Fri Feb 18 16:44:05 2011
New Revision: 1072053
URL: http://svn.apache.org/viewvc?rev=1072053&view=rev
Log:
Fix bug #50299 with patch from Andrei - Fix XSSFColor fetching of white and black background themes
Added:
poi/trunk/test-data/spreadsheet/50299.xlsx (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1072053&r1=1072052&r2=1072053&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 18 16:44:05 2011
@@ -34,6 +34,7 @@
<changes>
<release version="3.8-beta1" date="2010-??-??">
+ <action dev="poi-developers" type="fix">50299 - Fix XSSFColor fetching of white and black background themes</action>
<action dev="poi-developers" type="fix">50795 - Avoid NPE from xmlbeans when moving XSSF Comments from one cell to another</action>
<action dev="poi-developers" type="fix">46664 - When creating HSSF Print Areas, ensure the named range is reference based not value based</action>
<action dev="poi-developers" type="fix">50756 - When formatting numbers based on their Cell Style, treat GENERAL the same as the more typical General</action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java?rev=1072053&r1=1072052&r2=1072053&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java Fri Feb 18 16:44:05 2011
@@ -51,7 +51,17 @@ public class ThemesTable extends POIXMLD
if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
if (cnt == idx) {
ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
- return new XSSFColor(ctColor.getSrgbClr().getVal());
+
+ byte[] rgb = null;
+ if (ctColor.getSrgbClr() != null) {
+ // Colour is a regular one
+ rgb = ctColor.getSrgbClr().getVal();
+ } else if (ctColor.getSysClr() != null) {
+ // Colour is a tint of white or black
+ rgb = ctColor.getSysClr().getLastClr();
+ }
+
+ return new XSSFColor(rgb);
}
cnt++;
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1072053&r1=1072052&r2=1072053&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Feb 18 16:44:05 2011
@@ -674,6 +674,37 @@ public final class TestXSSFBugs extends
}
/**
+ * When the cell background colour is set with one of the first
+ * two columns of the theme colour palette, the colours are
+ * shades of white or black.
+ * For those cases, ensure we don't break on reading the colour
+ */
+ public void test50299() throws Exception {
+ Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
+
+ // Check all the colours
+ for(int sn=0; sn<wb.getNumberOfSheets(); sn++) {
+ Sheet s = wb.getSheetAt(sn);
+ for(Row r : s) {
+ for(Cell c : r) {
+ CellStyle cs = c.getCellStyle();
+ if(cs != null) {
+ cs.getFillForegroundColor();
+ }
+ }
+ }
+ }
+
+ // Check one bit in detail
+ // TODO Is this correct, shouldn't one be white and one black?
+ Sheet s = wb.getSheetAt(0);
+ assertEquals(0, s.getRow(0).getCell(8).getCellStyle().getFillForegroundColor());
+ assertEquals(64, s.getRow(0).getCell(8).getCellStyle().getFillBackgroundColor());
+ assertEquals(0, s.getRow(1).getCell(8).getCellStyle().getFillForegroundColor());
+ assertEquals(64, s.getRow(1).getCell(8).getCellStyle().getFillBackgroundColor());
+ }
+
+ /**
* Fonts where their colours come from the theme rather
* then being set explicitly still should allow the
* fetching of the RGB
Added: poi/trunk/test-data/spreadsheet/50299.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/50299.xlsx?rev=1072053&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/50299.xlsx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org