mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
65c8c6cd11
commit
948d4a3574
|
@ -85,7 +85,7 @@ public class Mirr extends MultiOperandNumericFunction {
|
||||||
|
|
||||||
private static double mirr(double[] in, double financeRate, double reinvestRate) {
|
private static double mirr(double[] in, double financeRate, double reinvestRate) {
|
||||||
double value = 0;
|
double value = 0;
|
||||||
double numOfYears = in.length - 1;
|
double numOfYears = in.length - 1.;
|
||||||
double pv = 0;
|
double pv = 0;
|
||||||
double fv = 0;
|
double fv = 0;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class StreamStore { // TODO - instantiable superclass
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prependContentsWith(byte[] b) {
|
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(b, 0, newContents, 0, b.length);
|
||||||
System.arraycopy(contents, 0, newContents, b.length, contents.length);
|
System.arraycopy(contents, 0, newContents, b.length, contents.length);
|
||||||
contents = newContents;
|
contents = newContents;
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class HemfComment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
|
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();
|
data = new EmfCommentDataIterator(leis, (int)recordSize, true).next();
|
||||||
return leis.getReadIndex()-startIdx;
|
return leis.getReadIndex()-startIdx;
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ public class HemfComment {
|
||||||
@Override
|
@Override
|
||||||
public long init(final LittleEndianInputStream leis, final long dataSize)
|
public long init(final LittleEndianInputStream leis, final long dataSize)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final int startIdx = leis.getReadIndex();
|
final long startIdx = leis.getReadIndex();
|
||||||
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfPlus);
|
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfPlus);
|
||||||
new HemfPlusRecordIterator(leis, (int)dataSize-LittleEndianConsts.INT_SIZE).forEachRemaining(records::add);
|
new HemfPlusRecordIterator(leis, (int)dataSize-LittleEndianConsts.INT_SIZE).forEachRemaining(records::add);
|
||||||
return leis.getReadIndex()-startIdx;
|
return leis.getReadIndex()-startIdx;
|
||||||
|
@ -339,7 +339,7 @@ public class HemfComment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
|
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);
|
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfBeginGroup);
|
||||||
HemfDraw.readRectL(leis, bounds);
|
HemfDraw.readRectL(leis, bounds);
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ public class HemfComment {
|
||||||
@Override
|
@Override
|
||||||
public long init(final LittleEndianInputStream leis, final long dataSize)
|
public long init(final LittleEndianInputStream leis, final long dataSize)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final int startIdx = leis.getReadIndex();
|
final long startIdx = leis.getReadIndex();
|
||||||
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfEndGroup);
|
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfEndGroup);
|
||||||
return leis.getReadIndex()-startIdx;
|
return leis.getReadIndex()-startIdx;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ public class HemfComment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return leis.getReadIndex()-startIdx;
|
return leis.getReadIndex()-(long)startIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EmfCommentDataFormat> getFormats() {
|
public List<EmfCommentDataFormat> getFormats() {
|
||||||
|
@ -510,7 +510,7 @@ public class HemfComment {
|
||||||
throw new RecordFormatException("offset for emrformat must be > 0");
|
throw new RecordFormatException("offset for emrformat must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 4*LittleEndianConsts.INT_SIZE;
|
return 4L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getRawData() {
|
public byte[] getRawData() {
|
||||||
|
@ -543,7 +543,7 @@ public class HemfComment {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Override
|
@Override
|
||||||
public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
|
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);
|
EmfComment.validateCommentType(leis, HemfCommentRecordType.emfWMF);
|
||||||
|
|
||||||
// A 16-bit unsigned integer that specifies the WMF metafile version in terms
|
// A 16-bit unsigned integer that specifies the WMF metafile version in terms
|
||||||
|
|
|
@ -1238,13 +1238,13 @@ public final class HemfDraw {
|
||||||
/* A 32-bit signed integer that defines the x coordinate, in logical coordinates,
|
/* A 32-bit signed integer that defines the x coordinate, in logical coordinates,
|
||||||
* of the ... corner of the rectangle.
|
* of the ... corner of the rectangle.
|
||||||
*/
|
*/
|
||||||
final int left = leis.readInt();
|
final double left = leis.readInt();
|
||||||
final int top = leis.readInt();
|
final double top = leis.readInt();
|
||||||
final int right = leis.readInt();
|
final double right = leis.readInt();
|
||||||
final int bottom = leis.readInt();
|
final double bottom = leis.readInt();
|
||||||
bounds.setRect(left, top, right-left, bottom-top);
|
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) {
|
static long readPointS(LittleEndianInputStream leis, Point2D point) {
|
||||||
|
@ -1254,7 +1254,7 @@ public final class HemfDraw {
|
||||||
final int y = leis.readShort();
|
final int y = leis.readShort();
|
||||||
point.setLocation(x, y);
|
point.setLocation(x, y);
|
||||||
|
|
||||||
return 2*LittleEndianConsts.SHORT_SIZE;
|
return 2L*LittleEndianConsts.SHORT_SIZE;
|
||||||
|
|
||||||
}
|
}
|
||||||
static long readPointL(LittleEndianInputStream leis, Point2D point) {
|
static long readPointL(LittleEndianInputStream leis, Point2D point) {
|
||||||
|
@ -1264,7 +1264,7 @@ public final class HemfDraw {
|
||||||
final int y = leis.readInt();
|
final int y = leis.readInt();
|
||||||
point.setLocation(x, y);
|
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 width = leis.readFloat();
|
||||||
final double height = leis.readFloat();
|
final double height = leis.readFloat();
|
||||||
dimension.setSize(width, height);
|
dimension.setSize(width, height);
|
||||||
return 2*LittleEndianConsts.INT_SIZE;
|
return 2L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long readDimensionInt(LittleEndianInputStream leis, Dimension2D dimension) {
|
static long readDimensionInt(LittleEndianInputStream leis, Dimension2D dimension) {
|
||||||
|
@ -1280,7 +1280,7 @@ public final class HemfDraw {
|
||||||
final double width = leis.readInt();
|
final double width = leis.readInt();
|
||||||
final double height = leis.readInt();
|
final double height = leis.readInt();
|
||||||
dimension.setSize(width, height);
|
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) {
|
private static void polyTo(final HemfGraphics ctx, final Path2D poly, FillDrawStyle fillDrawStyle) {
|
||||||
|
|
|
@ -509,7 +509,7 @@ public final class HemfFill {
|
||||||
long rgnDataSize = leis.readUInt();
|
long rgnDataSize = leis.readUInt();
|
||||||
// A 32-bit unsigned integer that specifies the way to use the region.
|
// A 32-bit unsigned integer that specifies the way to use the region.
|
||||||
regionMode = HwmfRegionMode.valueOf((int)leis.readUInt());
|
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
|
// If RegionMode is RGN_COPY, this data can be omitted and the clip region
|
||||||
// SHOULD be set to the default (NULL) clip region.
|
// SHOULD be set to the default (NULL) clip region.
|
||||||
|
@ -790,7 +790,7 @@ public final class HemfFill {
|
||||||
|
|
||||||
final int dibSize = cbBmi+cbBits;
|
final int dibSize = cbBmi+cbBits;
|
||||||
if (undefinedSpace2 == 0) {
|
if (undefinedSpace2 == 0) {
|
||||||
return undefinedSpace1 + bitmap.init(leis, dibSize);
|
return (long)undefinedSpace1 + bitmap.init(leis, dibSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream(cbBmi+cbBits);
|
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 LittleEndianInputStream leisDib = new LittleEndianInputStream(new ByteArrayInputStream(bos.toByteArray()));
|
||||||
final int dibSizeAct = bitmap.init(leisDib, dibSize);
|
final int dibSizeAct = bitmap.init(leisDib, dibSize);
|
||||||
assert (dibSizeAct <= 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();
|
long rgnCntRect = leis.readUInt();
|
||||||
// A 32-bit unsigned integer that specifies the size of the buffer of rectangles in bytes.
|
// A 32-bit unsigned integer that specifies the size of the buffer of rectangles in bytes.
|
||||||
long rgnCntBytes = leis.readUInt();
|
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.
|
// A 128-bit WMF RectL object, which specifies the bounds of the region.
|
||||||
Rectangle2D rgnBounds = new Rectangle2D.Double();
|
Rectangle2D rgnBounds = new Rectangle2D.Double();
|
||||||
size += readRectL(leis, rgnBounds);
|
size += readRectL(leis, rgnBounds);
|
||||||
|
|
|
@ -360,7 +360,7 @@ public class HemfMisc {
|
||||||
colorRef = new HwmfColorRef();
|
colorRef = new HwmfColorRef();
|
||||||
int size = colorRef.init(leis);
|
int size = colorRef.init(leis);
|
||||||
brushHatch = HwmfHatchStyle.valueOf((int) leis.readUInt());
|
brushHatch = HwmfHatchStyle.valueOf((int) leis.readUInt());
|
||||||
return size + 3 * LittleEndianConsts.INT_SIZE;
|
return size + 3L * LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -513,7 +513,7 @@ public class HemfMisc {
|
||||||
|
|
||||||
int size = colorRef.init(leis);
|
int size = colorRef.init(leis);
|
||||||
|
|
||||||
return size + 4 * LittleEndianConsts.INT_SIZE;
|
return size + 4L * LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -792,7 +792,7 @@ public class HemfMisc {
|
||||||
// An XForm object that defines a two-dimensional linear transform in logical units.
|
// 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
|
// 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.
|
// 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.
|
// A 32-bit unsigned integer that specifies how the transform specified in Xform is used.
|
||||||
// This value MUST be in the ModifyWorldTransformMode enumeration
|
// This value MUST be in the ModifyWorldTransformMode enumeration
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class HemfPalette {
|
||||||
/* A 16-bit unsigned integer that specifies the version number of the system. This MUST be 0x0300. */
|
/* A 16-bit unsigned integer that specifies the version number of the system. This MUST be 0x0300. */
|
||||||
int version = leis.readUShort();
|
int version = leis.readUShort();
|
||||||
assert(version == 0x0300);
|
assert(version == 0x0300);
|
||||||
int size = readPaletteEntries(leis, -1);
|
long size = readPaletteEntries(leis, -1);
|
||||||
return size + LittleEndianConsts.INT_SIZE + LittleEndianConsts.SHORT_SIZE;
|
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.
|
// A 32-bit unsigned integer that specifies the number of entries.
|
||||||
int nbrOfEntries = (int)leis.readUInt();
|
int nbrOfEntries = (int)leis.readUInt();
|
||||||
int size = readPaletteEntries(leis, nbrOfEntries);
|
int size = readPaletteEntries(leis, nbrOfEntries);
|
||||||
return size + 3*LittleEndianConsts.INT_SIZE;
|
return size + 3L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,7 +170,7 @@ public class HemfPalette {
|
||||||
// The value MUST be less than or equal to 0x00000400 and greater than 0x00000000.
|
// The value MUST be less than or equal to 0x00000400 and greater than 0x00000000.
|
||||||
numberOfEntries = (int)leis.readUInt();
|
numberOfEntries = (int)leis.readUInt();
|
||||||
|
|
||||||
return 2*LittleEndianConsts.INT_SIZE;
|
return 2L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -311,7 +311,7 @@ public class HemfText {
|
||||||
// A 32-bit unsigned integer that specifies the index of the logical font object
|
// A 32-bit unsigned integer that specifies the index of the logical font object
|
||||||
// in the EMF Object Table
|
// in the EMF Object Table
|
||||||
fontIdx = (int)leis.readUInt();
|
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;
|
return size+LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,7 @@ public class HemfPlusBrush {
|
||||||
style = EmfPlusHatchStyle.valueOf(leis.readInt());
|
style = EmfPlusHatchStyle.valueOf(leis.readInt());
|
||||||
foreColor = readARGB(leis.readInt());
|
foreColor = readARGB(leis.readInt());
|
||||||
backColor = readARGB(leis.readInt());
|
backColor = readARGB(leis.readInt());
|
||||||
return 3*LittleEndianConsts.INT_SIZE;
|
return 3L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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
|
// 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
|
// Unicode character. Otherwise, each value specifies an index to a character glyph in the EmfPlusFont
|
||||||
// object specified by the ObjectId value in Flags field.
|
// 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);
|
glyphs = StringUtil.getFromUnicodeLE(glyphBuf);
|
||||||
|
|
||||||
size += glyphBuf.length;
|
size += glyphBuf.length;
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class HemfPlusHeader implements HemfPlusRecord {
|
||||||
|
|
||||||
logicalDpiX = leis.readUInt();
|
logicalDpiX = leis.readUInt();
|
||||||
logicalDpiY = leis.readUInt();
|
logicalDpiY = leis.readUInt();
|
||||||
return 4* LittleEndianConsts.INT_SIZE;
|
return 4L*LittleEndianConsts.INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmfPlusGraphicsVersion getVersion() {
|
public EmfPlusGraphicsVersion getVersion() {
|
||||||
|
|
|
@ -461,7 +461,7 @@ public class HemfPlusMisc {
|
||||||
|
|
||||||
origin.setLocation(x,y);
|
origin.setLocation(x,y);
|
||||||
|
|
||||||
return LittleEndianConsts.INT_SIZE*2;
|
return LittleEndianConsts.INT_SIZE*2L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class HemfPlusPen {
|
||||||
// respect to the width of the EmfPlusPen object that is used to draw the lines.
|
// respect to the width of the EmfPlusPen object that is used to draw the lines.
|
||||||
widthScale = leis.readFloat();
|
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}.
|
// An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
|
||||||
size += readPointF(leis, fillHotSpot);
|
size += readPointF(leis, fillHotSpot);
|
||||||
|
@ -668,7 +668,7 @@ public class HemfPlusPen {
|
||||||
// beginning of the line cap and the end of the line.
|
// beginning of the line cap and the end of the line.
|
||||||
baseInset = leis.readFloat();
|
baseInset = leis.readFloat();
|
||||||
|
|
||||||
long size = 3*LittleEndianConsts.INT_SIZE;
|
long size = 3L*LittleEndianConsts.INT_SIZE;
|
||||||
|
|
||||||
size += super.init(leis);
|
size += super.init(leis);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public final class DIB extends Bitmap {
|
||||||
LittleEndian.putInt(header, 10, offset);
|
LittleEndian.putInt(header, 10, offset);
|
||||||
|
|
||||||
//DIB data is the header + dib bytes
|
//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(header, 0, dib, 0, header.length);
|
||||||
System.arraycopy(data, 0, dib, header.length, data.length);
|
System.arraycopy(data, 0, dib, header.length, data.length);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class WMF extends Metafile {
|
||||||
InputStream is = new ByteArrayInputStream( rawdata );
|
InputStream is = new ByteArrayInputStream( rawdata );
|
||||||
Header header = new Header();
|
Header header = new Header();
|
||||||
header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount());
|
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);
|
long skipped = IOUtils.skipFully(is, skipLen);
|
||||||
assert(skipped == skipLen);
|
assert(skipped == skipLen);
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ public final class DocumentAtom extends RecordAtom {
|
||||||
showComments = leis.readByte();
|
showComments = leis.readByte();
|
||||||
|
|
||||||
// If there's any other bits of data, keep them about
|
// 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);
|
leis.readFully(reserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -403,7 +403,7 @@ public final class StyleTextPropAtom extends RecordAtom {
|
||||||
|
|
||||||
out.append(" original byte stream \n");
|
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(rawContents, 0, buf, 0, rawContents.length);
|
||||||
System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
|
System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
|
||||||
out.append( HexDump.dump(buf, 0, 0) );
|
out.append( HexDump.dump(buf, 0, 0) );
|
||||||
|
|
|
@ -195,7 +195,7 @@ public final class Chunks implements ChunkGroupWithProperties {
|
||||||
// Work out what MAPIProperty this corresponds to
|
// Work out what MAPIProperty this corresponds to
|
||||||
MAPIProperty prop = MAPIProperty.get(chunk.getChunkId());
|
MAPIProperty prop = MAPIProperty.get(chunk.getChunkId());
|
||||||
if (prop == MAPIProperty.UNKNOWN) {
|
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);
|
prop = unknownProperties.get(id);
|
||||||
if (prop == null) {
|
if (prop == null) {
|
||||||
prop = MAPIProperty.createCustom(chunk.getChunkId(), chunk.getType(), chunk.getEntryName());
|
prop = MAPIProperty.createCustom(chunk.getChunkId(), chunk.getType(), chunk.getEntryName());
|
||||||
|
|
|
@ -157,7 +157,7 @@ public final class NameIdChunks implements ChunkGroup {
|
||||||
if (propertyKind == 1 && propertyNameCRC32[0] < 0) {
|
if (propertyKind == 1 && propertyNameCRC32[0] < 0) {
|
||||||
// skip stream entry matching and return tag from property index from entry stream
|
// skip stream entry matching and return tag from property index from entry stream
|
||||||
// this code should not be reached
|
// this code should not be reached
|
||||||
return 0x8000 + propertyIndex;
|
return 0x8000L + propertyIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPropertyTag(streamID, nameOffset, propertyNameCRC32[0]);
|
return getPropertyTag(streamID, nameOffset, propertyNameCRC32[0]);
|
||||||
|
@ -182,7 +182,7 @@ public final class NameIdChunks implements ChunkGroup {
|
||||||
int matchPropertyKind = matchGuidIndex & 0x01;
|
int matchPropertyKind = matchGuidIndex & 0x01;
|
||||||
|
|
||||||
if (nameCRC == (matchPropertyKind == 0 ? nameOffset : propertyNameCRC32)) {
|
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) {
|
Consumer<String> propertyNameSetter, Consumer<Long> propertyNameCRC32Setter) {
|
||||||
if (propertyKind == 0) {
|
if (propertyKind == 0) {
|
||||||
// numerical named property
|
// numerical named property
|
||||||
return 0x1000 + (nameOffset ^ (guidIndex << 1)) % 0x1F;
|
return 0x1000L + (nameOffset ^ (guidIndex << 1)) % 0x1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
// string named property
|
// string named property
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class HwmfBitmapDib implements GenericRecord {
|
||||||
|
|
||||||
public int init(LittleEndianInputStream leis, int recordSize) throws IOException {
|
public int init(LittleEndianInputStream leis, int recordSize) throws IOException {
|
||||||
leis.mark(10000);
|
leis.mark(10000);
|
||||||
|
|
||||||
// need to read the header to calculate start of bitmap data correct
|
// need to read the header to calculate start of bitmap data correct
|
||||||
introSize = readHeader(leis);
|
introSize = readHeader(leis);
|
||||||
assert(introSize == headerSize);
|
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
|
// sometimes there are missing bytes after the imageData which will be 0-filled
|
||||||
int imageSize = (int)Math.max(imageData.length, introSize+headerImageSize);
|
int imageSize = (int)Math.max(imageData.length, introSize+headerImageSize);
|
||||||
|
|
||||||
// create the image data and leave the parsing to the ImageIO api
|
// 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
|
// https://en.wikipedia.org/wiki/BMP_file_format # Bitmap file header
|
||||||
buf[0] = (byte)'B';
|
buf[0] = (byte)'B';
|
||||||
|
@ -466,10 +466,10 @@ public class HwmfBitmapDib implements GenericRecord {
|
||||||
LittleEndian.putInt(buf, 10, BMP_HEADER_SIZE + introSize);
|
LittleEndian.putInt(buf, 10, BMP_HEADER_SIZE + introSize);
|
||||||
// fill the "known" image data
|
// fill the "known" image data
|
||||||
System.arraycopy(imageData, 0, buf, BMP_HEADER_SIZE, imageData.length);
|
System.arraycopy(imageData, 0, buf, BMP_HEADER_SIZE, imageData.length);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage() {
|
public BufferedImage getImage() {
|
||||||
return getImage(null, null, false);
|
return getImage(null, null, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class HwmfText {
|
||||||
@Override
|
@Override
|
||||||
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
|
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
|
||||||
stringLength = leis.readShort();
|
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);
|
leis.readFully(rawTextBytes);
|
||||||
// A 16-bit signed integer that defines the vertical (y-axis) coordinate, in logical
|
// A 16-bit signed integer that defines the vertical (y-axis) coordinate, in logical
|
||||||
// units, of the point where drawing is to start.
|
// units, of the point where drawing is to start.
|
||||||
|
@ -413,7 +413,7 @@ public class HwmfText {
|
||||||
size += readRectS(leis, bounds);
|
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);
|
leis.readFully(rawTextBytes);
|
||||||
size += rawTextBytes.length;
|
size += rawTextBytes.length;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class SprmBuffer implements Duplicatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SprmBuffer(int sprmsStartOffset) {
|
public SprmBuffer(int sprmsStartOffset) {
|
||||||
_buf = IOUtils.safelyAllocate(sprmsStartOffset + 4, MAX_RECORD_LENGTH);
|
_buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, MAX_RECORD_LENGTH);
|
||||||
_offset = sprmsStartOffset;
|
_offset = sprmsStartOffset;
|
||||||
_sprmsStartOffset = sprmsStartOffset;
|
_sprmsStartOffset = sprmsStartOffset;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public final class SprmBuffer implements Duplicatable {
|
||||||
// commented - buffer shall not contain any additional bytes --
|
// commented - buffer shall not contain any additional bytes --
|
||||||
// sergey
|
// sergey
|
||||||
// byte[] newBuf = new byte[_offset + addition + 6];
|
// 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);
|
_buf = Arrays.copyOf(_buf, _offset + addition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue