* @param is The input stream containing the XML document.
* @throws IOException if an error occurs while reading.
*/
+ @SuppressWarnings("deprecation")
public void readFrom(InputStream is) throws IOException {
try {
doc = StyleSheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
CTTableStyles ctTableStyles = styleSheet.getTableStyles();
if (ctTableStyles != null) {
int idx = 0;
- for (CTTableStyle style : Arrays.asList(ctTableStyles.getTableStyleArray())) {
+ for (CTTableStyle style : ctTableStyles.getTableStyleArray()) {
tableStyles.put(style.getName(), new XSSFTableStyle(idx, styleDxfs, style, indexedColors));
idx++;
}
}
ctXfs.setCount(xfs.size());
ctXfs.setXfArray(
- xfs.toArray(new CTXf[xfs.size()])
+ xfs.toArray(new CTXf[0])
);
styleSheet.setCellXfs(ctXfs);
}
}
ctSXfs.setCount(styleXfs.size());
ctSXfs.setXfArray(
- styleXfs.toArray(new CTXf[styleXfs.size()])
+ styleXfs.toArray(new CTXf[0])
);
styleSheet.setCellStyleXfs(ctSXfs);
}
ctDxfs = CTDxfs.Factory.newInstance();
}
ctDxfs.setCount(dxfs.size());
- ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()]));
+ ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[0]));
styleSheet.setDxfs(ctDxfs);
}
private final IndexedColorMap indexedColorMap;
/**
- * @param color
- * @param map
+ * @param color The ooxml color object to use
+ * @param map The IndexedColorMap to use instead of the default one
* @return null if color is null, new instance otherwise
*/
public static XSSFColor from(CTColor color, IndexedColorMap map) {
+ //noinspection deprecation
return color == null ? null : new XSSFColor(color, map);
}
/**
* new color with the given indexed color map
- * @param colorMap
+ * @param colorMap The IndexedColorMap to use instead of the default one
*/
public XSSFColor(IndexedColorMap colorMap) {
+ //noinspection deprecation
this(CTColor.Factory.newInstance(), colorMap);
}
/**
* TEST ONLY
* @param clr awt Color
- * @param map
+ * @param map The IndexedColorMap to use instead of the default one
*/
public XSSFColor(java.awt.Color clr, IndexedColorMap map) {
this(map);
* @param colorMap The IndexedColorMap to use instead of the default one
*/
public XSSFColor(byte[] rgb, IndexedColorMap colorMap) {
+ //noinspection deprecation
this(CTColor.Factory.newInstance(), colorMap);
ctColor.setRgb(rgb);
}
* @param colorMap The IndexedColorMap to use instead of the default one
*/
public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) {
+ //noinspection deprecation
this(CTColor.Factory.newInstance(), colorMap);
ctColor.setIndexed(indexedColor.index);
}
* @return FontScheme
* @see org.apache.poi.xssf.model.StylesTable#createDefaultFont()
*/
+ @SuppressWarnings("JavadocReference")
public FontScheme getScheme() {
CTFontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.getSchemeArray(0);
return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal().intValue());
* Color is optional.
*/
public class XSSFCellBorder {
- private IndexedColorMap _indexedColorMap;
+ private final IndexedColorMap _indexedColorMap;
private ThemesTable _theme;
- private CTBorder border;
+ private final CTBorder border;
/**
* Creates a Cell Border from the supplied XML definition
- * @param border
- * @param theme
- * @param colorMap
+ * @param border The ooxml object for the border
+ * @param theme The related themes
+ * @param colorMap The global map of colors
*/
public XSSFCellBorder(CTBorder border, ThemesTable theme, IndexedColorMap colorMap) {
- this(border, colorMap);
+ this.border = border;
+ this._indexedColorMap = colorMap;
this._theme = theme;
}
/**
* Creates a Cell Border from the supplied XML definition
- * @param border
+ * @param border The ooxml object for the border
*/
public XSSFCellBorder(CTBorder border) {
- this(border, null);
+ this(border, null, null);
}
/**
*
- * @param border
- * @param colorMap
+ * @param border The ooxml object for the border
+ * @param colorMap The global map of colors
*/
public XSSFCellBorder(CTBorder border, IndexedColorMap colorMap) {
- this.border = border;
- this._indexedColorMap = colorMap;
+ this(border, null, colorMap);
}
/**
* You need to attach this to the Styles Table
*/
public XSSFCellBorder() {
- border = CTBorder.Factory.newInstance();
+ this(CTBorder.Factory.newInstance(), null, null);
}
/**
/**
* Set the background fill color represented as a indexed color value.
*
- * @param index
+ * @param index - the color to use
*/
public void setFillBackgroundColor(int index) {
CTPatternFill ptrn = ensureCTPatternFill();
/**
* Set the background fill color represented as a {@link XSSFColor} value.
*
- * @param color
+ * @param color - background color. null if color should be unset
*/
public void setFillBackgroundColor(XSSFColor color) {
CTPatternFill ptrn = ensureCTPatternFill();
*/
@Internal
public CTFill getCTFill() {
- return _fill;
+ return _fill;
}
/**
* Tests of {@link BorderStyle}
*/
-public class BaseTestBorderStyle {
+public abstract class BaseTestBorderStyle {
private final ITestDataProvider _testDataProvider;
*
* @see org.apache.poi.ss.util.CellUtil
*/
-public class BaseTestCellUtil {
+public abstract class BaseTestCellUtil {
protected final ITestDataProvider _testDataProvider;
protected BaseTestCellUtil(ITestDataProvider testDataProvider) {
Row row = sh.createRow(0);
Cell A1 = row.createCell(0);
Cell B1 = row.createCell(1);
- final short defaultFontIndex = 0;
+ final int defaultFontIndex = 0;
Font font = wb.createFont();
font.setItalic(true);
- final short customFontIndex = font.getIndex();
+ final int customFontIndex = font.getIndexAsInt();
// Assumptions
assertNotEquals(defaultFontIndex, customFontIndex);
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
// HSSFCellStyle wraps an underlying style record, and the underlying
// style record is the same between multiple getCellStyle() calls.
- assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndex());
- assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
+ assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndexAsInt());
+ assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt());
// get/set alignment modifies the cell's style
CellUtil.setFont(A1, font);
- assertEquals(customFontIndex, A1.getCellStyle().getFontIndex());
+ assertEquals(customFontIndex, A1.getCellStyle().getFontIndexAsInt());
// get/set alignment doesn't affect the style of cells with
// the same style prior to modifying the style
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
- assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
+ assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt());
wb.close();
}