Browse Source

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
tags/REL_4_1_0
Dominik Stadler 5 years ago
parent
commit
d942e2042d

+ 5
- 4
src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java View File

@@ -184,6 +184,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
* @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);
@@ -240,7 +241,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
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++;
}
@@ -670,7 +671,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
}
ctXfs.setCount(xfs.size());
ctXfs.setXfArray(
xfs.toArray(new CTXf[xfs.size()])
xfs.toArray(new CTXf[0])
);
styleSheet.setCellXfs(ctXfs);
}
@@ -683,7 +684,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
}
ctSXfs.setCount(styleXfs.size());
ctSXfs.setXfArray(
styleXfs.toArray(new CTXf[styleXfs.size()])
styleXfs.toArray(new CTXf[0])
);
styleSheet.setCellStyleXfs(ctSXfs);
}
@@ -695,7 +696,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
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);
}


+ 8
- 4
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java View File

@@ -33,11 +33,12 @@ public class XSSFColor extends ExtendedColor {
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);
}
@@ -80,9 +81,10 @@ public class XSSFColor extends ExtendedColor {

/**
* 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);
}

@@ -100,7 +102,7 @@ public class XSSFColor extends ExtendedColor {
/**
* 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);
@@ -113,6 +115,7 @@ public class XSSFColor extends ExtendedColor {
* @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);
}
@@ -122,6 +125,7 @@ public class XSSFColor extends ExtendedColor {
* @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);
}

+ 1
- 0
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java View File

@@ -562,6 +562,7 @@ public class XSSFFont implements Font {
* @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());

+ 13
- 13
src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java View File

@@ -32,37 +32,37 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
* 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);
}

/**
@@ -70,7 +70,7 @@ public class XSSFCellBorder {
* You need to attach this to the Styles Table
*/
public XSSFCellBorder() {
border = CTBorder.Factory.newInstance();
this(CTBorder.Factory.newInstance(), null, null);
}

/**

+ 3
- 3
src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java View File

@@ -66,7 +66,7 @@ public final class XSSFCellFill {
/**
* 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();
@@ -77,7 +77,7 @@ public final class XSSFCellFill {
/**
* 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();
@@ -161,7 +161,7 @@ public final class XSSFCellFill {
*/
@Internal
public CTFill getCTFill() {
return _fill;
return _fill;
}



+ 1
- 1
src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java View File

@@ -31,7 +31,7 @@ import org.junit.Test;
/**
* Tests of {@link BorderStyle}
*/
public class BaseTestBorderStyle {
public abstract class BaseTestBorderStyle {
private final ITestDataProvider _testDataProvider;


+ 7
- 7
src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java View File

@@ -46,7 +46,7 @@ import org.junit.Test;
*
* @see org.apache.poi.ss.util.CellUtil
*/
public class BaseTestCellUtil {
public abstract class BaseTestCellUtil {
protected final ITestDataProvider _testDataProvider;

protected BaseTestCellUtil(ITestDataProvider testDataProvider) {
@@ -302,10 +302,10 @@ public class BaseTestCellUtil {
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);
@@ -313,17 +313,17 @@ public class BaseTestCellUtil {
// 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();
}

Loading…
Cancel
Save