mirror of https://github.com/apache/poi.git
IDE and JavaDoc fixes, make base test classes abstract
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c039da1b94
commit
d942e2042d
|
@ -184,6 +184,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
||||||
* @param is The input stream containing the XML document.
|
* @param is The input stream containing the XML document.
|
||||||
* @throws IOException if an error occurs while reading.
|
* @throws IOException if an error occurs while reading.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void readFrom(InputStream is) throws IOException {
|
public void readFrom(InputStream is) throws IOException {
|
||||||
try {
|
try {
|
||||||
doc = StyleSheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
|
doc = StyleSheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
|
||||||
|
@ -240,7 +241,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
||||||
CTTableStyles ctTableStyles = styleSheet.getTableStyles();
|
CTTableStyles ctTableStyles = styleSheet.getTableStyles();
|
||||||
if (ctTableStyles != null) {
|
if (ctTableStyles != null) {
|
||||||
int idx = 0;
|
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));
|
tableStyles.put(style.getName(), new XSSFTableStyle(idx, styleDxfs, style, indexedColors));
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +671,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
||||||
}
|
}
|
||||||
ctXfs.setCount(xfs.size());
|
ctXfs.setCount(xfs.size());
|
||||||
ctXfs.setXfArray(
|
ctXfs.setXfArray(
|
||||||
xfs.toArray(new CTXf[xfs.size()])
|
xfs.toArray(new CTXf[0])
|
||||||
);
|
);
|
||||||
styleSheet.setCellXfs(ctXfs);
|
styleSheet.setCellXfs(ctXfs);
|
||||||
}
|
}
|
||||||
|
@ -683,7 +684,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
||||||
}
|
}
|
||||||
ctSXfs.setCount(styleXfs.size());
|
ctSXfs.setCount(styleXfs.size());
|
||||||
ctSXfs.setXfArray(
|
ctSXfs.setXfArray(
|
||||||
styleXfs.toArray(new CTXf[styleXfs.size()])
|
styleXfs.toArray(new CTXf[0])
|
||||||
);
|
);
|
||||||
styleSheet.setCellStyleXfs(ctSXfs);
|
styleSheet.setCellStyleXfs(ctSXfs);
|
||||||
}
|
}
|
||||||
|
@ -695,7 +696,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
||||||
ctDxfs = CTDxfs.Factory.newInstance();
|
ctDxfs = CTDxfs.Factory.newInstance();
|
||||||
}
|
}
|
||||||
ctDxfs.setCount(dxfs.size());
|
ctDxfs.setCount(dxfs.size());
|
||||||
ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()]));
|
ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[0]));
|
||||||
styleSheet.setDxfs(ctDxfs);
|
styleSheet.setDxfs(ctDxfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,12 @@ public class XSSFColor extends ExtendedColor {
|
||||||
private final IndexedColorMap indexedColorMap;
|
private final IndexedColorMap indexedColorMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param color
|
* @param color The ooxml color object to use
|
||||||
* @param map
|
* @param map The IndexedColorMap to use instead of the default one
|
||||||
* @return null if color is null, new instance otherwise
|
* @return null if color is null, new instance otherwise
|
||||||
*/
|
*/
|
||||||
public static XSSFColor from(CTColor color, IndexedColorMap map) {
|
public static XSSFColor from(CTColor color, IndexedColorMap map) {
|
||||||
|
//noinspection deprecation
|
||||||
return color == null ? null : new XSSFColor(color, map);
|
return color == null ? null : new XSSFColor(color, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +81,10 @@ public class XSSFColor extends ExtendedColor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* new color with the given indexed 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) {
|
public XSSFColor(IndexedColorMap colorMap) {
|
||||||
|
//noinspection deprecation
|
||||||
this(CTColor.Factory.newInstance(), colorMap);
|
this(CTColor.Factory.newInstance(), colorMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +102,7 @@ public class XSSFColor extends ExtendedColor {
|
||||||
/**
|
/**
|
||||||
* TEST ONLY
|
* TEST ONLY
|
||||||
* @param clr awt Color
|
* @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) {
|
public XSSFColor(java.awt.Color clr, IndexedColorMap map) {
|
||||||
this(map);
|
this(map);
|
||||||
|
@ -113,6 +115,7 @@ public class XSSFColor extends ExtendedColor {
|
||||||
* @param colorMap The IndexedColorMap to use instead of the default one
|
* @param colorMap The IndexedColorMap to use instead of the default one
|
||||||
*/
|
*/
|
||||||
public XSSFColor(byte[] rgb, IndexedColorMap colorMap) {
|
public XSSFColor(byte[] rgb, IndexedColorMap colorMap) {
|
||||||
|
//noinspection deprecation
|
||||||
this(CTColor.Factory.newInstance(), colorMap);
|
this(CTColor.Factory.newInstance(), colorMap);
|
||||||
ctColor.setRgb(rgb);
|
ctColor.setRgb(rgb);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +125,7 @@ public class XSSFColor extends ExtendedColor {
|
||||||
* @param colorMap The IndexedColorMap to use instead of the default one
|
* @param colorMap The IndexedColorMap to use instead of the default one
|
||||||
*/
|
*/
|
||||||
public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) {
|
public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) {
|
||||||
|
//noinspection deprecation
|
||||||
this(CTColor.Factory.newInstance(), colorMap);
|
this(CTColor.Factory.newInstance(), colorMap);
|
||||||
ctColor.setIndexed(indexedColor.index);
|
ctColor.setIndexed(indexedColor.index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,6 +562,7 @@ public class XSSFFont implements Font {
|
||||||
* @return FontScheme
|
* @return FontScheme
|
||||||
* @see org.apache.poi.xssf.model.StylesTable#createDefaultFont()
|
* @see org.apache.poi.xssf.model.StylesTable#createDefaultFont()
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("JavadocReference")
|
||||||
public FontScheme getScheme() {
|
public FontScheme getScheme() {
|
||||||
CTFontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.getSchemeArray(0);
|
CTFontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.getSchemeArray(0);
|
||||||
return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal().intValue());
|
return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal().intValue());
|
||||||
|
|
|
@ -32,37 +32,37 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
|
||||||
* Color is optional.
|
* Color is optional.
|
||||||
*/
|
*/
|
||||||
public class XSSFCellBorder {
|
public class XSSFCellBorder {
|
||||||
private IndexedColorMap _indexedColorMap;
|
private final IndexedColorMap _indexedColorMap;
|
||||||
private ThemesTable _theme;
|
private ThemesTable _theme;
|
||||||
private CTBorder border;
|
private final CTBorder border;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Cell Border from the supplied XML definition
|
* Creates a Cell Border from the supplied XML definition
|
||||||
* @param border
|
* @param border The ooxml object for the border
|
||||||
* @param theme
|
* @param theme The related themes
|
||||||
* @param colorMap
|
* @param colorMap The global map of colors
|
||||||
*/
|
*/
|
||||||
public XSSFCellBorder(CTBorder border, ThemesTable theme, IndexedColorMap colorMap) {
|
public XSSFCellBorder(CTBorder border, ThemesTable theme, IndexedColorMap colorMap) {
|
||||||
this(border, colorMap);
|
this.border = border;
|
||||||
|
this._indexedColorMap = colorMap;
|
||||||
this._theme = theme;
|
this._theme = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Cell Border from the supplied XML definition
|
* Creates a Cell Border from the supplied XML definition
|
||||||
* @param border
|
* @param border The ooxml object for the border
|
||||||
*/
|
*/
|
||||||
public XSSFCellBorder(CTBorder border) {
|
public XSSFCellBorder(CTBorder border) {
|
||||||
this(border, null);
|
this(border, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param border
|
* @param border The ooxml object for the border
|
||||||
* @param colorMap
|
* @param colorMap The global map of colors
|
||||||
*/
|
*/
|
||||||
public XSSFCellBorder(CTBorder border, IndexedColorMap colorMap) {
|
public XSSFCellBorder(CTBorder border, IndexedColorMap colorMap) {
|
||||||
this.border = border;
|
this(border, null, colorMap);
|
||||||
this._indexedColorMap = colorMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ public class XSSFCellBorder {
|
||||||
* You need to attach this to the Styles Table
|
* You need to attach this to the Styles Table
|
||||||
*/
|
*/
|
||||||
public XSSFCellBorder() {
|
public XSSFCellBorder() {
|
||||||
border = CTBorder.Factory.newInstance();
|
this(CTBorder.Factory.newInstance(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,7 +66,7 @@ public final class XSSFCellFill {
|
||||||
/**
|
/**
|
||||||
* Set the background fill color represented as a indexed color value.
|
* Set the background fill color represented as a indexed color value.
|
||||||
*
|
*
|
||||||
* @param index
|
* @param index - the color to use
|
||||||
*/
|
*/
|
||||||
public void setFillBackgroundColor(int index) {
|
public void setFillBackgroundColor(int index) {
|
||||||
CTPatternFill ptrn = ensureCTPatternFill();
|
CTPatternFill ptrn = ensureCTPatternFill();
|
||||||
|
@ -77,7 +77,7 @@ public final class XSSFCellFill {
|
||||||
/**
|
/**
|
||||||
* Set the background fill color represented as a {@link XSSFColor} value.
|
* 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) {
|
public void setFillBackgroundColor(XSSFColor color) {
|
||||||
CTPatternFill ptrn = ensureCTPatternFill();
|
CTPatternFill ptrn = ensureCTPatternFill();
|
||||||
|
@ -161,7 +161,7 @@ public final class XSSFCellFill {
|
||||||
*/
|
*/
|
||||||
@Internal
|
@Internal
|
||||||
public CTFill getCTFill() {
|
public CTFill getCTFill() {
|
||||||
return _fill;
|
return _fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* Tests of {@link BorderStyle}
|
* Tests of {@link BorderStyle}
|
||||||
*/
|
*/
|
||||||
public class BaseTestBorderStyle {
|
public abstract class BaseTestBorderStyle {
|
||||||
|
|
||||||
private final ITestDataProvider _testDataProvider;
|
private final ITestDataProvider _testDataProvider;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.ss.util.CellUtil
|
* @see org.apache.poi.ss.util.CellUtil
|
||||||
*/
|
*/
|
||||||
public class BaseTestCellUtil {
|
public abstract class BaseTestCellUtil {
|
||||||
protected final ITestDataProvider _testDataProvider;
|
protected final ITestDataProvider _testDataProvider;
|
||||||
|
|
||||||
protected BaseTestCellUtil(ITestDataProvider testDataProvider) {
|
protected BaseTestCellUtil(ITestDataProvider testDataProvider) {
|
||||||
|
@ -302,10 +302,10 @@ public class BaseTestCellUtil {
|
||||||
Row row = sh.createRow(0);
|
Row row = sh.createRow(0);
|
||||||
Cell A1 = row.createCell(0);
|
Cell A1 = row.createCell(0);
|
||||||
Cell B1 = row.createCell(1);
|
Cell B1 = row.createCell(1);
|
||||||
final short defaultFontIndex = 0;
|
final int defaultFontIndex = 0;
|
||||||
Font font = wb.createFont();
|
Font font = wb.createFont();
|
||||||
font.setItalic(true);
|
font.setItalic(true);
|
||||||
final short customFontIndex = font.getIndex();
|
final int customFontIndex = font.getIndexAsInt();
|
||||||
|
|
||||||
// Assumptions
|
// Assumptions
|
||||||
assertNotEquals(defaultFontIndex, customFontIndex);
|
assertNotEquals(defaultFontIndex, customFontIndex);
|
||||||
|
@ -313,17 +313,17 @@ public class BaseTestCellUtil {
|
||||||
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
|
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
|
||||||
// HSSFCellStyle wraps an underlying style record, and the underlying
|
// HSSFCellStyle wraps an underlying style record, and the underlying
|
||||||
// style record is the same between multiple getCellStyle() calls.
|
// style record is the same between multiple getCellStyle() calls.
|
||||||
assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndex());
|
assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndexAsInt());
|
||||||
assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
|
assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt());
|
||||||
|
|
||||||
// get/set alignment modifies the cell's style
|
// get/set alignment modifies the cell's style
|
||||||
CellUtil.setFont(A1, font);
|
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
|
// get/set alignment doesn't affect the style of cells with
|
||||||
// the same style prior to modifying the style
|
// the same style prior to modifying the style
|
||||||
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
|
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
|
||||||
assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
|
assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue