You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2019/09/14 09:54:11 UTC

svn commit: r1866933 - in /poi/trunk/src: examples/src/org/apache/poi/hssf/view/ examples/src/org/apache/poi/ss/examples/ examples/src/org/apache/poi/ss/examples/html/ java/org/apache/poi/hpsf/ java/org/apache/poi/ss/formula/atp/ java/org/apache/poi/ss...

Author: fanningpj
Date: Sat Sep 14 09:54:11 2019
New Revision: 1866933

URL: http://svn.apache.org/viewvc?rev=1866933&view=rev
Log:
try to avoid casting to int

Modified:
    poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
    poi/trunk/src/java/org/apache/poi/hpsf/Section.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/ParityFunction.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java
    poi/trunk/src/java/org/apache/poi/ss/util/ExpandedDouble.java
    poi/trunk/src/java/org/apache/poi/ss/util/IEEEDouble.java
    poi/trunk/src/java/org/apache/poi/util/HexDump.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/Angles.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java
    poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java

Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java Sat Sep 14 09:54:11 2019
@@ -182,7 +182,7 @@ public class SVSheetTable extends JTable
       Row row = sheet.getRow(i - sheet.getFirstRowNum());
       if (row != null) {
         short h = row.getHeight();
-        int height = (int)Math.round(Math.max(1., h / (res / 70. * 20.) + 3.));
+        int height = Math.toIntExact(Math.round(Math.max(1., h / (res / 70. * 20.) + 3.)));
         System.out.printf("%d: %d (%d @ %d)%n", i, height, h, res);
         setRowHeight(i, height);
       }

Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java Sat Sep 14 09:54:11 2019
@@ -703,7 +703,7 @@ public class ToCSV {
         
         if (converted) {
             System.out.println("Conversion took " + 
-                  (int)((System.currentTimeMillis() - startTime)/1000) + " seconds");
+                  ((System.currentTimeMillis() - startTime)/1000) + " seconds");
         }
     }
 

Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java Sat Sep 14 09:54:11 2019
@@ -399,7 +399,7 @@ public class ToHtml {
      * @return the approximate number of pixels for a typical display
      */
     protected int widthToPixels(final double widthUnits) {
-        return (int) (Math.round(widthUnits * 9 / 256));
+        return Math.toIntExact(Math.round(widthUnits * 9 / 256));
     }
 
     private void printCols(Map<Integer, Integer> widths) {

Modified: poi/trunk/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Section.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Section.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Section.java Sat Sep 14 09:54:11 2019
@@ -182,10 +182,10 @@ public class Section {
         final TreeBidiMap<Long,Long> offset2Id = new TreeBidiMap<>();
         for (int i = 0; i < propertyCount; i++) {
             /* Read the property ID. */
-            long id = (int)leis.readUInt();
+            long id = leis.readUInt();
 
             /* Offset from the section's start. */
-            long off = (int)leis.readUInt();
+            long off = leis.readUInt();
 
             offset2Id.put(off, id);
         }
@@ -196,7 +196,7 @@ public class Section {
         int codepage = -1;
         if (cpOffset != null) {
             /* Read the property's value type. It must be VT_I2. */
-            leis.setReadIndex((int)(this._offset + cpOffset));
+            leis.setReadIndex(Math.toIntExact(this._offset + cpOffset));
             final long type = leis.readUInt();
 
             if (type != Variant.VT_I2) {
@@ -221,7 +221,7 @@ public class Section {
             }
             
             int pLen = propLen(offset2Id, off, size);
-            leis.setReadIndex((int)(this._offset + off));
+            leis.setReadIndex(Math.toIntExact(this._offset + off));
 
             if (id == PropertyIDMap.PID_DICTIONARY) {
                 leis.mark(100000);
@@ -242,7 +242,7 @@ public class Section {
             }
         }
         
-        sectionBytes.write(src, (int)_offset, size);
+        sectionBytes.write(src, Math.toIntExact(_offset), size);
         padSectionBytes();
     }
 
@@ -261,7 +261,7 @@ public class Section {
         Long nextKey = offset2Id.nextKey(entryOffset);
         long begin = entryOffset;
         long end = (nextKey != null) ? nextKey : maxSize;
-        return (int)(end - begin);
+        return Math.toIntExact(end - begin);
     }
 
 
@@ -823,7 +823,7 @@ public class Section {
 
             /* Read the string - Strip 0x00 characters from the end of the string. */
             int cp = (codepage == -1) ? Property.DEFAULT_CODEPAGE : codepage;
-            int nrBytes = (int)((sLength-1) * (cp == CodePageUtil.CP_UNICODE ? 2 : 1));
+            int nrBytes = Math.toIntExact(((sLength-1) * (cp == CodePageUtil.CP_UNICODE ? 2 : 1)));
             if (nrBytes > 0xFFFFFF) {
                 LOG.log(POILogger.WARN, errMsg);
                 isCorrupted = true;
@@ -946,7 +946,7 @@ public class Section {
         for (Property aPa : pa) {
             hashCode += aPa.hashCode();
         }
-        return (int) (hashCode & 0x0ffffffffL);
+        return Math.toIntExact(hashCode & 0x0ffffffffL);
     }
 
 

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/ParityFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/ParityFunction.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/ParityFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/ParityFunction.java Sat Sep 14 09:54:11 2019
@@ -62,6 +62,6 @@ final class ParityFunction implements Fr
 			d = -d;
 		}
 		long v = (long) Math.floor(d);
-		return (int) (v & 0x0001);
+		return Math.toIntExact(v & 0x0001);
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java Sat Sep 14 09:54:11 2019
@@ -354,7 +354,7 @@ public class CellReference {
         if(rowNum > Integer.MAX_VALUE) {
             return false;
         }
-        return isRowWithinRange((int)rowNum, ssVersion);
+        return isRowWithinRange(Math.toIntExact(rowNum), ssVersion);
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/ss/util/ExpandedDouble.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/ExpandedDouble.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/ExpandedDouble.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/ExpandedDouble.java Sat Sep 14 09:54:11 2019
@@ -54,7 +54,7 @@ final class ExpandedDouble {
 	private final int _binaryExponent;
 
 	public ExpandedDouble(long rawBits) {
-		int biasedExp = (int) (rawBits >> 52);
+		int biasedExp = Math.toIntExact(rawBits >> 52);
 		if (biasedExp == 0) {
 			// sub-normal numbers
 			BigInteger frac = BigInteger.valueOf(rawBits).and(BI_FRAC_MASK);

Modified: poi/trunk/src/java/org/apache/poi/ss/util/IEEEDouble.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/IEEEDouble.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/IEEEDouble.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/IEEEDouble.java Sat Sep 14 09:54:11 2019
@@ -39,6 +39,6 @@ final class IEEEDouble {
 	 * @return the top 12 bits (sign and biased exponent value)
 	 */
 	public static int getBiasedExponent(long rawBits) {
-		return (int) ((rawBits & EXPONENT_MASK) >> EXPONENT_SHIFT);
+		return Math.toIntExact((rawBits & EXPONENT_MASK) >> EXPONENT_SHIFT);
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/util/HexDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/HexDump.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/HexDump.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/HexDump.java Sat Sep 14 09:54:11 2019
@@ -401,7 +401,7 @@ public class HexDump {
         char[] buf = new char[nDigits];
         long acc = value;
         for(int i=nDigits-1; i>=0; i--) {
-            int digit = (int)(acc & 0x0F);
+            int digit = Math.toIntExact(acc & 0x0F);
             buf[i] = (char) (digit < 10 ? ('0' + digit) : ('A' + digit - 10));
             acc >>>= 4;
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java Sat Sep 14 09:54:11 2019
@@ -16,9 +16,6 @@
 ==================================================================== */
 package org.apache.poi.openxml4j.util;
 
-import static org.apache.commons.collections4.IteratorUtils.asIterable;
-import static org.apache.commons.collections4.IteratorUtils.asIterator;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Enumeration;
@@ -76,7 +73,9 @@ public class ZipFileZipEntrySource imple
       }
 
       // the opc spec allows case-insensitive filename matching (see #49609)
-      for (final ZipArchiveEntry ze : asIterable(asIterator(zipArchive.getEntries()))) {
+      final Enumeration<ZipArchiveEntry> zipArchiveEntryEnumeration = zipArchive.getEntries();
+      while (zipArchiveEntryEnumeration.hasMoreElements()) {
+         ZipArchiveEntry ze = zipArchiveEntryEnumeration.nextElement();
          if (normalizedPath.equalsIgnoreCase(ze.getName().replace('\\','/'))) {
             return ze;
          }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java Sat Sep 14 09:54:11 2019
@@ -18,11 +18,11 @@ package org.apache.poi.openxml4j.util;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.collections4.IteratorUtils;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 
 /**
@@ -58,7 +58,7 @@ public class ZipInputStreamZipEntrySourc
 
 	@Override
 	public Enumeration<? extends ZipArchiveEntry> getEntries() {
-		return IteratorUtils.asEnumeration(zipEntries.values().iterator());
+		return Collections.enumeration(zipEntries.values());
 	}
 
 	@Override

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/Angles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/Angles.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/Angles.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/Angles.java Sat Sep 14 09:54:11 2019
@@ -27,7 +27,7 @@ public class Angles {
     public static final int OOXML_DEGREE = 60_000;
 
     public static final int degreesToAttribute(double angle) {
-        return (int) (OOXML_DEGREE * angle);
+        return Math.toIntExact(Math.round(OOXML_DEGREE * angle));
     }
 
     public static final double attributeToDegrees(int angle) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java Sat Sep 14 09:54:11 2019
@@ -47,6 +47,6 @@ public class XDDFBulletSizePercent imple
     }
 
     public void setPercent(double value) {
-        percent.setVal((int) (1000 * value));
+        percent.setVal(Math.toIntExact(Math.round(1000 * value)));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java Sat Sep 14 09:54:11 2019
@@ -45,6 +45,6 @@ public class XDDFBulletSizePoints implem
     }
 
     public void setPoints(double value) {
-        points.setVal((int) (100 * value));
+        points.setVal(Math.toIntExact(Math.round(100 * value)));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java Sat Sep 14 09:54:11 2019
@@ -142,7 +142,7 @@ public class XDDFRunProperties {
         } else if (size < 1 || 400 < size) {
             throw new IllegalArgumentException("Minimum inclusive = 1. Maximum inclusive = 400.");
         } else {
-            props.setSz((int) (100 * size));
+            props.setSz((int)(100 * size));
         }
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Sat Sep 14 09:54:11 2019
@@ -542,8 +542,7 @@ public class XMLSlideShow extends POIXML
      */
     @Override
     public XSLFPictureData addPicture(File pict, PictureType format) throws IOException {
-        int length = (int) pict.length();
-        byte[] data = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH);
+        byte[] data = IOUtils.safelyAllocate(pict.length(), MAX_RECORD_LENGTH);
         try (InputStream is = new FileInputStream(pict)) {
             IOUtils.readFully(is, data);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Sat Sep 14 09:54:11 2019
@@ -577,10 +577,10 @@ public abstract class XSLFShape implemen
         // value of 0 or 1000 indicates no background,
         // values 1-999 refer to the index of a fill style within the fillStyleLst element
         // values 1001 and above refer to the index of a background fill style within the bgFillStyleLst element.
-        int idx = (int)fillRef.getIdx();
+        long idx = fillRef.getIdx();
         CTStyleMatrix matrix = theme.getXmlObject().getThemeElements().getFmtScheme();
         final XmlObject styleLst;
-        int childIdx;
+        long childIdx;
         if (idx >= 1 && idx <= 999) {
             childIdx = idx-1;
             styleLst = (isLineStyle) ? matrix.getLnStyleLst() : matrix.getFillStyleLst();
@@ -592,7 +592,7 @@ public abstract class XSLFShape implemen
         }
         XmlCursor cur = styleLst.newCursor();
         XSLFFillProperties fp = null;
-        if (cur.toChild(childIdx)) {
+        if (cur.toChild(Math.toIntExact(childIdx))) {
             fp = XSLFPropertiesDelegate.getFillDelegate(cur.getObject());
         }
         cur.dispose();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Sat Sep 14 09:54:11 2019
@@ -78,7 +78,6 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
 import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 
 /**
  * Represents a single (non-group) shape in a .pptx slide show
@@ -242,7 +241,7 @@ public abstract class XSLFSimpleShape ex
             return null;
         }
         // 1-based index of a line style within the style matrix
-        int idx = (int)lnRef.getIdx();
+        int idx = Math.toIntExact(lnRef.getIdx());
 
         XSLFTheme theme = getSheet().getTheme();
         if (theme == null) {
@@ -359,7 +358,7 @@ public abstract class XSLFSimpleShape ex
                 if (lnRef == null) {
                     return null;
                 }
-                int idx = (int)lnRef.getIdx();
+                int idx = Math.toIntExact(lnRef.getIdx());
                 CTSchemeColor phClr = lnRef.getSchemeClr();
                 if(idx <= 0){
                     return null;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java Sat Sep 14 09:54:11 2019
@@ -216,8 +216,8 @@ public class PPTX2PNG {
                     break;
             }
 
-            final int width = (int) Math.rint(pgsize.getWidth() * scale / lenSide);
-            final int height = (int) Math.rint(pgsize.getHeight() * scale / lenSide);
+            final int width = Math.toIntExact(Math.round(pgsize.getWidth() * scale / lenSide));
+            final int height = Math.toIntExact(Math.round(pgsize.getHeight() * scale / lenSide));
 
 
             for (int slideNo : slidenum) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java Sat Sep 14 09:54:11 2019
@@ -119,7 +119,7 @@ public class CommentsTable extends POIXM
 
     @Override
     public String getAuthor(long authorId) {
-        return comments.getAuthors().getAuthorArray((int)authorId);
+        return comments.getAuthors().getAuthorArray(Math.toIntExact(authorId));
     }
 
     @Override

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java Sat Sep 14 09:54:11 2019
@@ -281,7 +281,7 @@ import org.apache.poi.util.Internal;
             }
         }
         final double width = maxColumnWidths.get(column).getMaxColumnWidth(useMergedCells);
-        return (int) (256*width);
+        return Math.toIntExact(Math.round(256*width));
     }
     
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/OpcOutputStream.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/OpcOutputStream.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/OpcOutputStream.java Sat Sep 14 09:54:11 2019
@@ -85,7 +85,7 @@ class OpcOutputStream extends DeflaterOu
         }
 
         current.size = def.getBytesRead();
-        current.compressedSize = (int) def.getBytesWritten();
+        current.compressedSize = Math.toIntExact(def.getBytesWritten());
         current.crc = crc.getValue();
 
         written += current.compressedSize;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Sat Sep 14 09:54:11 2019
@@ -465,7 +465,8 @@ public final class XSSFCell extends Cell
         if (f == null) {
             return null;
         } else if (f.getT() == STCellFormulaType.SHARED) {
-            return convertSharedFormula((int)f.getSi(), fpb == null ? XSSFEvaluationWorkbook.create(getSheet().getWorkbook()) : fpb);
+            return convertSharedFormula(Math.toIntExact(f.getSi()),
+                    fpb == null ? XSSFEvaluationWorkbook.create(getSheet().getWorkbook()) : fpb);
         } else {
             return f.getStringValue();
         }
@@ -614,7 +615,7 @@ public final class XSSFCell extends Cell
         XSSFCellStyle style = null;
         if(_stylesSource.getNumCellStyles() > 0){
             long idx = _cell.isSetS() ? _cell.getS() : 0;
-            style = _stylesSource.getStyleAt((int)idx);
+            style = _stylesSource.getStyleAt(Math.toIntExact(idx));
         }
         return style;
     }
@@ -1224,7 +1225,7 @@ public final class XSSFCell extends Cell
         }
 
         CalculationChain calcChain = getSheet().getWorkbook().getCalculationChain();
-        int sheetId = (int)getSheet().sheet.getSheetId();
+        int sheetId = Math.toIntExact(getSheet().sheet.getSheetId());
     
         //remove the reference in the calculation chain
         if(calcChain != null) calcChain.removeItem(sheetId, getReference());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Sat Sep 14 09:54:11 2019
@@ -236,7 +236,7 @@ public class XSSFCellStyle implements Ce
     public BorderStyle getBorderBottom() {
         if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
         STBorderStyle.Enum ptrn = ct.isSetBottom() ? ct.getBottom().getStyle() : null;
         if (ptrn == null) {
@@ -254,7 +254,7 @@ public class XSSFCellStyle implements Ce
     public BorderStyle getBorderLeft() {
         if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
         STBorderStyle.Enum ptrn = ct.isSetLeft() ? ct.getLeft().getStyle() : null;
         if (ptrn == null) {
@@ -270,7 +270,7 @@ public class XSSFCellStyle implements Ce
     public BorderStyle getBorderRight() {
         if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
         STBorderStyle.Enum ptrn = ct.isSetRight() ? ct.getRight().getStyle() : null;
         if (ptrn == null) {
@@ -288,7 +288,7 @@ public class XSSFCellStyle implements Ce
     public BorderStyle getBorderTop() {
         if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
         STBorderStyle.Enum ptrn = ct.isSetTop() ? ct.getTop().getStyle() : null;
         if (ptrn == null) {
@@ -323,7 +323,7 @@ public class XSSFCellStyle implements Ce
     public XSSFColor getBottomBorderXSSFColor() {
         if(!_cellXf.getApplyBorder()) return null;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         XSSFCellBorder border = _stylesSource.getBorderAt(idx);
 
         return border.getBorderColor(BorderSide.BOTTOM);
@@ -549,7 +549,7 @@ public class XSSFCellStyle implements Ce
     public XSSFColor getLeftBorderXSSFColor() {
         if(!_cellXf.getApplyBorder()) return null;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         XSSFCellBorder border = _stylesSource.getBorderAt(idx);
 
         return border.getBorderColor(BorderSide.LEFT);
@@ -592,7 +592,7 @@ public class XSSFCellStyle implements Ce
     public XSSFColor getRightBorderXSSFColor() {
         if(!_cellXf.getApplyBorder()) return null;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         XSSFCellBorder border = _stylesSource.getBorderAt(idx);
 
         return border.getBorderColor(BorderSide.RIGHT);
@@ -644,7 +644,7 @@ public class XSSFCellStyle implements Ce
     public XSSFColor getTopBorderXSSFColor() {
         if(!_cellXf.getApplyBorder()) return null;
 
-        int idx = (int)_cellXf.getBorderId();
+        int idx = Math.toIntExact(_cellXf.getBorderId());
         XSSFCellBorder border = _stylesSource.getBorderAt(idx);
 
         return border.getBorderColor(BorderSide.TOP);
@@ -960,7 +960,7 @@ public class XSSFCellStyle implements Ce
     private CTBorder getCTBorder(){
         CTBorder ct;
         if(_cellXf.getApplyBorder()) {
-            int idx = (int)_cellXf.getBorderId();
+            int idx = Math.toIntExact(_cellXf.getBorderId());
             XSSFCellBorder cf = _stylesSource.getBorderAt(idx);
 
             ct = (CTBorder)cf.getCTBorder().copy();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java Sat Sep 14 09:54:11 2019
@@ -256,7 +256,7 @@ public class XSSFClientAnchor extends XS
     }
 
     public int getDx1() {
-        return (int) getCell1().getColOff();
+        return Math.toIntExact(getCell1().getColOff());
     }
 
     /**
@@ -268,7 +268,7 @@ public class XSSFClientAnchor extends XS
     }
 
     public int getDy1() {
-        return (int) getCell1().getRowOff();
+        return Math.toIntExact(getCell1().getRowOff());
     }
 
     /**
@@ -280,7 +280,7 @@ public class XSSFClientAnchor extends XS
     }
 
     public int getDy2() {
-        return (int) getCell2().getRowOff();
+        return Math.toIntExact(getCell2().getRowOff());
     }
 
     /**
@@ -292,7 +292,7 @@ public class XSSFClientAnchor extends XS
     }
 
     public int getDx2() {
-        return (int) getCell2().getColOff();
+        return Math.toIntExact(getCell2().getColOff());
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Sat Sep 14 09:54:11 2019
@@ -407,7 +407,7 @@ public class XSSFRow implements Row, Com
      */
     @Override
     public int getRowNum() {
-        return (int) (_row.getR() - 1);
+        return Math.toIntExact(_row.getR() - 1);
     }
 
     /**
@@ -469,7 +469,7 @@ public class XSSFRow implements Row, Com
 
        StylesTable stylesSource = getSheet().getWorkbook().getStylesSource();
        if(stylesSource.getNumCellStyles() > 0) {
-           return stylesSource.getStyleAt((int)_row.getS());
+           return stylesSource.getStyleAt(Math.toIntExact(_row.getS()));
        } else {
           return null;
        }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sat Sep 14 09:54:11 2019
@@ -559,7 +559,7 @@ public class XSSFSheet extends POIXMLDoc
             if (width > maxColumnWidth) {
                 width = maxColumnWidth;
             }
-            setColumnWidth(column, (int)(width));
+            setColumnWidth(column, Math.toIntExact(Math.round(width)));
             columnHelper.setColBestFit(column, true);
         }
     }
@@ -900,7 +900,7 @@ public class XSSFSheet extends POIXMLDoc
         CTBreak[] brkArray = ctPageBreak.getBrkArray();
         int[] breaks = new int[brkArray.length];
         for (int i = 0 ; i < brkArray.length ; i++) {
-            breaks[i] = (int) brkArray[i].getId() - 1;
+            breaks[i] = Math.toIntExact(brkArray[i].getId() - 1);
         }
         return breaks;
     }
@@ -944,7 +944,7 @@ public class XSSFSheet extends POIXMLDoc
     public int getColumnWidth(int columnIndex) {
         CTCol col = columnHelper.getColumn(columnIndex, false);
         double width = col == null || !col.isSetWidth() ? getDefaultColumnWidth() : col.getWidth();
-        return (int)(width*256);
+        return Math.toIntExact(Math.round(width*256));
     }
 
     /**
@@ -973,7 +973,7 @@ public class XSSFSheet extends POIXMLDoc
     @Override
     public int getDefaultColumnWidth() {
         CTSheetFormatPr pr = worksheet.getSheetFormatPr();
-        return pr == null ? 8 : (int)pr.getBaseColWidth();
+        return pr == null ? 8 : Math.toIntExact(pr.getBaseColWidth());
     }
 
     /**
@@ -1686,7 +1686,7 @@ public class XSSFSheet extends POIXMLDoc
             //col must exist
             short outlineLevel=col.getOutlineLevel();
             col.setOutlineLevel((short)(outlineLevel+1));
-            index=(int)col.getMax();
+            index = Math.toIntExact(col.getMax());
         }
         worksheet.setColsArray(0,ctCols);
         setSheetFormatPrOutlineLevelCol();
@@ -2256,7 +2256,7 @@ public class XSSFSheet extends POIXMLDoc
             // split to 3 records
             CTCol ciMid = columnHelper.cloneCol(cols, ci);
             CTCol ciEnd = columnHelper.cloneCol(cols, ci);
-            int lastcolumn = (int) ciMax;
+            int lastcolumn = Math.toIntExact(ciMax);
 
             ci.setMax(targetColumnIx - 1);
 
@@ -2308,7 +2308,7 @@ public class XSSFSheet extends POIXMLDoc
             }
             idx++;
         }
-        return (int) columnInfo.getMax();
+        return Math.toIntExact(columnInfo.getMax());
     }
 
     private boolean isAdjacentBefore(CTCol col, CTCol otherCol) {
@@ -2363,7 +2363,7 @@ public class XSSFSheet extends POIXMLDoc
         CTCol col = columnHelper.getColumn(columnIndex, false);
         int colInfoIx = columnHelper.getIndexOfColumn(cols, col);
 
-        int idx = findColInfoIdx((int) col.getMax(), colInfoIx);
+        int idx = findColInfoIdx(Math.toIntExact(col.getMax()), colInfoIx);
         if (idx == -1) {
             return;
         }
@@ -2408,7 +2408,7 @@ public class XSSFSheet extends POIXMLDoc
         }
         // Write collapse flag (stored in a single col info record after this
         // outline group)
-        setColumn((int) columnInfo.getMax() + 1, null, null,
+        setColumn(Math.toIntExact(columnInfo.getMax() + 1), null, null,
                 Boolean.FALSE, Boolean.FALSE);
     }
 
@@ -3286,7 +3286,7 @@ public class XSSFSheet extends POIXMLDoc
             if (col != null) {
                 short outlineLevel = col.getOutlineLevel();
                 col.setOutlineLevel((short) (outlineLevel - 1));
-                index = (int) col.getMax();
+                index = Math.toIntExact(col.getMax());
 
                 if (col.getOutlineLevel() <= 0) {
                     int colIndex = columnHelper.getIndexOfColumn(cols, col);
@@ -3492,7 +3492,7 @@ public class XSSFSheet extends POIXMLDoc
             //  the sheet has (i.e. sheet 1 -> comments 1)
             try {
                 sheetComments = (CommentsTable)createRelationship(
-                        XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), (int)sheet.getSheetId());
+                        XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), Math.toIntExact(sheet.getSheetId()));
             } catch(PartAlreadyExistsException e) {
                 // Technically a sheet doesn't need the same number as
                 //  it's comments, and clearly someone has already pinched
@@ -3563,7 +3563,7 @@ public class XSSFSheet extends POIXMLDoc
                 sf.setRef(effectiveRef);
             }
 
-            sharedFormulas.put((int)f.getSi(), sf);
+            sharedFormulas.put(Math.toIntExact(f.getSi()), sf);
         }
         if (f != null && f.getT() == STCellFormulaType.ARRAY && f.getRef() != null) {
             arrayFormulas.add(CellRangeAddress.valueOf(f.getRef()));
@@ -4649,7 +4649,7 @@ public class XSSFSheet extends POIXMLDoc
                                     nextCell.getColumnIndex(), ref.getLastColumn());
                             nextF.setRef(nextRef.formatAsString());
 
-                            sharedFormulas.put((int)nextF.getSi(), nextF);
+                            sharedFormulas.put(Math.toIntExact(nextF.getSi()), nextF);
                             break DONE;
                         }
                     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java Sat Sep 14 09:54:11 2019
@@ -109,7 +109,7 @@ import java.util.List;
                     if (shiftedFormula != null) {
                         f.setStringValue(shiftedFormula);
                         if(f.getT() == STCellFormulaType.SHARED){
-                            int si = (int)f.getSi();
+                            int si = Math.toIntExact(f.getSi());
                             CTCellFormula sf = sheet.getSharedFormula(si);
                             sf.setStringValue(shiftedFormula);
                             updateRefInCTCellFormula(row, formulaShifter, sf);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java?rev=1866933&r1=1866932&r2=1866933&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java Sat Sep 14 09:54:11 2019
@@ -20,9 +20,10 @@ package org.apache.poi.ss.util;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertArrayEquals;
+
+import java.util.Iterator;
 import java.util.Set;
 import java.util.HashSet;
-import org.apache.commons.collections4.IteratorUtils;
 
 /**
  * Tests CellRangeUtil.
@@ -76,7 +77,9 @@ public final class TestCellRangeUtil {
     private static Set<CellAddress> getCellAddresses(CellRangeAddress[] ranges) {
         final Set<CellAddress> set = new HashSet<>();
         for (final CellRangeAddress range : ranges) {
-            set.addAll(IteratorUtils.toList(range.iterator()));
+            for (Iterator<CellAddress> iter = range.iterator(); iter.hasNext(); ) {
+                set.add(iter.next());
+            }
         }
         return set;
     }



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