From: PJ Fanning Date: Sat, 3 Mar 2018 01:48:46 +0000 (+0000) Subject: remove some casts to short X-Git-Tag: REL_4_0_0_FINAL~226 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6791e333655bcb157152993cd4ec06975017c2da;p=poi.git remove some casts to short git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825749 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/util/PropertyTemplate.java b/src/java/org/apache/poi/ss/util/PropertyTemplate.java index 7b310cdbd7..b19ea9f713 100644 --- a/src/java/org/apache/poi/ss/util/PropertyTemplate.java +++ b/src/java/org/apache/poi/ss/util/PropertyTemplate.java @@ -958,8 +958,8 @@ public final class PropertyTemplate { * @return short value, or 0 if not a short */ private static short getShort(Object value) { - if (value instanceof Short) { - return ((Short) value).shortValue(); + if (value instanceof Number) { + return ((Number) value).shortValue(); } return 0; } diff --git a/src/java/org/apache/poi/ss/util/RegionUtil.java b/src/java/org/apache/poi/ss/util/RegionUtil.java index 5434aa3806..7846d015a8 100644 --- a/src/java/org/apache/poi/ss/util/RegionUtil.java +++ b/src/java/org/apache/poi/ss/util/RegionUtil.java @@ -42,7 +42,7 @@ public final class RegionUtil { public CellPropertySetter(String propertyName, int value) { _propertyName = propertyName; - _propertyValue = Short.valueOf((short) value); + _propertyValue = Integer.valueOf(value); } public CellPropertySetter(String propertyName, BorderStyle value) { _propertyName = propertyName; diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java index 782e21bee7..4e8310ea2c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java @@ -613,7 +613,7 @@ public class SXSSFCell implements Cell { { if(_style == null){ SXSSFWorkbook wb = (SXSSFWorkbook)getRow().getSheet().getWorkbook(); - return wb.getCellStyleAt((short)0); + return wb.getCellStyleAt(0); } else { return _style; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java index 89eea6ad4f..a86c637eea 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java @@ -138,7 +138,7 @@ public class XSSFFontFormatting implements FontFormatting { if(_font.sizeOfSzArray() == 0) return -1; CTFontSize sz = _font.getSzArray(0); - return (short)(20*sz.getVal()); + return (int)(20*sz.getVal()); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index fe8cafcaac..06751cf2e5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -876,7 +876,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { font1.setColor((short) 20); Font font2 = wb1.createFont(); font2.setColor(Font.COLOR_RED); - Font font3 = wb1.getFontAt((short) 0); + Font font3 = wb1.getFontAt(0); XSSFRow row = sheet.createRow(2); XSSFCell cell = row.createCell(2); @@ -1750,9 +1750,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // run some method on the font to verify if it is "disconnected" already //for(short i = 0;i < 256;i++) { - Font font = wb.getFontAt((short) 0); + Font font = wb.getFontAt(0); if (font instanceof XSSFFont) { - XSSFFont xfont = (XSSFFont) wb.getFontAt((short) 0); + XSSFFont xfont = (XSSFFont) wb.getFontAt(0); CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont(); assertEquals(0, ctFont.sizeOfBArray()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java index 64d27548d4..b9339ba019 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java @@ -35,7 +35,7 @@ public final class TestXSSFColor { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx"); // Check the CTColor is as expected - XSSFColor indexed = wb.getCellStyleAt((short)1).getFillBackgroundXSSFColor(); + XSSFColor indexed = wb.getCellStyleAt(1).getFillBackgroundXSSFColor(); assertEquals(true, indexed.getCTColor().isSetIndexed()); assertEquals(64, indexed.getCTColor().getIndexed()); assertEquals(false, indexed.getCTColor().isSetRgb()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java index 3ccf5a3371..a88ecf401d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java @@ -323,7 +323,7 @@ public final class TestXSSFFont extends BaseTestFont{ Workbook wb = new XSSFWorkbook(); // cannot check on result because on some machines we get back false here! - SheetUtil.canComputeColumnWidth(wb.getFontAt((short)0)); + SheetUtil.canComputeColumnWidth(wb.getFontAt(0)); wb.close(); } @@ -354,16 +354,16 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(1, wb.getNumberOfFonts()); - XSSFFont f1 = wb.getFontAt((short) 0); + XSSFFont f1 = wb.getFontAt(0); assertFalse(f1.getBold()); // Check that asking for the same font // multiple times gives you the same thing. // Otherwise, our tests wouldn't work! - assertSame(wb.getFontAt((short) 0), wb.getFontAt((short) 0)); + assertSame(wb.getFontAt(0), wb.getFontAt(0)); assertEquals( - wb.getFontAt((short) 0), - wb.getFontAt((short) 0) + wb.getFontAt(0), + wb.getFontAt(0) ); // Look for a new font we have @@ -384,8 +384,8 @@ public final class TestXSSFFont extends BaseTestFont{ XSSFFont nf = wb.createFont(); assertEquals(2, wb.getNumberOfFonts()); - assertEquals(1, nf.getIndex()); - assertEquals(nf, wb.getFontAt((short) 1)); + assertEquals(1, nf.getIndexAsInt()); + assertEquals(nf, wb.getFontAt(1)); nf.setBold(false); nf.setColor(IndexedColors.INDIGO.getIndex()); @@ -397,12 +397,12 @@ public final class TestXSSFFont extends BaseTestFont{ nf.setUnderline((byte) 2); assertEquals(2, wb.getNumberOfFonts()); - assertEquals(nf, wb.getFontAt((short) 1)); + assertEquals(nf, wb.getFontAt(1)); assertTrue( - wb.getFontAt((short) 0) + wb.getFontAt(0) != - wb.getFontAt((short) 1) + wb.getFontAt(1) ); // Find it now @@ -426,7 +426,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertNotNull(font); assertEquals( 1, - font.getIndex() + font.getIndexAsInt() ); assertEquals(nf, wb.findFont(