git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1082946 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_8_BETA2
<changes> | <changes> | ||||
<release version="3.8-beta2" date="2011-??-??"> | <release version="3.8-beta2" date="2011-??-??"> | ||||
<action dev="poi-developers" type="fix">50846 - More XSSFColor theme improvements, this time for Cell Borders</action> | |||||
<action dev="poi-developers" type="fix">50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not</action> | <action dev="poi-developers" type="fix">50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not</action> | ||||
<action dev="poi-developers" type="add">HMEF - New component which supports TNEF (Transport Neutral Encoding Format), aka winmail.dat</action> | <action dev="poi-developers" type="add">HMEF - New component which supports TNEF (Transport Neutral Encoding Format), aka winmail.dat</action> | ||||
<action dev="poi-developers" type="fix">50313 - support for getting HWPFDocument fields</action> | <action dev="poi-developers" type="fix">50313 - support for getting HWPFDocument fields</action> |
public void setTheme(ThemesTable theme) { | public void setTheme(ThemesTable theme) { | ||||
this.theme = theme; | this.theme = theme; | ||||
// Pass the themes table along to things which need to | |||||
// know about it, but have already been created by now | |||||
for(XSSFFont font : fonts) { | for(XSSFFont font : fonts) { | ||||
font.setThemesTable(theme); | font.setThemesTable(theme); | ||||
} | } | ||||
for(XSSFCellBorder border : borders) { | |||||
border.setThemesTable(theme); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
CTBorders ctborders = styleSheet.getBorders(); | CTBorders ctborders = styleSheet.getBorders(); | ||||
if(ctborders != null) { | if(ctborders != null) { | ||||
for (CTBorder border : ctborders.getBorderArray()) { | for (CTBorder border : ctborders.getBorderArray()) { | ||||
borders.add(new XSSFCellBorder(border, theme)); | |||||
borders.add(new XSSFCellBorder(border)); | |||||
} | } | ||||
} | } | ||||
return idx; | return idx; | ||||
} | } | ||||
borders.add(border); | borders.add(border); | ||||
border.setThemesTable(theme); | |||||
return borders.size() - 1; | return borders.size() - 1; | ||||
} | } | ||||
fills.add(new XSSFCellFill(ctFill[1])); | fills.add(new XSSFCellFill(ctFill[1])); | ||||
CTBorder ctBorder = createDefaultBorder(); | CTBorder ctBorder = createDefaultBorder(); | ||||
borders.add(new XSSFCellBorder(ctBorder, theme)); | |||||
borders.add(new XSSFCellBorder(ctBorder)); | |||||
CTXf styleXf = createDefaultXf(); | CTXf styleXf = createDefaultXf(); | ||||
styleXfs.add(styleXf); | styleXfs.add(styleXf); |
* Creates a Cell Border from the supplied XML definition | * Creates a Cell Border from the supplied XML definition | ||||
*/ | */ | ||||
public XSSFCellBorder(CTBorder border, ThemesTable theme) { | public XSSFCellBorder(CTBorder border, ThemesTable theme) { | ||||
this.border = border; | |||||
this(border); | |||||
this._theme = theme; | this._theme = theme; | ||||
} | } | ||||
/** | |||||
* Creates a Cell Border from the supplied XML definition | |||||
*/ | |||||
public XSSFCellBorder(CTBorder border) { | |||||
this.border = border; | |||||
} | |||||
/** | /** | ||||
* Creates a new, empty Cell Border. | * Creates a new, empty Cell Border. | ||||
* You need to attach this to the Styles Table | * You need to attach this to the Styles Table | ||||
*/ | */ | ||||
public XSSFCellBorder(ThemesTable theme) { | |||||
public XSSFCellBorder() { | |||||
border = CTBorder.Factory.newInstance(); | border = CTBorder.Factory.newInstance(); | ||||
this._theme = theme; | |||||
} | } | ||||
/** | |||||
* Records the Themes Table that is associated with | |||||
* the current font, used when looking up theme | |||||
* based colours and properties. | |||||
*/ | |||||
public void setThemesTable(ThemesTable themes) { | |||||
this._theme = themes; | |||||
} | |||||
/** | /** | ||||
* The enumeration value indicating the side being used for a cell border. | * The enumeration value indicating the side being used for a cell border. | ||||
*/ | */ |
* should still be able to get colours | * should still be able to get colours | ||||
*/ | */ | ||||
public void test50846() throws Exception { | public void test50846() throws Exception { | ||||
// TODO Get file and test | |||||
//Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50846.xlsx"); | |||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50846-border_colours.xlsx"); | |||||
// Check the style that is theme based | |||||
XSSFSheet sheet = wb.getSheetAt(0); | |||||
XSSFRow row = sheet.getRow(0); | |||||
// Border from a theme, brown | |||||
XSSFCell cellT = row.getCell(0); | |||||
XSSFCellStyle styleT = cellT.getCellStyle(); | |||||
XSSFColor colorT = styleT.getBottomBorderXSSFColor(); | |||||
assertEquals(5, colorT.getTheme()); | |||||
assertEquals("FFC0504D", colorT.getARGBHex()); | |||||
// Border from a style direct, red | |||||
XSSFCell cellS = row.getCell(1); | |||||
XSSFCellStyle styleS = cellS.getCellStyle(); | |||||
XSSFColor colorS = styleS.getBottomBorderXSSFColor(); | |||||
// Check the one that isn't | |||||
assertEquals(0, colorS.getTheme()); | |||||
assertEquals("FFFF0000", colorS.getARGBHex()); | |||||
} | } | ||||
/** | /** |
ctStylesheet = stylesTable.getCTStylesheet(); | ctStylesheet = stylesTable.getCTStylesheet(); | ||||
ctBorderA = CTBorder.Factory.newInstance(); | ctBorderA = CTBorder.Factory.newInstance(); | ||||
XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA, null); | |||||
XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA); | |||||
long borderId = stylesTable.putBorder(borderA); | long borderId = stylesTable.putBorder(borderA); | ||||
assertEquals(1, borderId); | assertEquals(1, borderId); | ||||
XSSFCellBorder borderB = new XSSFCellBorder(null); | |||||
XSSFCellBorder borderB = new XSSFCellBorder(); | |||||
assertEquals(1, stylesTable.putBorder(borderB)); | assertEquals(1, stylesTable.putBorder(borderB)); | ||||
ctFill = CTFill.Factory.newInstance(); | ctFill = CTFill.Factory.newInstance(); |
right.setStyle(STBorderStyle.NONE); | right.setStyle(STBorderStyle.NONE); | ||||
bottom.setStyle(STBorderStyle.THIN); | bottom.setStyle(STBorderStyle.THIN); | ||||
XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border, null); | |||||
XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border); | |||||
assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString()); | assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString()); | ||||
assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString()); | assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString()); |