From 9808fd501571043484bae8fb890722564c81ff0c Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 14 Sep 2019 11:42:42 +0000 Subject: [PATCH] try to fix build failure git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1866941 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/format/CellNumberFormatter.java | 2 +- .../poi/hemf/record/emf/HemfComment.java | 26 +++++++++---------- .../apache/poi/hemf/record/emf/HemfMisc.java | 3 ++- .../hemf/record/emf/HemfRecordIterator.java | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java index 2511917e25..6ab581d52d 100644 --- a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java @@ -304,7 +304,7 @@ public class CellNumberFormatter extends CellFormatter { } private static int maxValue(List s) { - return (int) Math.round(Math.pow(10, s.size()) - 1); + return Math.toIntExact(Math.round(Math.pow(10, s.size()) - 1)); } private List specialsFor(int pos, int takeFirst) { diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java index 514923c679..4b572daaca 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java @@ -198,9 +198,9 @@ public class HemfComment { // Valid comment identifier values are listed in the following table. // // If this field contains any other value, the comment record MUST be an EMR_COMMENT record - final int commentIdentifier = Math.toIntExact(leis.readUInt()); + final long commentIdentifier = leis.readUInt(); // A 32-bit unsigned integer that identifies the type of public comment record. - final int publicCommentIdentifier = Math.toIntExact(leis.readUInt()); + final long publicCommentIdentifier = leis.readUInt(); final boolean isEmfPublic = (commentIdentifier == HemfCommentRecordType.emfPublic.id); leis.reset(); @@ -322,14 +322,14 @@ public class HemfComment { public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { final int startIdx = leis.getReadIndex(); - final int commentIdentifier = Math.toIntExact(leis.readUInt()); + final long commentIdentifier = leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final int publicCommentIdentifier = Math.toIntExact(leis.readUInt()); + final long publicCommentIdentifier = leis.readUInt(); assert(publicCommentIdentifier == HemfCommentRecordType.emfBeginGroup.id); HemfDraw.readRectL(leis, bounds); // The number of Unicode characters in the optional description string that follows. - int nDescription = Math.toIntExact(leis.readUInt()); + long nDescription = leis.readUInt(); byte[] buf = IOUtils.safelyAllocate(nDescription * 2L, MAX_RECORD_LENGTH); leis.readFully(buf); @@ -365,9 +365,9 @@ public class HemfComment { public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { final int startIdx = leis.getReadIndex(); - final int commentIdentifier = Math.toIntExact(leis.readUInt()); + final long commentIdentifier = leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final int publicCommentIdentifier = Math.toIntExact(leis.readUInt()); + final long publicCommentIdentifier = leis.readUInt(); assert(publicCommentIdentifier == HemfCommentRecordType.emfEndGroup.id); return leis.getReadIndex()-startIdx; } @@ -391,15 +391,15 @@ public class HemfComment { public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { final int startIdx = leis.getReadIndex(); - final int commentIdentifier = Math.toIntExact(leis.readUInt()); + final long commentIdentifier = leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final int publicCommentIdentifier = Math.toIntExact(leis.readUInt()); + final long publicCommentIdentifier = leis.readUInt(); assert(publicCommentIdentifier == HemfCommentRecordType.emfMultiFormats.id); HemfDraw.readRectL(leis, bounds); // A 32-bit unsigned integer that specifies the number of graphics formats contained in this record. - int countFormats = Math.toIntExact(leis.readUInt()); - for (int i=0; i { long remBytes = recordSize-HEADER_SIZE; long readBytes = record.init(stream, remBytes, recordId); assert (readBytes <= remBytes); - stream.skipFully((int)(remBytes-readBytes)); + stream.skipFully(Math.toIntExact(remBytes-readBytes)); } catch (IOException|RuntimeException e) { throw new RecordFormatException(e); } -- 2.39.5