more int narrowing

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-08-19 09:02:15 +00:00
parent f1692cc041
commit 9d7d2f26e0
5 changed files with 13 additions and 22 deletions

View File

@ -709,7 +709,7 @@ public class HemfPlusBrush {
// that appears at the center point of the brush. The color of the brush changes gradually from the // that appears at the center point of the brush. The color of the brush changes gradually from the
// boundary color to the center color as it moves from the boundary to the center point. // boundary color to the center color as it moves from the boundary to the center point.
centerColor = readARGB(leis.readInt()); centerColor = readARGB(leis.readInt());
int size = 3*LittleEndianConsts.INT_SIZE; long size = 3*LittleEndianConsts.INT_SIZE;
if (wrapMode == null) { if (wrapMode == null) {
return size; return size;
@ -785,7 +785,7 @@ public class HemfPlusBrush {
size += 3*LittleEndianConsts.INT_SIZE; size += 3*LittleEndianConsts.INT_SIZE;
} }
return size; return Math.toIntExact(size);
} }
@Override @Override
@ -846,7 +846,7 @@ public class HemfPlusBrush {
// across a shape, when the image is smaller than the area being filled. // across a shape, when the image is smaller than the area being filled.
wrapMode = EmfPlusWrapMode.valueOf(leis.readInt()); wrapMode = EmfPlusWrapMode.valueOf(leis.readInt());
int size = 2*LittleEndianConsts.INT_SIZE; long size = 2*LittleEndianConsts.INT_SIZE;
if (TRANSFORM.isSet(dataFlags)) { if (TRANSFORM.isSet(dataFlags)) {
size += readXForm(leis, (brushTransform = new AffineTransform())); size += readXForm(leis, (brushTransform = new AffineTransform()));
@ -856,7 +856,7 @@ public class HemfPlusBrush {
size += (image = new EmfPlusImage()).init(leis, dataSize-size, EmfPlusObjectType.IMAGE, 0); size += (image = new EmfPlusImage()).init(leis, dataSize-size, EmfPlusObjectType.IMAGE, 0);
} }
return size; return Math.toIntExact(size);
} }
@Override @Override

View File

@ -174,7 +174,7 @@ public class HemfPlusObject {
EmfPlusObjectType objectType = getObjectType(); EmfPlusObjectType objectType = getObjectType();
assert (objectType != null); assert (objectType != null);
int size = 0; long size = 0;
totalObjectSize = 0; totalObjectSize = 0;
int dataSize2 = (int) dataSize; int dataSize2 = (int) dataSize;
@ -192,7 +192,7 @@ public class HemfPlusObject {
objectData = objectType.constructor.get(); objectData = objectType.constructor.get();
size += objectData.init(leis, dataSize2, objectType, flags); size += objectData.init(leis, dataSize2, objectType, flags);
return size; return Math.toIntExact(size);
} }
@Override @Override

View File

@ -533,7 +533,7 @@ public class HemfPlusPen {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private long initCustomCap(Consumer<EmfPlusCustomLineCap> setter, LittleEndianInputStream leis) throws IOException { private long initCustomCap(Consumer<EmfPlusCustomLineCap> setter, LittleEndianInputStream leis) throws IOException {
int CustomStartCapSize = leis.readInt(); int CustomStartCapSize = leis.readInt();
int size = LittleEndianConsts.INT_SIZE; long size = LittleEndianConsts.INT_SIZE;
EmfPlusGraphicsVersion version = new EmfPlusGraphicsVersion(); EmfPlusGraphicsVersion version = new EmfPlusGraphicsVersion();
size += version.init(leis); size += version.init(leis);
@ -547,13 +547,13 @@ public class HemfPlusPen {
setter.accept(cap); setter.accept(cap);
return size; return Math.toIntExact(size);
} }
@Override @Override
public void applyObject(HemfGraphics ctx, List<? extends EmfPlusObjectData> continuedObjectData) { public void applyObject(HemfGraphics ctx, List<? extends EmfPlusObjectData> continuedObjectData) {
final HemfDrawProperties prop = ctx.getProperties(); final HemfDrawProperties prop = ctx.getProperties();
// TOOD: // TODO:
// - set width according unit type // - set width according unit type
// - provide logic for different start and end cap // - provide logic for different start and end cap
// - provide standard caps like diamond // - provide standard caps like diamond

View File

@ -281,19 +281,10 @@ public final class SlideShowDumper {
if (recordLen == 8 && atomLen > 8) { if (recordLen == 8 && atomLen > 8) {
// Assume it has children, rather than being corrupted // Assume it has children, rather than being corrupted
walkEscherDDF((indent + 3), pos + 8, (int) atomLen); walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
// Wind on our length + our header
pos += atomLen;
pos += 8;
len -= atomLen;
len -= 8;
} else {
// No children, wind on our real length
pos += atomLen;
pos += 8;
len -= atomLen;
len -= 8;
} }
// Wind on our length + our header
pos = Math.toIntExact(pos + atomLen) + 8;
len = Math.toIntExact(len - atomLen) - 8;
// Move on to the next one, if we're not at the end yet // Move on to the next one, if we're not at the end yet
if (len >= 8) { if (len >= 8) {

View File

@ -113,7 +113,7 @@ public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
_childRecords.add(r); _childRecords.add(r);
} }
long rlen = LittleEndian.getUInt(remainingData,offset+4); long rlen = LittleEndian.getUInt(remainingData,offset+4);
offset += 8 + rlen; offset = Math.toIntExact(offset + 8 + rlen);
} }
} }