Sonarqube fixes - Cast one of the operands of this multiplication operation to a ...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1776894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2017-01-01 22:59:35 +00:00
parent abf3eb7d84
commit da20cf5d63
15 changed files with 52 additions and 52 deletions

View File

@ -36,11 +36,11 @@ public class OfficeDrawingWithGraphics {
HSSFSheet sheet = wb.createSheet( "my drawing" );
sheet.setColumnWidth(1, 256 * 27);
HSSFRow row1 = sheet.createRow(0);
row1.setHeightInPoints(10 * 15);
row1.setHeightInPoints(10 * 15f);
HSSFRow row2 = sheet.createRow(1);
row2.setHeightInPoints(5 * 15);
row2.setHeightInPoints(5 * 15f);
HSSFRow row3 = sheet.createRow(2);
row3.setHeightInPoints(10 * 15);
row3.setHeightInPoints(10 * 15f);
// Add some cells so we can test that the anchoring works when we
// sort them.

View File

@ -893,7 +893,7 @@ public class Section {
/* Write the dictionary item in another codepage than
* Unicode. */
length += TypeWriter.writeUIntToStream(out, key.longValue());
length += TypeWriter.writeUIntToStream(out, value.length() + 1);
length += TypeWriter.writeUIntToStream(out, value.length() + 1L);
final byte[] ba = CodePageUtil.getBytesInCodePage(value, codepage);
for (int j = 0; j < ba.length; j++) {
out.write(ba[j]);

View File

@ -170,7 +170,7 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
LittleEndianInputStream leis = new LittleEndianInputStream(sbis);
int streamDescriptorArrayOffset = (int) leis.readUInt();
/* int streamDescriptorArraySize = (int) */ leis.readUInt();
sbis.skip(streamDescriptorArrayOffset - 8);
sbis.skip(streamDescriptorArrayOffset - 8L);
sbis.setBlock(0);
int encryptedStreamDescriptorCount = (int) leis.readUInt();
StreamDescriptorEntry entries[] = new StreamDescriptorEntry[encryptedStreamDescriptorCount];

View File

@ -200,7 +200,7 @@ public final class NDocumentInputStream extends DocumentInputStream {
if (n < 0) {
return 0;
}
int new_offset = _current_offset + (int) n;
long new_offset = _current_offset + n;
if (new_offset < _current_offset) {
// wrap around in converting a VERY large long to an int

View File

@ -478,7 +478,7 @@ public class NPOIFSFileSystem extends BlockStore
@Override
protected ByteBuffer getBlockAt(final int offset) throws IOException {
// The header block doesn't count, so add one
long blockWanted = offset + 1;
long blockWanted = offset + 1L;
long startAt = blockWanted * bigBlockSize.getBigBlockSize();
try {
return _data.read(bigBlockSize.getBigBlockSize(), startAt);
@ -499,7 +499,7 @@ public class NPOIFSFileSystem extends BlockStore
return getBlockAt(offset);
} catch(IndexOutOfBoundsException e) {
// The header block doesn't count, so add one
long startAt = (offset+1) * bigBlockSize.getBigBlockSize();
long startAt = (offset+1L) * bigBlockSize.getBigBlockSize();
// Allocate and write
ByteBuffer buffer = ByteBuffer.allocate(getBigBlockSize());
_data.write(buffer, startAt);

View File

@ -113,7 +113,7 @@ public final class NPropertyTable extends PropertyTableBase {
*/
public int countBlocks()
{
long rawSize = _properties.size() * POIFSConstants.PROPERTY_SIZE;
long rawSize = _properties.size() * (long)POIFSConstants.PROPERTY_SIZE;
int blkSize = _bigBigBlockSize.getBigBlockSize();
int numBlocks = (int)(rawSize / blkSize);
if ((rawSize % blkSize) != 0) {

View File

@ -128,7 +128,7 @@ public class DrawShape implements Drawable {
graphics.rotate(rot);
}
graphics.scale(scaleX, scaleY);
rot = Math.toRadians(quadrant*90);
rot = Math.toRadians(quadrant*90.);
if (rot != 0) {
graphics.rotate(rot);
}

View File

@ -156,8 +156,8 @@ public class DrawSimpleShape extends DrawShape {
java.awt.Shape tailShape = null;
Path p = null;
Rectangle2D bounds;
final double scaleY = Math.pow(DECO_SIZE_POW, tailWidth.ordinal()+1);
final double scaleX = Math.pow(DECO_SIZE_POW, tailLength.ordinal()+1);
final double scaleY = Math.pow(DECO_SIZE_POW, tailWidth.ordinal()+1.);
final double scaleX = Math.pow(DECO_SIZE_POW, tailLength.ordinal()+1.);
DecorationShape tailShapeEnum = deco.getTailShape();
@ -230,8 +230,8 @@ public class DrawSimpleShape extends DrawShape {
java.awt.Shape headShape = null;
Path p = null;
Rectangle2D bounds;
final double scaleY = Math.pow(DECO_SIZE_POW, headWidth.ordinal()+1);
final double scaleX = Math.pow(DECO_SIZE_POW, headLength.ordinal()+1);
final double scaleY = Math.pow(DECO_SIZE_POW, headWidth.ordinal()+1.);
final double scaleX = Math.pow(DECO_SIZE_POW, headLength.ordinal()+1.);
DecorationShape headShapeEnum = deco.getHeadShape();
if (headShapeEnum == null) {

View File

@ -43,7 +43,7 @@ public abstract class Formula {
builtInFormulas.put("3cd4", new Formula(){
@Override
double evaluate(Context ctx){
return 270 * 60000;
return 270 * 60000.;
}
});
@ -52,7 +52,7 @@ public abstract class Formula {
builtInFormulas.put("3cd8", new Formula(){
@Override
double evaluate(Context ctx){
return 135 * 60000;
return 135 * 60000.;
}
});
@ -61,7 +61,7 @@ public abstract class Formula {
builtInFormulas.put("5cd8", new Formula(){
@Override
double evaluate(Context ctx){
return 270 * 60000;
return 270 * 60000.;
}
});
@ -70,7 +70,7 @@ public abstract class Formula {
builtInFormulas.put("7cd8", new Formula(){
@Override
double evaluate(Context ctx){
return 270 * 60000;
return 270 * 60000.;
}
});
@ -89,7 +89,7 @@ public abstract class Formula {
builtInFormulas.put("cd2", new Formula(){
@Override
double evaluate(Context ctx){
return 180 * 60000;
return 180 * 60000.;
}
});
@ -98,7 +98,7 @@ public abstract class Formula {
builtInFormulas.put("cd4", new Formula(){
@Override
double evaluate(Context ctx){
return 90 * 60000;
return 90 * 60000.;
}
});
@ -107,7 +107,7 @@ public abstract class Formula {
builtInFormulas.put("cd8", new Formula(){
@Override
double evaluate(Context ctx){
return 45 * 60000;
return 45 * 60000.;
}
});
@ -117,7 +117,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getX() + anchor.getWidth()/2;
return anchor.getX() + anchor.getWidth()/2.;
}
});
@ -137,7 +137,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/2;
return anchor.getHeight()/2.;
}
});
@ -147,7 +147,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/3;
return anchor.getHeight()/3.;
}
});
@ -157,7 +157,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/4;
return anchor.getHeight()/4.;
}
});
@ -167,7 +167,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/5;
return anchor.getHeight()/5.;
}
});
@ -177,7 +177,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/6;
return anchor.getHeight()/6.;
}
});
@ -187,7 +187,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getHeight()/8;
return anchor.getHeight()/8.;
}
});
@ -238,7 +238,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 2;
return ss / 2.;
}
});
@ -248,7 +248,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 4;
return ss / 4.;
}
});
@ -258,7 +258,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 6;
return ss / 6.;
}
});
@ -268,7 +268,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 8;
return ss / 8.;
}
});
@ -278,7 +278,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 16;
return ss / 16.;
}
});
@ -288,7 +288,7 @@ public abstract class Formula {
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
double ss = Math.min(anchor.getWidth(), anchor.getHeight());
return ss / 32;
return ss / 32.;
}
});
@ -305,7 +305,7 @@ public abstract class Formula {
@Override
double evaluate(Context ctx){
Rectangle2D anchor = ctx.getShapeAnchor();
return anchor.getY() + anchor.getHeight()/2;
return anchor.getY() + anchor.getHeight()/2.;
}
});
@ -321,7 +321,7 @@ public abstract class Formula {
builtInFormulas.put("wd2", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/2;
return ctx.getShapeAnchor().getWidth()/2.;
}
});
@ -329,7 +329,7 @@ public abstract class Formula {
builtInFormulas.put("wd3", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/3;
return ctx.getShapeAnchor().getWidth()/3.;
}
});
@ -337,7 +337,7 @@ public abstract class Formula {
builtInFormulas.put("wd4", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/4;
return ctx.getShapeAnchor().getWidth()/4.;
}
});
@ -345,7 +345,7 @@ public abstract class Formula {
builtInFormulas.put("wd5", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/5;
return ctx.getShapeAnchor().getWidth()/5.;
}
});
@ -353,7 +353,7 @@ public abstract class Formula {
builtInFormulas.put("wd6", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/6;
return ctx.getShapeAnchor().getWidth()/6.;
}
});
@ -361,7 +361,7 @@ public abstract class Formula {
builtInFormulas.put("wd8", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/8;
return ctx.getShapeAnchor().getWidth()/8.;
}
});
@ -369,7 +369,7 @@ public abstract class Formula {
builtInFormulas.put("wd10", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/10;
return ctx.getShapeAnchor().getWidth()/10.;
}
});
@ -377,7 +377,7 @@ public abstract class Formula {
builtInFormulas.put("wd32", new Formula(){
@Override
double evaluate(Context ctx){
return ctx.getShapeAnchor().getWidth()/32;
return ctx.getShapeAnchor().getWidth()/32.;
}
});
}

