EPStyleRegion sregion = (EPStyleRegion) parent;
if (sregion.isValid()) {
Hashtable colorhash = sregion.getColorHash();
HSSFCellStyle style = sregion.getStyle();
short cnvhalign = convertAlignment(getHorizontalAlignment().getCode());
style.setAlignment(cnvhalign);
short cnvvalign = convertVAlignment(getVerticalAlignment().getCode());
style.setVerticalAlignment(cnvvalign);
style.setFillPattern((short)getShade());
if (getShade() == 1) {
// TODO: change to constant when upgrade to new HSSF
// solid w/foreground, bg doesn't matter
getLogger().debug("shade = 1");
HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
if (color == null) {
getLogger().debug("s1 BG couldn't find color for "+ getBackgroundColor().toString());
color = new HSSFColor.WHITE();
}
style.setFillForegroundColor(color.getIndex());
color = (HSSFColor) colorhash.get(getPatternColor().toString());
if (color == null) {
getLogger().debug("s1 PC couldn't find color for "+ getPatternColor().toString());
color = new HSSFColor.BLACK();
}
style.setFillBackgroundColor(color.getIndex());
} else {
HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
if (color == null) {
getLogger().debug("BG couldn't find color for "+ getBackgroundColor().toString());
color = new HSSFColor.BLACK();
}
style.setFillBackgroundColor(color.getIndex());
color = (HSSFColor) colorhash.get(getPatternColor().toString());
if (color == null) {
getLogger().debug("PC couldn't find color for "+ getPatternColor().toString());
color = new HSSFColor.WHITE();
}
style.setFillForegroundColor(color.getIndex());
}
style.setWrapText(getWrapText());
style.setLocked(true);
String format = null;
try {
format = getFormat();
} catch (NullPointerException e) {
format = "General";
}
if (!format.equals("General")) {
format = kludgeForGnumericMisformats(format);
format = kludgeForGnumericDateDivergence(format);
short nformat = org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(format);
getLogger().debug("setting format to "+ nformat);
style.setDataFormat(nformat);
}
} else {
invalid = true;
}
}