further uptake of int methods for font lookups

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-02-22 22:32:25 +00:00
parent 104d4dac06
commit 753f6f9dc6
7 changed files with 36 additions and 36 deletions

View File

@ -849,7 +849,7 @@ public final class HSSFCellStyle implements CellStyle {
FontRecord fr = _workbook.createNewFont(); FontRecord fr = _workbook.createNewFont();
fr.cloneStyleFrom( fr.cloneStyleFrom(
source._workbook.getFontRecordAt( source._workbook.getFontRecordAt(
source.getFontIndex() source.getFontIntIndex()
) )
); );

View File

@ -346,7 +346,7 @@ public final class CellUtil {
put(properties, FILL_PATTERN, style.getFillPattern()); put(properties, FILL_PATTERN, style.getFillPattern());
put(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor()); put(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
put(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor()); put(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor());
put(properties, FONT, style.getFontIndex()); put(properties, FONT, style.getFontIntIndex());
put(properties, HIDDEN, style.getHidden()); put(properties, HIDDEN, style.getHidden());
put(properties, INDENTION, style.getIndention()); put(properties, INDENTION, style.getIndention());
put(properties, LEFT_BORDER_COLOR, style.getLeftBorderColor()); put(properties, LEFT_BORDER_COLOR, style.getLeftBorderColor());

View File

@ -210,7 +210,7 @@ public class TestAutoSizeColumnTracker {
private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) { private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) {
// autoSize will fail if required fonts are not installed, skip this test then // autoSize will fail if required fonts are not installed, skip this test then
Font font = workbook.getFontAt(cell.getCellStyle().getFontIndex()); Font font = workbook.getFontAt(cell.getCellStyle().getFontIntIndex());
Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font, Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
SheetUtil.canComputeColumnWidth(font)); SheetUtil.canComputeColumnWidth(font));
} }

View File

@ -350,7 +350,7 @@ public class TestSXSSFSheetAutoSizeColumn {
private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) { private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) {
// autoSize will fail if required fonts are not installed, skip this test then // autoSize will fail if required fonts are not installed, skip this test then
Font font = workbook.getFontAt(cell.getCellStyle().getFontIndex()); Font font = workbook.getFontAt(cell.getCellStyle().getFontIntIndex());
Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font, Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
SheetUtil.canComputeColumnWidth(font)); SheetUtil.canComputeColumnWidth(font));
} }

View File

@ -324,7 +324,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
cellXf.setXfId(1); cellXf.setXfId(1);
stylesTable.putCellXf(cellXf); stylesTable.putCellXf(cellXf);
XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable, null); XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);
assertEquals(1, cellStyle.getFontIndex()); assertEquals(1, cellStyle.getFontIntIndex());
sheet.setDefaultColumnStyle(3, cellStyle); sheet.setDefaultColumnStyle(3, cellStyle);
assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle()); assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());

View File

