diff options
author | PJ Fanning <fanningpj@apache.org> | 2019-09-14 14:40:47 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2019-09-14 14:40:47 +0000 |
commit | 93b992712a4618918de2e6f247ddeb54a6b2a2f1 (patch) | |
tree | 2ec70c5b2212a5129cd96c1aecdb1903c0ccc805 | |
parent | c109245eca89fcff4339a598c87d53c178c8b3fc (diff) | |
download | poi-93b992712a4618918de2e6f247ddeb54a6b2a2f1.tar.gz poi-93b992712a4618918de2e6f247ddeb54a6b2a2f1.zip |
revert hemf changes due to broken test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1866948 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 21 insertions, 21 deletions
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 4b572daaca..70df41135a 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 @@ -104,7 +104,7 @@ public class HemfComment { @Override public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException { int startIdx = leis.getReadIndex(); - data = new EmfCommentDataIterator(leis, Math.toIntExact(recordSize), true).next(); + data = new EmfCommentDataIterator(leis, (int)recordSize, true).next(); return leis.getReadIndex()-startIdx; } @@ -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 long commentIdentifier = leis.readUInt(); + final int commentIdentifier = (int)leis.readUInt(); // A 32-bit unsigned integer that identifies the type of public comment record. - final long publicCommentIdentifier = leis.readUInt(); + final int publicCommentIdentifier = (int)leis.readUInt(); final boolean isEmfPublic = (commentIdentifier == HemfCommentRecordType.emfPublic.id); leis.reset(); @@ -211,7 +211,7 @@ public class HemfComment { final EmfCommentData record = commentType.constructor.get(); long readBytes = record.init(leis, dataSize); - final int skipBytes = Math.toIntExact(recordSize-4-readBytes); + final int skipBytes = (int)(recordSize-4-readBytes); assert (skipBytes >= 0); leis.skipFully(skipBytes); @@ -286,7 +286,7 @@ public class HemfComment { long startIdx = leis.getReadIndex(); int commentIdentifier = leis.readInt(); assert (commentIdentifier == HemfCommentRecordType.emfPlus.id); - new HemfPlusRecordIterator(leis, Math.toIntExact(dataSize-LittleEndianConsts.INT_SIZE)).forEachRemaining(records::add); + new HemfPlusRecordIterator(leis, (int)dataSize-LittleEndianConsts.INT_SIZE).forEachRemaining(records::add); return leis.getReadIndex()-startIdx; } @@ -322,14 +322,14 @@ public class HemfComment { public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { final int startIdx = leis.getReadIndex(); - final long commentIdentifier = leis.readUInt(); + final int commentIdentifier = (int)leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final long publicCommentIdentifier = leis.readUInt(); + final int publicCommentIdentifier = (int)leis.readUInt(); assert(publicCommentIdentifier == HemfCommentRecordType.emfBeginGroup.id); HemfDraw.readRectL(leis, bounds); // The number of Unicode characters in the optional description string that follows. - long nDescription = leis.readUInt(); + int nDescription = (int)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 long commentIdentifier = leis.readUInt(); + final int commentIdentifier = (int)leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final long publicCommentIdentifier = leis.readUInt(); + final int publicCommentIdentifier = (int)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 long commentIdentifier = leis.readUInt(); + final int commentIdentifier = (int)leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final long publicCommentIdentifier = leis.readUInt(); + final int publicCommentIdentifier = (int)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. - long countFormats = leis.readUInt(); - for (long pos = 0; pos < countFormats; pos++) { + int countFormats = (int)leis.readUInt(); + for (int i=0; i<countFormats; i++) { EmfCommentDataFormat fmt = new EmfCommentDataFormat(); long readBytes = fmt.init(leis, dataSize, startIdx); formats.add(fmt); @@ -533,9 +533,9 @@ public class HemfComment { @Override public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { final int startIdx = leis.getReadIndex(); - final long commentIdentifier = leis.readUInt(); + final int commentIdentifier = (int)leis.readUInt(); assert(commentIdentifier == HemfCommentRecordType.emfPublic.id); - final long publicCommentIdentifier = leis.readUInt(); + final int publicCommentIdentifier = (int)leis.readUInt(); assert(publicCommentIdentifier == HemfCommentRecordType.emfWMF.id); // A 16-bit unsigned integer that specifies the WMF metafile version in terms @@ -553,7 +553,7 @@ public class HemfComment { // A 32-bit unsigned integer that specifies the size, in bytes, of the // WMF metafile in the WinMetafile field. - int winMetafileSize = Math.toIntExact(leis.readUInt()); + int winMetafileSize = (int)leis.readUInt(); wmfData = IOUtils.safelyAllocate(winMetafileSize, MAX_RECORD_LENGTH); // some emf comments are truncated, so we don't use readFully here @@ -586,7 +586,8 @@ public class HemfComment { } @Override - public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException { + public long init(final LittleEndianInputStream leis, final long dataSize) + throws IOException { throw new RecordFormatException("UNICODE_STRING/UNICODE_END values are reserved in CommentPublic records"); } diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java index 1e037c0590..e32fde84e9 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.function.Function; import java.util.function.Supplier; -import org.apache.commons.math3.util.ArithmeticUtils; import org.apache.poi.hemf.draw.HemfDrawProperties; import org.apache.poi.hemf.draw.HemfGraphics; import org.apache.poi.hwmf.draw.HwmfDrawProperties; @@ -901,7 +900,7 @@ public class HemfMisc { // contains a DIB. int cbBits = (int) leis.readUInt(); - int size = ArithmeticUtils.mulAndCheck(6, LittleEndianConsts.INT_SIZE); + int size = 6 * LittleEndianConsts.INT_SIZE; size += readBitmap(leis, bitmap, startIdx, offBmi, cbBmi, offBits, cbBits); diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java index da7b1112c7..dfa68670e1 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java @@ -75,7 +75,7 @@ public class HemfRecordIterator implements Iterator<HemfRecord> { long remBytes = recordSize-HEADER_SIZE; long readBytes = record.init(stream, remBytes, recordId); assert (readBytes <= remBytes); - stream.skipFully(Math.toIntExact(remBytes-readBytes)); + stream.skipFully((int)(remBytes-readBytes)); } catch (IOException|RuntimeException e) { throw new RecordFormatException(e); } |