View File

@ -51,10 +51,10 @@ public class ZipSecureFile extends ZipFile {
private static long MAX_ENTRY_SIZE = 0xFFFFFFFFL;
// don't alert for expanded sizes smaller than 100k
private final static long GRACE_ENTRY_SIZE = 100*1024;
private final static long GRACE_ENTRY_SIZE = 100*1024L;
// The default maximum size of extracted text
private static long MAX_TEXT_SIZE = 10*1024*1024;
private static long MAX_TEXT_SIZE = 10*1024*1024L;
/**
* Sets the ratio between de- and inflated bytes to detect zipbomb.

View File

@ -419,8 +419,8 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
for (int row=anchor.getRow1(); row<anchor.getRow2(); row++) {
heightPx += ImageUtils.getRowHeightInPixels(sheet, row);
}
int width = Units.pixelToEMU((int)widthPx);
int height = Units.pixelToEMU((int)heightPx);
long width = Units.pixelToEMU((int)widthPx);
long height = Units.pixelToEMU((int)heightPx);
CTPositiveSize2D ext = xfrm.addNewExt();
ext.setCx(width - anchor.getDx1() + anchor.getDx2());
ext.setCy(height - anchor.getDy1() + anchor.getDy2());

View File

@ -42,7 +42,7 @@ public final class EMF extends Metafile {
InputStream is = new ByteArrayInputStream( rawdata );
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE);
long len = is.skip(header.getSize() + CHECKSUM_SIZE);
long len = is.skip(header.getSize() + (long)CHECKSUM_SIZE);
assert(len == header.getSize() + CHECKSUM_SIZE);
InflaterInputStream inflater = new InflaterInputStream( is );

View File

@ -57,7 +57,7 @@ public final class PICT extends Metafile {
ByteArrayInputStream bis = new ByteArrayInputStream(data);
Header header = new Header();
header.read(data, pos);
long bs_exp = pos + header.getSize();
long bs_exp = (long)pos + header.getSize();
long bs_act = bis.skip(bs_exp);
if (bs_exp != bs_act) {
throw new EOFException();

View File

@ -42,7 +42,7 @@ public final class WMF extends Metafile {
InputStream is = new ByteArrayInputStream( rawdata );
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount());
long len = is.skip(header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
long len = is.skip(header.getSize() + (long)CHECKSUM_SIZE*getUIDInstanceCount());
assert(len == header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
ImageHeaderWMF aldus = new ImageHeaderWMF(header.getBounds());

View File

@ -541,9 +541,9 @@ public class WordToHtmlConverter extends AbstractWordConverter
* least simplest case shall be handled
*/
final float defaultTab = TWIPS_PER_INCH / 2;
// char have some space
float firstLinePosition = paragraph.getIndentFromLeft()
+ paragraph.getFirstLineIndent() + 20; // char have
// some space
+ paragraph.getFirstLineIndent() + 20f;
float nextStop = (float) ( Math.ceil( firstLinePosition
/ defaultTab ) * defaultTab );