} else {
ch = new ChunkHeaderV6();
}
- ch.setType((int)LittleEndian.getUInt(data, offset));
- ch.setId((int)LittleEndian.getUInt(data, offset + 4));
- ch.setUnknown1((int)LittleEndian.getUInt(data, offset + 8));
- ch.setLength((int)LittleEndian.getUInt(data, offset + 12));
+ ch.setType(Math.toIntExact(LittleEndian.getUInt(data, offset)));
+ ch.setId(Math.toIntExact(LittleEndian.getUInt(data, offset + 4)));
+ ch.setUnknown1(Math.toIntExact(LittleEndian.getUInt(data, offset + 8)));
+ ch.setLength(Math.toIntExact(LittleEndian.getUInt(data, offset + 12)));
ch.setUnknown2(LittleEndian.getShort(data, offset + 16));
ch.setUnknown3(LittleEndian.getUByte(data, offset + 18));
}
public static int getNumPointersOffsetV6(byte[] data) {
// V6 stores it as the first value in the stream
- return (int)LittleEndian.getUInt(data, 0);
+ return Math.toIntExact(LittleEndian.getUInt(data, 0));
}
/**
* 32 bit int at the given offset
}
public static int getNumPointersV6(int offset, byte[] data) {
// V6 stores it a 32 bit number at the offset
- return (int)LittleEndian.getUInt(data, offset);
+ return Math.toIntExact(LittleEndian.getUInt(data, offset));
}
/**
* 4 bytes of the number, and 4 more unknown bytes
int size = 6*LittleEndianConsts.INT_SIZE;
patternDib = new HwmfBitmapDib();
- size += readBitmap(leis, patternDib, startIdx, offBmi, cbBmi, offBits, cbBits);
+ size = Math.toIntExact(size + readBitmap(leis, patternDib, startIdx, offBmi, cbBmi, offBits, cbBits));
return size;
}
emfPS.setLineDashes(dashPattern);
}
- size += numStyleEntries * LittleEndianConsts.INT_SIZE;
+ size = Math.addExact(size, numStyleEntries * LittleEndianConsts.INT_SIZE);
- size += readBitmap(leis, bitmap, startIdx, offBmi, cbBmi, offBits, cbBits);
+ size = Math.toIntExact(size + readBitmap(leis, bitmap, startIdx, offBmi, cbBmi, offBits, cbBits));
return size;
}
// A 32-bit unsigned integer that specifies the size of the DIB bits, if the record
// contains a DIB.
- int cbBits = (int) leis.readUInt();
+ int cbBits = Math.toIntExact(leis.readUInt());
int size = 6 * LittleEndianConsts.INT_SIZE;
- size += readBitmap(leis, bitmap, startIdx, offBmi, cbBmi, offBits, cbBits);
+ size = Math.toIntExact(size + readBitmap(leis, bitmap, startIdx, offBmi, cbBmi, offBits, cbBits));
return size;
}
// invalid dx array
dx.clear();
}
- strEnd = (int)recordSize;
+ strEnd = Math.toIntExact(recordSize);
break;
}
default:
case 's': {
- int undefinedSpace1 = (int)(offString - (size + HEADER_SIZE));
+ int undefinedSpace1 = Math.toIntExact(offString - (size + HEADER_SIZE));
if (offString > 0 && undefinedSpace1 >= 0 && offString-HEADER_SIZE < recordSize) {
leis.skipFully(undefinedSpace1);
size += undefinedSpace1;
// read all available bytes and not just "stringLength * 1(ansi)/2(unicode)"
// in case we need to deal with surrogate pairs
- final int maxSize = (int)(Math.min(recordSize, strEnd)-size);
+ final int maxSize = Math.toIntExact(Math.min(recordSize, strEnd)-size);
rawTextBytes = IOUtils.safelyAllocate(maxSize, MAX_RECORD_LENGTH);
leis.readFully(rawTextBytes);
size += maxSize;
case DARKEN_COLOR: {
// see java.awt.Color#darken()
double FACTOR = (ecr.getRGB()[2])/255.;
- int r = (int)Math.rint(col.getRed()*FACTOR);
- int g = (int)Math.rint(col.getGreen()*FACTOR);
- int b = (int)Math.rint(col.getBlue()*FACTOR);
+ int r = Math.toIntExact(Math.round(col.getRed()*FACTOR));
+ int g = Math.toIntExact(Math.round(col.getGreen()*FACTOR));
+ int b = Math.toIntExact(Math.round(col.getBlue()*FACTOR));
return new Color(r,g,b);
}
case LIGHTEN_COLOR: {
int g = col.getGreen();
int b = col.getBlue();
- r += Math.rint((0xFF-r)*FACTOR);
- g += Math.rint((0xFF-g)*FACTOR);
- b += Math.rint((0xFF-b)*FACTOR);
+ r = Math.toIntExact(Math.round(r + (0xFF-r)*FACTOR));
+ g = Math.toIntExact(Math.round(g + (0xFF-g)*FACTOR));
+ b = Math.toIntExact(Math.round(b + (0xFF-b)*FACTOR));
return new Color(r,g,b);
}
for ( int x = 0; x < parentSize; x++ )
{
- numBits += ( mask >> x ) & 0x1;
+ numBits += (byte) (( mask >> x ) & 0x1);
}
if ( numBits == 1 )
int adjust = sprm.getOperand() - (rgdxaCenter[0] + newTAP.getDxaGapHalf ());
for (int x = 0; x < itcMac; x++)
{
- rgdxaCenter[x] += adjust;
+ rgdxaCenter[x] += (short) adjust;
}
break;
}
if (rgdxaCenter != null)
{
int adjust = newTAP.getDxaGapHalf () - sprm.getOperand();
- rgdxaCenter[0] += adjust;
+ rgdxaCenter[0] += (short) adjust;
}
newTAP.setDxaGapHalf (sprm.getOperand());
break;
for (; j < limit; j++)
{
new ShortField(offset, ( short ) char_array[ j ], _raw_data);
- offset += LittleEndianConsts.SHORT_SIZE;
+ offset += (short) LittleEndianConsts.SHORT_SIZE;
}
for (; j < _max_name_length + 1; j++)
{
new ShortField(offset, ( short ) 0, _raw_data);
- offset += LittleEndianConsts.SHORT_SIZE;
+ offset += (short) LittleEndianConsts.SHORT_SIZE;
}
// double the count, and include the null at the end
buSz = 100d;
}
if (buSz > 0) {
- fontSize *= buSz* 0.01;
+ fontSize *= (float) (buSz * 0.01);
} else {
- fontSize = (float)-buSz;
+ fontSize = (float) -buSz;
}
String buFontStr = bulletStyle.getBulletFont();
d = frac.getDenominator();
}
if (improperFraction) {
- n += Math.round(value * d);
+ n = Math.toIntExact(n + Math.round(value * d));
}
writeSingleInteger(numeratorFmt, n, output, numeratorSpecials, mods);
writeSingleInteger(denominatorFmt, d, output, denominatorSpecials, mods);