Author: fanningpj
Date: Thu Feb 22 22:32:25 2018
New Revision: 1825103

URL: http://svn.apache.org/viewvc?rev=1825103&view=rev
Log:
further uptake of int methods for font lookups

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestAutoSizeColumnTracker.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheetAutoSizeColumn.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java 
(original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Thu Feb 
22 22:32:25 2018
@@ -849,7 +849,7 @@ public final class HSSFCellStyle impleme
             FontRecord fr = _workbook.createNewFont();
             fr.cloneStyleFrom(
                     source._workbook.getFontRecordAt(
-                            source.getFontIndex()
+                            source.getFontIntIndex()
                     )
             );
 

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Thu Feb 22 22:32:25 
2018
@@ -346,7 +346,7 @@ public final class CellUtil {
         put(properties, FILL_PATTERN, style.getFillPattern());
         put(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
         put(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor());
-        put(properties, FONT, style.getFontIndex());
+        put(properties, FONT, style.getFontIntIndex());
         put(properties, HIDDEN, style.getHidden());
         put(properties, INDENTION, style.getIndention());
         put(properties, LEFT_BORDER_COLOR, style.getLeftBorderColor());

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestAutoSizeColumnTracker.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestAutoSizeColumnTracker.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestAutoSizeColumnTracker.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestAutoSizeColumnTracker.java
 Thu Feb 22 22:32:25 2018
@@ -210,7 +210,7 @@ public class TestAutoSizeColumnTracker {
     
     private static void assumeRequiredFontsAreInstalled(final Workbook 
workbook, final Cell cell) {
         // 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,
                           SheetUtil.canComputeColumnWidth(font));
     }

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheetAutoSizeColumn.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheetAutoSizeColumn.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheetAutoSizeColumn.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheetAutoSizeColumn.java
 Thu Feb 22 22:32:25 2018
@@ -350,7 +350,7 @@ public class TestSXSSFSheetAutoSizeColum
     
     private static void assumeRequiredFontsAreInstalled(final Workbook 
workbook, final Cell cell) {
         // 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,
                           SheetUtil.canComputeColumnWidth(font));
     }

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java 
Thu Feb 22 22:32:25 2018
@@ -324,7 +324,7 @@ public final class TestXSSFSheet extends
         cellXf.setXfId(1);
         stylesTable.putCellXf(cellXf);
         XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);
-        assertEquals(1, cellStyle.getFontIndex());
+        assertEquals(1, cellStyle.getFontIntIndex());
 
         sheet.setDefaultColumnStyle(3, cellStyle);
         assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Thu Feb 
22 22:32:25 2018
@@ -1017,7 +1017,7 @@ public final class TestBugs extends Base
     @Test
     public void bug45338() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals(4, wb.getNumberOfFonts());
+        assertEquals(4, wb.getNumberOfFontsAsInt());
 
         HSSFSheet s = wb.createSheet();
         s.createRow(0);
@@ -1025,7 +1025,7 @@ public final class TestBugs extends Base
         s.getRow(0).createCell(0);
         s.getRow(1).createCell(0);
 
-        assertEquals(4, wb.getNumberOfFonts());
+        assertEquals(4, wb.getNumberOfFontsAsInt());
 
         HSSFFont f1 = wb.getFontAt((short) 0);
         assertFalse(f1.getBold());
@@ -1033,19 +1033,19 @@ public final class TestBugs extends Base
         // 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)
         );
         assertEquals(
-                wb.getFontAt((short) 2),
-                wb.getFontAt((short) 2)
+                wb.getFontAt(2),
+                wb.getFontAt(2)
         );
         assertTrue(
-                wb.getFontAt((short) 0)
+                wb.getFontAt(0)
                         !=
-                        wb.getFontAt((short) 2)
+                        wb.getFontAt(2)
         );
 
         // Look for a new font we have
@@ -1058,10 +1058,10 @@ public final class TestBugs extends Base
         );
 
         HSSFFont nf = wb.createFont();
-        assertEquals(5, wb.getNumberOfFonts());
+        assertEquals(5, wb.getNumberOfFontsAsInt());
 
         assertEquals(5, nf.getIndex());
-        assertEquals(nf, wb.getFontAt((short) 5));
+        assertEquals(nf, wb.getFontAt(5));
 
         nf.setBold(false);
         nf.setColor((short) 123);
@@ -1072,8 +1072,8 @@ public final class TestBugs extends Base
         nf.setTypeOffset((short) 2);
         nf.setUnderline((byte) 2);
 
