Browse Source

remove unnecessary short casts for getCellStyleAt

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905938 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
PJ Fanning 1 year ago
parent
commit
1b4e8ba77b

+ 1
- 1
poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java View File

@@ -320,7 +320,7 @@ public final class ToHtml {

private String styleName(CellStyle style) {
if (style == null) {
style = wb.getCellStyleAt((short) 0);
style = wb.getCellStyleAt(0);
}
StringBuilder sb = new StringBuilder();
try (Formatter fmt = new Formatter(sb, Locale.ROOT)) {

+ 1
- 1
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java View File

@@ -989,7 +989,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
@Override
public CellStyle getColumnStyle(int column) {
int idx = columnHelper.getColDefaultStyle(column);
return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx));
return getWorkbook().getCellStyleAt(idx == -1 ? 0 : idx);
}

/**

+ 1
- 1
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java View File

@@ -1094,7 +1094,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet s = wb.createSheet();

CellStyle defaultStyle = wb.getCellStyleAt((short) 0);
CellStyle defaultStyle = wb.getCellStyleAt(0);
assertEquals(0, defaultStyle.getIndex());

CellStyle blueStyle = wb.createCellStyle();

+ 1
- 1
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java View File

@@ -597,7 +597,7 @@ class TestXSSFCellStyle {
assertEquals(1, wb.getNumCellStyles());
assertEquals(2, styles.getFills().size());

XSSFCellStyle defaultStyle = wb.getCellStyleAt((short)0);
XSSFCellStyle defaultStyle = wb.getCellStyleAt(0);
assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor());
assertNull(defaultStyle.getFillForegroundXSSFColor());
assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPattern());

+ 3
- 3
poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java View File

@@ -1541,9 +1541,9 @@ final class TestBugs extends BaseTestBugzillaIssues {
// Write out and read back
try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) {
// Re-check
assertEquals("Testing", wb2.getCellStyleAt((short) 21).getUserStyleName());
assertEquals("Testing 2", wb2.getCellStyleAt((short) 22).getUserStyleName());
assertEquals("Testing 3", wb2.getCellStyleAt((short) 23).getUserStyleName());
assertEquals("Testing", wb2.getCellStyleAt(21).getUserStyleName());
assertEquals("Testing 2", wb2.getCellStyleAt(22).getUserStyleName());
assertEquals("Testing 3", wb2.getCellStyleAt(23).getUserStyleName());
}
}
}

+ 1
- 1
poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java View File

@@ -844,7 +844,7 @@ public abstract class BaseTestCell {
Cell cell = row.createCell(0);

// different default style indexes for HSSF and XSSF/SXSSF
CellStyle defaultStyle = wb.getCellStyleAt(wb instanceof HSSFWorkbook ? (short) 15 : (short) 0);
CellStyle defaultStyle = wb.getCellStyleAt(wb instanceof HSSFWorkbook ? 15 : 0);

// Starts out with the default style
assertEquals(defaultStyle, cell.getCellStyle());

Loading…
Cancel
Save