poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1721930 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/usermodel/ java/org/apache/poi/ss/util/ ooxml/java/org/apache/poi/xssf/streaming/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/...
Date Mon, 28 Dec 2015 14:50:54 GMT
Author: onealj
Date: Mon Dec 28 14:50:54 2015
New Revision: 1721930

URL: http://svn.apache.org/viewvc?rev=1721930&view=rev
Log:
bug 58775: use short for data format index, int for cell style index

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Mon Dec 28 14:50:54
2015
@@ -1322,11 +1322,10 @@ public final class HSSFWorkbook extends
      * get the number of styles the workbook contains
      * @return count of cell styles
      */
-
     @Override
-    public short getNumCellStyles()
+    public int getNumCellStyles()
     {
-        return (short) workbook.getNumExFormats();
+        return workbook.getNumExFormats();
     }
 
     /**
@@ -1335,10 +1334,10 @@ public final class HSSFWorkbook extends
      * @return HSSFCellStyle object at the index
      */
     @Override
-    public HSSFCellStyle getCellStyleAt(short idx)
+    public HSSFCellStyle getCellStyleAt(int idx)
     {
         ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
-        HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this);
+        HSSFCellStyle style = new HSSFCellStyle((short)idx, xfr, this);
 
         return style;
     }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Workbook.java Mon Dec 28 14:50:54 2015
@@ -344,7 +344,7 @@ public interface Workbook extends Closea
      *
      * @return count of cell styles
      */
-    short getNumCellStyles();
+    int getNumCellStyles();
 
     /**
      * Get the cell style object at the given index
@@ -352,7 +352,7 @@ public interface Workbook extends Closea
      * @param idx  index within the set of styles (0-based)
      * @return CellStyle object at the index
      */
-    CellStyle getCellStyleAt(short idx);
+    CellStyle getCellStyleAt(int idx);
 
     /**
      * Write out this workbook to an Outputstream.

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=1721930&r1=1721929&r2=1721930&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 Mon Dec 28 14:50:54 2015
@@ -189,9 +189,9 @@ public final class CellUtil {
 
 		// index seems like what index the cellstyle is in the list of styles for a workbook.
 		// not good to compare on!
-		short numberCellStyles = workbook.getNumCellStyles();
+		int numberCellStyles = workbook.getNumCellStyles();
 
-		for (short i = 0; i < numberCellStyles; i++) {
+		for (int i = 0; i < numberCellStyles; i++) {
 			CellStyle wbStyle = workbook.getCellStyleAt(i);
 			Map<String, Object> wbStyleMap = getFormatProperties(wbStyle);
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java Mon Dec 28 14:50:54
2015
@@ -877,7 +877,7 @@ public class SXSSFWorkbook implements Wo
      * @return count of cell styles
      */
     @Override
-    public short getNumCellStyles()
+    public int getNumCellStyles()
     {
         return _wb.getNumCellStyles();
     }
@@ -889,7 +889,7 @@ public class SXSSFWorkbook implements Wo
      * @return CellStyle object at the index
      */
     @Override
-    public CellStyle getCellStyleAt(short idx)
+    public CellStyle getCellStyleAt(int idx)
     {
         return _wb.getCellStyleAt(idx);
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Mon Dec 28 14:50:54
2015
@@ -859,16 +859,6 @@ public class XSSFWorkbook extends POIXML
      * @param idx  index within the set of styles
      * @return XSSFCellStyle object at the index
      */
-    @Override
-    public XSSFCellStyle getCellStyleAt(short idx) {
-        return getCellStyleAt(idx&0xffff);
-    }
-    /**
-     * Get the cell style object at the given index
-     *
-     * @param idx  index within the set of styles
-     * @return XSSFCellStyle object at the index
-     */
     public XSSFCellStyle getCellStyleAt(int idx) {
         return stylesSource.getStyleAt(idx);
     }
@@ -931,9 +921,8 @@ public class XSSFWorkbook extends POIXML
      *
      * @return count of cell styles
      */
-    @Override
-    public short getNumCellStyles() {
-        return (short) (stylesSource).getNumCellStyles();
+    public int getNumCellStyles() {
+        return stylesSource.getNumCellStyles();
     }
 
     /**

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Mon Dec
28 14:50:54 2015
@@ -2507,6 +2507,7 @@ public final class TestXSSFBugs extends
             XSSFCellStyle style = wb.createCellStyle();
             assertEquals(i, style.getUIndex());
         }
+        assertEquals(numStyles, wb.getNumCellStyles());
 
         // avoid OOM in gump run
         File file = XSSFTestDataSamples.writeOutAndClose(wb, "bug57880");
@@ -2522,6 +2523,7 @@ public final class TestXSSFBugs extends
         //Assume identical cell styles aren't consolidated
         //If XSSFWorkbooks ever implicitly optimize/consolidate cell styles (such as when
the workbook is written to disk)
         //then this unit test should be updated
+        assertEquals(numStyles, wb.getNumCellStyles());
         for (int i=1; i<numStyles; i++) {
             XSSFCellStyle style = wb.getCellStyleAt(i);
             assertNotNull(style);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Mon
Dec 28 14:50:54 2015
@@ -1019,9 +1019,9 @@ public class TestXSSFCellStyle {
     }
 
     public static void copyStyles(Workbook reference, Workbook target) {
-        final short numberOfStyles = reference.getNumCellStyles();
+        final int numberOfStyles = reference.getNumCellStyles();
         // don't copy default style (style index 0)
-        for (short i = 1; i < numberOfStyles; i++) {
+        for (int i = 1; i < numberOfStyles; i++) {
             final CellStyle referenceStyle = reference.getCellStyleAt(i);
             final CellStyle targetStyle = target.createCellStyle();
             targetStyle.cloneStyleFrom(referenceStyle);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=1721930&r1=1721929&r2=1721930&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Mon
Dec 28 14:50:54 2015
@@ -225,9 +225,8 @@ public final class TestXSSFWorkbook exte
 	public void getNumCellStyles() throws IOException{
 	 	XSSFWorkbook workbook = new XSSFWorkbook();
 	 	try {
-    		short i = workbook.getNumCellStyles();
     		//get default cellStyles
-    		assertEquals(1, i);
+    		assertEquals(1, workbook.getNumCellStyles());
 	 	} finally {
 	 	    workbook.close();
 	 	}

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=1721930&r1=1721929&r2=1721930&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 Mon Dec 28 14:50:54
2015
@@ -2006,7 +2006,7 @@ public final class TestBugs extends Base
     @Test
     public void bug49751() throws Exception {
         HSSFWorkbook wb = openSample("49751.xls");
-        short numCellStyles = wb.getNumCellStyles();
+        int numCellStyles = wb.getNumCellStyles();
         List<String> namedStyles = Arrays.asList(
                 "20% - Accent1", "20% - Accent2", "20% - Accent3", "20% - Accent4", "20%
- Accent5",
                 "20% - Accent6", "40% - Accent1", "40% - Accent2", "40% - Accent3", "40%
- Accent4",
@@ -2017,7 +2017,7 @@ public final class TestBugs extends Base
                 "Neutral", "Note", "Output", "Title", "Total", "Warning Text");
 
         List<String> collecteddStyles = new ArrayList<String>();
-        for (short i = 0; i < numCellStyles; i++) {
+        for (int i = 0; i < numCellStyles; i++) {
             HSSFCellStyle cellStyle = wb.getCellStyleAt(i);
             String styleName = cellStyle.getUserStyleName();
             if (styleName != null) {



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


Mime
View raw message