-        assertEquals(5, wb.getNumberOfFonts());
-        assertEquals(nf, wb.getFontAt((short) 5));
+        assertEquals(5, wb.getNumberOfFontsAsInt());
+        assertEquals(nf, wb.getFontAt(5));
 
         // Find it now
         assertNotNull(
@@ -3130,20 +3130,20 @@ public final class TestBugs extends Base
 
             Cell cell = row.getCell(1);
             CellStyle style = cell.getCellStyle();
-            assertEquals(26, style.getFontIndex());
+            assertEquals(26, style.getFontIntIndex());
 
             row = sheet.getRow(3);
             cell = row.getCell(1);
             style = cell.getCellStyle();
-            assertEquals(28, style.getFontIndex());
+            assertEquals(28, style.getFontIntIndex());
 
             // check the two fonts
-            HSSFFont font = wb.getFontAt((short) 26);
+            HSSFFont font = wb.getFontAt(26);
             assertTrue(font.getBold());
             assertEquals(10, font.getFontHeightInPoints());
             assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", 
font.getFontName());
 
-            font = wb.getFontAt((short) 28);
+            font = wb.getFontAt(28);
             assertTrue(font.getBold());
             assertEquals(10, font.getFontHeightInPoints());
             assertEquals("\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF", 
font.getFontName());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java?rev=1825103&r1=1825102&r2=1825103&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java Thu 
Feb 22 22:32:25 2018
@@ -101,9 +101,9 @@ public abstract class BaseTestFont {
         font.setStrikeout(true);
         font.setColor(IndexedColors.YELLOW.getIndex());
         font.setFontName("Courier");
-        short font1Idx = font.getIndex();
+        int font1Idx = font.getIndexAsInt();
         wb1.createCellStyle().setFont(font);
-        assertEquals(num0 + 1, wb1.getNumberOfFonts());
+        assertEquals(num0 + 1, wb1.getNumberOfFontsAsInt());
 
         CellStyle cellStyleTitle=wb1.createCellStyle();
         cellStyleTitle.setFont(font);
@@ -114,8 +114,8 @@ public abstract class BaseTestFont {
         wb1.close();
         s1 = wb2.getSheetAt(0);
 
-        assertEquals(num0 + 1, wb2.getNumberOfFonts());
-        short idx = s1.getRow(0).getCell(0).getCellStyle().getFontIndex();
+        assertEquals(num0 + 1, wb2.getNumberOfFontsAsInt());
+        int idx = s1.getRow(0).getCell(0).getCellStyle().getFontIntIndex();
         Font fnt = wb2.getFontAt(idx);
         assertNotNull(fnt);
         assertEquals(IndexedColors.YELLOW.getIndex(), fnt.getColor());
@@ -125,9 +125,9 @@ public abstract class BaseTestFont {
         Font font2 = wb2.createFont();
         font2.setItalic(true);
         font2.setFontHeightInPoints((short)15);
-        short font2Idx = font2.getIndex();
+        int font2Idx = font2.getIndexAsInt();
         wb2.createCellStyle().setFont(font2);
-        assertEquals(num0 + 2, wb2.getNumberOfFonts());
+        assertEquals(num0 + 2, wb2.getNumberOfFontsAsInt());
 
         // Save and re-load
         Workbook wb3 = _testDataProvider.writeOutAndReadBack(wb2);
@@ -135,7 +135,7 @@ public abstract class BaseTestFont {
         s1 = wb3.getSheetAt(0);
         assertNotNull(s1);
 
-        assertEquals(num0 + 2, wb3.getNumberOfFonts());
+        assertEquals(num0 + 2, wb3.getNumberOfFontsAsInt());
         assertNotNull(wb3.getFontAt(font1Idx));
         assertNotNull(wb3.getFontAt(font2Idx));
 
@@ -150,7 +150,7 @@ public abstract class BaseTestFont {
     @Test
     public final void test45338() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
-        int num0 = wb.getNumberOfFonts();
+        int num0 = wb.getNumberOfFontsAsInt();
 
         Sheet s = wb.createSheet();
         s.createRow(0);
@@ -159,13 +159,13 @@ public abstract class BaseTestFont {
         s.getRow(1).createCell(0);
 
         //default font
-        Font f1 = wb.getFontAt((short)0);
+        Font 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));
 
         // Look for a new font we have
         //  yet to add
@@ -177,8 +177,8 @@ public abstract class BaseTestFont {
         );
 
         Font nf = wb.createFont();
-        short nfIdx = nf.getIndex();
-        assertEquals(num0 + 1, wb.getNumberOfFonts());
+        int nfIdx = nf.getIndexAsInt();
+        assertEquals(num0 + 1, wb.getNumberOfFontsAsInt());
 
         assertSame(nf, wb.getFontAt(nfIdx));
 
@@ -191,11 +191,11 @@ public abstract class BaseTestFont {
         nf.setTypeOffset((short)2);
         nf.setUnderline((byte)2);
 
-        assertEquals(num0 + 1, wb.getNumberOfFonts());
+        assertEquals(num0 + 1, wb.getNumberOfFontsAsInt());
         assertEquals(nf, 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
         assertNotNull(



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to