git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1072053 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_8_BETA1
@@ -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> |
@@ -51,7 +51,17 @@ public class ThemesTable extends POIXMLDocumentPart { | |||
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++; | |||
} |
@@ -673,6 +673,37 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { | |||
assertEquals(exp, comment.getString().getString()); | |||
} | |||
/** | |||
* 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 |