@ -1017,7 +1017,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
@Test @Test
public void bug45338() throws IOException { public void bug45338() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
assertEquals(4, wb.getNumberOfFonts()); assertEquals(4, wb.getNumberOfFontsAsInt());
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
s.createRow(0); s.createRow(0);
@ -1025,7 +1025,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
s.getRow(0).createCell(0); s.getRow(0).createCell(0);
s.getRow(1).createCell(0); s.getRow(1).createCell(0);
assertEquals(4, wb.getNumberOfFonts()); assertEquals(4, wb.getNumberOfFontsAsInt());
HSSFFont f1 = wb.getFontAt((short) 0); HSSFFont f1 = wb.getFontAt((short) 0);
assertFalse(f1.getBold()); assertFalse(f1.getBold());
@ -1033,19 +1033,19 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Check that asking for the same font // Check that asking for the same font
// multiple times gives you the same thing. // multiple times gives you the same thing.
// Otherwise, our tests wouldn't work! // Otherwise, our tests wouldn't work!
assertSame(wb.getFontAt((short) 0), wb.getFontAt((short) 0)); assertSame(wb.getFontAt(0), wb.getFontAt(0));
assertEquals( assertEquals(
wb.getFontAt((short) 0), wb.getFontAt(0),
wb.getFontAt((short) 0) wb.getFontAt(0)
); );
assertEquals( assertEquals(
wb.getFontAt((short) 2), wb.getFontAt(2),
wb.getFontAt((short) 2) wb.getFontAt(2)
); );
assertTrue( assertTrue(
wb.getFontAt((short) 0) wb.getFontAt(0)
!= !=
wb.getFontAt((short) 2) wb.getFontAt(2)
); );
// Look for a new font we have // Look for a new font we have
@ -1058,10 +1058,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
); );
HSSFFont nf = wb.createFont(); HSSFFont nf = wb.createFont();
assertEquals(5, wb.getNumberOfFonts()); assertEquals(5, wb.getNumberOfFontsAsInt());
assertEquals(5, nf.getIndex()); assertEquals(5, nf.getIndex());
assertEquals(nf, wb.getFontAt((short) 5)); assertEquals(nf, wb.getFontAt(5));
nf.setBold(false); nf.setBold(false);
nf.setColor((short) 123); nf.setColor((short) 123);
@ -1072,8 +1072,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
nf.setTypeOffset((short) 2); nf.setTypeOffset((short) 2);
nf.setUnderline((byte) 2); nf.setUnderline((byte) 2);
assertEquals(5, wb.getNumberOfFonts()); assertEquals(5, wb.getNumberOfFontsAsInt());
assertEquals(nf, wb.getFontAt((short) 5)); assertEquals(nf, wb.getFontAt(5));
// Find it now // Find it now
assertNotNull( assertNotNull(
@ -3130,20 +3130,20 @@ public final class TestBugs extends BaseTestBugzillaIssues {
Cell cell = row.getCell(1); Cell cell = row.getCell(1);
CellStyle style = cell.getCellStyle(); CellStyle style = cell.getCellStyle();
assertEquals(26, style.getFontIndex()); assertEquals(26, style.getFontIntIndex());
row = sheet.getRow(3); row = sheet.getRow(3);
cell = row.getCell(1); cell = row.getCell(1);
style = cell.getCellStyle(); style = cell.getCellStyle();
assertEquals(28, style.getFontIndex()); assertEquals(28, style.getFontIntIndex());
// check the two fonts // check the two fonts
HSSFFont font = wb.getFontAt((short) 26); HSSFFont font = wb.getFontAt(26);
assertTrue(font.getBold()); assertTrue(font.getBold());
assertEquals(10, font.getFontHeightInPoints()); assertEquals(10, font.getFontHeightInPoints());
assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", font.getFontName()); assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", font.getFontName());
font = wb.getFontAt((short) 28); font = wb.getFontAt(28);
assertTrue(font.getBold()); assertTrue(font.getBold());
assertEquals(10, font.getFontHeightInPoints()); assertEquals(10, font.getFontHeightInPoints());
assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", font.getFontName()); assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", font.getFontName());

View File

@ -101,9 +101,9 @@ public abstract class BaseTestFont {
font.setStrikeout(true); font.setStrikeout(true);
font.setColor(IndexedColors.YELLOW.getIndex()); font.setColor(IndexedColors.YELLOW.getIndex());
font.setFontName("Courier"); font.setFontName("Courier");
short font1Idx = font.getIndex(); int font1Idx = font.getIndexAsInt();
wb1.createCellStyle().setFont(font); wb1.createCellStyle().setFont(font);
assertEquals(num0 + 1, wb1.getNumberOfFonts()); assertEquals(num0 + 1, wb1.getNumberOfFontsAsInt());
CellStyle cellStyleTitle=wb1.createCellStyle(); CellStyle cellStyleTitle=wb1.createCellStyle();
cellStyleTitle.setFont(font); cellStyleTitle.setFont(font);
@ -114,8 +114,8 @@ public abstract class BaseTestFont {
wb1.close(); wb1.close();
s1 = wb2.getSheetAt(0); s1 = wb2.getSheetAt(0);
assertEquals(num0 + 1, wb2.getNumberOfFonts()); assertEquals(num0 + 1, wb2.getNumberOfFontsAsInt());
short idx = s1.getRow(0).getCell(0).getCellStyle().getFontIndex(); int idx = s1.getRow(0).getCell(0).getCellStyle().getFontIntIndex();
Font fnt = wb2.getFontAt(idx); Font fnt = wb2.getFontAt(idx);
assertNotNull(fnt); assertNotNull(fnt);
assertEquals(IndexedColors.YELLOW.getIndex(), fnt.getColor()); assertEquals(IndexedColors.YELLOW.getIndex(), fnt.getColor());
@ -125,9 +125,9 @@ public abstract class BaseTestFont {
Font font2 = wb2.createFont(); Font font2 = wb2.createFont();
font2.setItalic(true); font2.setItalic(true);
font2.setFontHeightInPoints((short)15); font2.setFontHeightInPoints((short)15);
short font2Idx = font2.getIndex(); int font2Idx = font2.getIndexAsInt();
wb2.createCellStyle().setFont(font2); wb2.createCellStyle().setFont(font2);
assertEquals(num0 + 2, wb2.getNumberOfFonts()); assertEquals(num0 + 2, wb2.getNumberOfFontsAsInt());
// Save and re-load // Save and re-load
Workbook wb3 = _testDataProvider.writeOutAndReadBack(wb2); Workbook wb3 = _testDataProvider.writeOutAndReadBack(wb2);
@ -135,7 +135,7 @@ public abstract class BaseTestFont {
s1 = wb3.getSheetAt(0); s1 = wb3.getSheetAt(0);
assertNotNull(s1); assertNotNull(s1);
assertEquals(num0 + 2, wb3.getNumberOfFonts()); assertEquals(num0 + 2, wb3.getNumberOfFontsAsInt());
assertNotNull(wb3.getFontAt(font1Idx)); assertNotNull(wb3.getFontAt(font1Idx));
assertNotNull(wb3.getFontAt(font2Idx)); assertNotNull(wb3.getFontAt(font2Idx));
@ -150,7 +150,7 @@ public abstract class BaseTestFont {
@Test @Test
public final void test45338() throws IOException { public final void test45338() throws IOException {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
int num0 = wb.getNumberOfFonts(); int num0 = wb.getNumberOfFontsAsInt();
Sheet s = wb.createSheet(); Sheet s = wb.createSheet();
s.createRow(0); s.createRow(0);
@ -159,13 +159,13 @@ public abstract class BaseTestFont {
s.getRow(1).createCell(0); s.getRow(1).createCell(0);
//default font //default font
Font f1 = wb.getFontAt((short)0); Font f1 = wb.getFontAt(0);
assertFalse(f1.getBold()); assertFalse(f1.getBold());
// Check that asking for the same font // Check that asking for the same font
// multiple times gives you the same thing. // multiple times gives you the same thing.
// Otherwise, our tests wouldn't work! // Otherwise, our tests wouldn't work!
assertSame(wb.getFontAt((short)0), wb.getFontAt((short)0)); assertSame(wb.getFontAt(0), wb.getFontAt(0));
// Look for a new font we have // Look for a new font we have
// yet to add // yet to add
@ -177,8 +177,8 @@ public abstract class BaseTestFont {
); );
Font nf = wb.createFont(); Font nf = wb.createFont();
short nfIdx = nf.getIndex(); int nfIdx = nf.getIndexAsInt();
assertEquals(num0 + 1, wb.getNumberOfFonts()); assertEquals(num0 + 1, wb.getNumberOfFontsAsInt());
assertSame(nf, wb.getFontAt(nfIdx)); assertSame(nf, wb.getFontAt(nfIdx));
@ -191,11 +191,11 @@ public abstract class BaseTestFont {
nf.setTypeOffset((short)2); nf.setTypeOffset((short)2);
nf.setUnderline((byte)2); nf.setUnderline((byte)2);
assertEquals(num0 + 1, wb.getNumberOfFonts()); assertEquals(num0 + 1, wb.getNumberOfFontsAsInt());
assertEquals(nf, wb.getFontAt(nfIdx)); assertEquals(nf, wb.getFontAt(nfIdx));
assertEquals(wb.getFontAt(nfIdx), wb.getFontAt(nfIdx)); assertEquals(wb.getFontAt(nfIdx), wb.getFontAt(nfIdx));
assertTrue(wb.getFontAt((short)0) != wb.getFontAt(nfIdx)); assertTrue(wb.getFontAt(0) != wb.getFontAt(nfIdx));
// Find it now // Find it now
assertNotNull( assertNotNull(