aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-04-20 21:28:34 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-04-20 21:28:34 +0000
commit948d4a3574511368f2769c403c030fc69d4687f3 (patch)
tree11d083d1a697b84d2e3a38734a7602f367fb2856 /src/scratchpad
parent65c8c6cd11803da23d027de073784595347e692a (diff)
downloadpoi-948d4a3574511368f2769c403c030fc69d4687f3.tar.gz
poi-948d4a3574511368f2769c403c030fc69d4687f3.zip
Sonar fix - "Cast one of the operands of this addition operation to a 'long'/'double'"
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876767 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java14
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java18
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java6
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java6
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java4
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java6
-rw-r--r--src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java10
-rw-r--r--src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java4
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java4
21 files changed, 51 insertions, 51 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java b/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java
index ad8e13cd56..fa577ad2e9 100644
--- a/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java
+++ b/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java
@@ -38,7 +38,7 @@ public class StreamStore { // TODO - instantiable superclass
}
protected void prependContentsWith(byte[] b) {
- byte[] newContents = IOUtils.safelyAllocate(contents.length + b.length, MAX_RECORD_LENGTH);
+ byte[] newContents = IOUtils.safelyAllocate(contents.length + (long)b.length, MAX_RECORD_LENGTH);
System.arraycopy(b, 0, newContents, 0, b.length);
System.arraycopy(contents, 0, newContents, b.length, contents.length);
contents = newContents;
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 228cfd285f..4b1060b7bd 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
@@ -115,7 +115,7 @@ public class HemfComment {
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
- int startIdx = leis.getReadIndex();
+ long startIdx = leis.getReadIndex();
data = new EmfCommentDataIterator(leis, (int)recordSize, true).next();
return leis.getReadIndex()-startIdx;
}
@@ -299,7 +299,7 @@ public class HemfComment {
@Override
public long init(final LittleEndianInputStream leis, final long dataSize)
throws IOException {
- final int startIdx = leis.getReadIndex();
+ final long startIdx = leis.getReadIndex();
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfPlus);
new HemfPlusRecordIterator(leis, (int)dataSize-LittleEndianConsts.INT_SIZE).forEachRemaining(records::add);
return leis.getReadIndex()-startIdx;
@@ -339,7 +339,7 @@ public class HemfComment {
@Override
public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
- final int startIdx = leis.getReadIndex();
+ final long startIdx = leis.getReadIndex();
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfBeginGroup);
HemfDraw.readRectL(leis, bounds);
@@ -380,7 +380,7 @@ public class HemfComment {
@Override
public long init(final LittleEndianInputStream leis, final long dataSize)
throws IOException {
- final int startIdx = leis.getReadIndex();
+ final long startIdx = leis.getReadIndex();
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfEndGroup);
return leis.getReadIndex()-startIdx;
}
@@ -429,7 +429,7 @@ public class HemfComment {
}
}
- return leis.getReadIndex()-startIdx;
+ return leis.getReadIndex()-(long)startIdx;
}
public List<EmfCommentDataFormat> getFormats() {
@@ -510,7 +510,7 @@ public class HemfComment {
throw new RecordFormatException("offset for emrformat must be > 0");
}
- return 4*LittleEndianConsts.INT_SIZE;
+ return 4L*LittleEndianConsts.INT_SIZE;
}
public byte[] getRawData() {
@@ -543,7 +543,7 @@ public class HemfComment {
@SuppressWarnings("unused")
@Override
public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
- final int startIdx = leis.getReadIndex();
+ final long startIdx = leis.getReadIndex();
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfWMF);
// A 16-bit unsigned integer that specifies the WMF metafile version in terms
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
index caabb04a4c..f49926871f 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
@@ -1238,13 +1238,13 @@ public final class HemfDraw {
/* A 32-bit signed integer that defines the x coordinate, in logical coordinates,
* of the ... corner of the rectangle.
*/
- final int left = leis.readInt();
- final int top = leis.readInt();
- final int right = leis.readInt();
- final int bottom = leis.readInt();
+ final double left = leis.readInt();
+ final double top = leis.readInt();
+ final double right = leis.readInt();
+ final double bottom = leis.readInt();
bounds.setRect(left, top, right-left, bottom-top);
- return 4 * LittleEndianConsts.INT_SIZE;
+ return 4L * LittleEndianConsts.INT_SIZE;
}
static long readPointS(LittleEndianInputStream leis, Point2D point) {
@@ -1254,7 +1254,7 @@ public final class HemfDraw {
final int y = leis.readShort();
point.setLocation(x, y);
- return 2*LittleEndianConsts.SHORT_SIZE;
+ return 2L*LittleEndianConsts.SHORT_SIZE;
}
static long readPointL(LittleEndianInputStream leis, Point2D point) {
@@ -1264,7 +1264,7 @@ public final class HemfDraw {
final int y = leis.readInt();
point.setLocation(x, y);
- return 2*LittleEndianConsts.INT_SIZE;
+ return 2L*LittleEndianConsts.INT_SIZE;
}
@@ -1272,7 +1272,7 @@ public final class HemfDraw {
final double width = leis.readFloat();
final double height = leis.readFloat();
dimension.setSize(width, height);
- return 2*LittleEndianConsts.INT_SIZE;
+ return 2L*LittleEndianConsts.INT_SIZE;
}
static long readDimensionInt(LittleEndianInputStream leis, Dimension2D dimension) {
@@ -1280,7 +1280,7 @@ public final class HemfDraw {
final double width = leis.readInt();
final double height = leis.readInt();
dimension.setSize(width, height);
- return 2*LittleEndianConsts.INT_SIZE;
+ return 2L*LittleEndianConsts.INT_SIZE;
}
private static void polyTo(final HemfGraphics ctx, final Path2D poly, FillDrawStyle fillDrawStyle) {
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
index 187096a8a6..803fb98855 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
@@ -509,7 +509,7 @@ public final class HemfFill {
long rgnDataSize = leis.readUInt();
// A 32-bit unsigned integer that specifies the way to use the region.
regionMode = HwmfRegionMode.valueOf((int)leis.readUInt());
- long size = 2* LittleEndianConsts.INT_SIZE;
+ long size = 2L * LittleEndianConsts.INT_SIZE;
// If RegionMode is RGN_COPY, this data can be omitted and the clip region
// SHOULD be set to the default (NULL) clip region.
@@ -790,7 +790,7 @@ public final class HemfFill {
final int dibSize = cbBmi+cbBits;
if (undefinedSpace2 == 0) {
- return undefinedSpace1 + bitmap.init(leis, dibSize);
+ return (long)undefinedSpace1 + bitmap.init(leis, dibSize);
}
final ByteArrayOutputStream bos = new ByteArrayOutputStream(cbBmi+cbBits);
@@ -803,7 +803,7 @@ public final class HemfFill {
final LittleEndianInputStream leisDib = new LittleEndianInputStream(new ByteArrayInputStream(bos.toByteArray()));
final int dibSizeAct = bitmap.init(leisDib, dibSize);
assert (dibSizeAct <= dibSize);
- return undefinedSpace1 + cbBmi + undefinedSpace2 + cbBits;
+ return (long)undefinedSpace1 + cbBmi + undefinedSpace2 + cbBits;
}
@@ -820,7 +820,7 @@ public final class HemfFill {
long rgnCntRect = leis.readUInt();
// A 32-bit unsigned integer that specifies the size of the buffer of rectangles in bytes.
long rgnCntBytes = leis.readUInt();
- long size = 4*LittleEndianConsts.INT_SIZE;
+ long size = 4L*LittleEndianConsts.INT_SIZE;
// A 128-bit WMF RectL object, which specifies the bounds of the region.
Rectangle2D rgnBounds = new Rectangle2D.Double();
size += readRectL(leis, rgnBounds);
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 4552f858a2..51dd125930 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
@@ -360,7 +360,7 @@ public class HemfMisc {
colorRef = new HwmfColorRef();
int size = colorRef.init(leis);
brushHatch = HwmfHatchStyle.valueOf((int) leis.readUInt());
- return size + 3 * LittleEndianConsts.INT_SIZE;
+ return size + 3L * LittleEndianConsts.INT_SIZE;
}
@Override
@@ -513,7 +513,7 @@ public class HemfMisc {
int size = colorRef.init(leis);
- return size + 4 * LittleEndianConsts.INT_SIZE;
+ return size + 4L * LittleEndianConsts.INT_SIZE;
}
@Override
@@ -792,7 +792,7 @@ public class HemfMisc {
// An XForm object that defines a two-dimensional linear transform in logical units.
// This transform is used according to the ModifyWorldTransformMode to define a new value for
// the world-space to page-space transform in the playback device context.
- int size = readXForm(leis, xForm);
+ long size = readXForm(leis, xForm);
// A 32-bit unsigned integer that specifies how the transform specified in Xform is used.
// This value MUST be in the ModifyWorldTransformMode enumeration
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
index 0bfbebad38..607e30244e 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
@@ -74,7 +74,7 @@ public class HemfPalette {
/* A 16-bit unsigned integer that specifies the version number of the system. This MUST be 0x0300. */
int version = leis.readUShort();
assert(version == 0x0300);
- int size = readPaletteEntries(leis, -1);
+ long size = readPaletteEntries(leis, -1);
return size + LittleEndianConsts.INT_SIZE + LittleEndianConsts.SHORT_SIZE;
}
@@ -123,7 +123,7 @@ public class HemfPalette {
// A 32-bit unsigned integer that specifies the number of entries.
int nbrOfEntries = (int)leis.readUInt();
int size = readPaletteEntries(leis, nbrOfEntries);
- return size + 3*LittleEndianConsts.INT_SIZE;
+ return size + 3L*LittleEndianConsts.INT_SIZE;
}
@Override
@@ -170,7 +170,7 @@ public class HemfPalette {
// The value MUST be less than or equal to 0x00000400 and greater than 0x00000000.
numberOfEntries = (int)leis.readUInt();
- return 2*LittleEndianConsts.INT_SIZE;
+ return 2L*LittleEndianConsts.INT_SIZE;
}
@Override
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
index 344cc62a9b..e7d9947b72 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
@@ -311,7 +311,7 @@ public class HemfText {
// A 32-bit unsigned integer that specifies the index of the logical font object
// in the EMF Object Table
fontIdx = (int)leis.readUInt();
- int size = font.init(leis, (int)(recordSize-LittleEndianConsts.INT_SIZE));
+ long size = font.init(leis, (int)(recordSize-LittleEndianConsts.INT_SIZE));
return size+LittleEndianConsts.INT_SIZE;
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
index 2d92484f0c..34bda1e4be 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
@@ -478,7 +478,7 @@ public class HemfPlusBrush {
style = EmfPlusHatchStyle.valueOf(leis.readInt());
foreColor = readARGB(leis.readInt());
backColor = readARGB(leis.readInt());
- return 3*LittleEndianConsts.INT_SIZE;
+ return 3L*LittleEndianConsts.INT_SIZE;
}
@Override
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
index 8c95a2a192..5df76bde68 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
@@ -708,7 +708,7 @@ public final class HemfPlusDraw {
// If the CMAP_LOOKUP flag in the optionsFlags field is set, each value in this array specifies a
// Unicode character. Otherwise, each value specifies an index to a character glyph in the EmfPlusFont
// object specified by the ObjectId value in Flags field.
- byte[] glyphBuf = IOUtils.toByteArray(leis, glyphCount*2, MAX_OBJECT_SIZE);
+ byte[] glyphBuf = IOUtils.toByteArray(leis, glyphCount*2L, MAX_OBJECT_SIZE);
glyphs = StringUtil.getFromUnicodeLE(glyphBuf);
size += glyphBuf.length;
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
index e61dae8d2f..a492985c9b 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
@@ -94,7 +94,7 @@ public class HemfPlusHeader implements HemfPlusRecord {
logicalDpiX = leis.readUInt();
logicalDpiY = leis.readUInt();
- return 4* LittleEndianConsts.INT_SIZE;
+ return 4L*LittleEndianConsts.INT_SIZE;
}
public EmfPlusGraphicsVersion getVersion() {
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
index 40b3d729eb..104863f8cd 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
@@ -461,7 +461,7 @@ public class HemfPlusMisc {
origin.setLocation(x,y);
- return LittleEndianConsts.INT_SIZE*2;
+ return LittleEndianConsts.INT_SIZE*2L;
}
@Override
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
index b2213df707..7d0fc5c2d3 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
@@ -262,7 +262,7 @@ public class HemfPlusPen {
// respect to the width of the EmfPlusPen object that is used to draw the lines.
widthScale = leis.readFloat();
- long size = 5*LittleEndianConsts.INT_SIZE;
+ long size = 5L*LittleEndianConsts.INT_SIZE;
// An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
size += readPointF(leis, fillHotSpot);
@@ -668,7 +668,7 @@ public class HemfPlusPen {
// beginning of the line cap and the end of the line.
baseInset = leis.readFloat();
- long size = 3*LittleEndianConsts.INT_SIZE;
+ long size = 3L*LittleEndianConsts.INT_SIZE;
size += super.init(leis);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
index 1c2d3dc07f..8a091bd7ab 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
@@ -92,7 +92,7 @@ public final class DIB extends Bitmap {
LittleEndian.putInt(header, 10, offset);
//DIB data is the header + dib bytes
- byte[] dib = IOUtils.safelyAllocate(header.length + data.length, MAX_RECORD_LENGTH);
+ byte[] dib = IOUtils.safelyAllocate(header.length + (long)data.length, MAX_RECORD_LENGTH);
System.arraycopy(header, 0, dib, 0, header.length);
System.arraycopy(data, 0, dib, header.length, data.length);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
index 632c6f68c1..1d00322911 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
@@ -43,7 +43,7 @@ public final class WMF extends Metafile {
InputStream is = new ByteArrayInputStream( rawdata );
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount());
- long skipLen = header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount();
+ long skipLen = header.getSize() + (long)CHECKSUM_SIZE*getUIDInstanceCount();
long skipped = IOUtils.skipFully(is, skipLen);
assert(skipped == skipLen);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java
index c0195d7a27..273c3a6a2c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java
@@ -190,7 +190,7 @@ public final class DocumentAtom extends RecordAtom {
showComments = leis.readByte();
// If there's any other bits of data, keep them about
- reserved = IOUtils.safelyAllocate(maxLen-48, MAX_RECORD_LENGTH);
+ reserved = IOUtils.safelyAllocate(maxLen-48L, MAX_RECORD_LENGTH);
leis.readFully(reserved);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
index 2e0084e323..14ddb0e307 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
@@ -403,7 +403,7 @@ public final class StyleTextPropAtom extends RecordAtom {
out.append(" original byte stream \n");
- byte[] buf = IOUtils.safelyAllocate(rawContents.length + reserved.length, MAX_RECORD_LENGTH);
+ byte[] buf = IOUtils.safelyAllocate(rawContents.length + (long)reserved.length, MAX_RECORD_LENGTH);
System.arraycopy(rawContents, 0, buf, 0, rawContents.length);
System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
out.append( HexDump.dump(buf, 0, 0) );
diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
index 5da2f5bd43..82b3c00646 100644
--- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
+++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
@@ -195,7 +195,7 @@ public final class Chunks implements ChunkGroupWithProperties {
// Work out what MAPIProperty this corresponds to
MAPIProperty prop = MAPIProperty.get(chunk.getChunkId());
if (prop == MAPIProperty.UNKNOWN) {
- long id = (chunk.getChunkId() << 16) + chunk.getType().getId();
+ long id = (chunk.getChunkId() << 16) + (long)chunk.getType().getId();
prop = unknownProperties.get(id);
if (prop == null) {
prop = MAPIProperty.createCustom(chunk.getChunkId(), chunk.getType(), chunk.getEntryName());
diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java
index 4c352413ba..a80d26fd48 100644
--- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java
+++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java
@@ -157,7 +157,7 @@ public final class NameIdChunks implements ChunkGroup {
if (propertyKind == 1 && propertyNameCRC32[0] < 0) {
// skip stream entry matching and return tag from property index from entry stream
// this code should not be reached
- return 0x8000 + propertyIndex;
+ return 0x8000L + propertyIndex;
}
return getPropertyTag(streamID, nameOffset, propertyNameCRC32[0]);
@@ -182,7 +182,7 @@ public final class NameIdChunks implements ChunkGroup {
int matchPropertyKind = matchGuidIndex & 0x01;
if (nameCRC == (matchPropertyKind == 0 ? nameOffset : propertyNameCRC32)) {
- return 0x8000 + matchPropertyIndex;
+ return 0x8000L + matchPropertyIndex;
}
}
}
@@ -221,7 +221,7 @@ public final class NameIdChunks implements ChunkGroup {
Consumer<String> propertyNameSetter, Consumer<Long> propertyNameCRC32Setter) {
if (propertyKind == 0) {
// numerical named property
- return 0x1000 + (nameOffset ^ (guidIndex << 1)) % 0x1F;
+ return 0x1000L + (nameOffset ^ (guidIndex << 1)) % 0x1F;
}
// string named property
diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
index a21eb5a7ef..bca708b7f7 100644
--- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
+++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfBitmapDib.java
@@ -232,7 +232,7 @@ public class HwmfBitmapDib implements GenericRecord {
public int init(LittleEndianInputStream leis, int recordSize) throws IOException {
leis.mark(10000);
-
+
// need to read the header to calculate start of bitmap data correct
introSize = readHeader(leis);
assert(introSize == headerSize);
@@ -451,9 +451,9 @@ public class HwmfBitmapDib implements GenericRecord {
// sometimes there are missing bytes after the imageData which will be 0-filled
int imageSize = (int)Math.max(imageData.length, introSize+headerImageSize);
-
+
// create the image data and leave the parsing to the ImageIO api
- byte[] buf = IOUtils.safelyAllocate(BMP_HEADER_SIZE + imageSize, MAX_RECORD_LENGTH);
+ byte[] buf = IOUtils.safelyAllocate(BMP_HEADER_SIZE + (long)imageSize, MAX_RECORD_LENGTH);
// https://en.wikipedia.org/wiki/BMP_file_format # Bitmap file header
buf[0] = (byte)'B';
@@ -466,10 +466,10 @@ public class HwmfBitmapDib implements GenericRecord {
LittleEndian.putInt(buf, 10, BMP_HEADER_SIZE + introSize);
// fill the "known" image data
System.arraycopy(imageData, 0, buf, BMP_HEADER_SIZE, imageData.length);
-
+
return buf;
}
-
+
public BufferedImage getImage() {
return getImage(null, null, false);
}
diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
index 5229b34c18..15f88d5e6f 100644
--- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
+++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java
@@ -197,7 +197,7 @@ public class HwmfText {
@Override
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
stringLength = leis.readShort();
- rawTextBytes = IOUtils.safelyAllocate(stringLength+(stringLength&1), MAX_RECORD_LENGTH);
+ rawTextBytes = IOUtils.safelyAllocate(stringLength+(long)(stringLength&1), MAX_RECORD_LENGTH);
leis.readFully(rawTextBytes);
// A 16-bit signed integer that defines the vertical (y-axis) coordinate, in logical
// units, of the point where drawing is to start.
@@ -413,7 +413,7 @@ public class HwmfText {
size += readRectS(leis, bounds);
}
- rawTextBytes = IOUtils.safelyAllocate(stringLength+(stringLength&1), MAX_RECORD_LENGTH);
+ rawTextBytes = IOUtils.safelyAllocate(stringLength+(long)(stringLength&1), MAX_RECORD_LENGTH);
leis.readFully(rawTextBytes);
size += rawTextBytes.length;
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
index af937e6465..d18f8219aa 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
@@ -57,7 +57,7 @@ public final class SprmBuffer implements Duplicatable {
}
public SprmBuffer(int sprmsStartOffset) {
- _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4, MAX_RECORD_LENGTH);
+ _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, MAX_RECORD_LENGTH);
_offset = sprmsStartOffset;
_sprmsStartOffset = sprmsStartOffset;
}
@@ -127,7 +127,7 @@ public final class SprmBuffer implements Duplicatable {
// commented - buffer shall not contain any additional bytes --
// sergey
// byte[] newBuf = new byte[_offset + addition + 6];
- IOUtils.safelyAllocateCheck(_offset + addition, MAX_RECORD_LENGTH);
+ IOUtils.safelyAllocateCheck(_offset + (long)addition, MAX_RECORD_LENGTH);
_buf = Arrays.copyOf(_buf, _offset + addition);
}
}