aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2017-01-01 22:59:35 +0000
committerAndreas Beeker <kiwiwings@apache.org>2017-01-01 22:59:35 +0000
commitda20cf5d63600e1655252c3e9ac6251075e83c23 (patch)
tree91d4518e28b5eeb9b4b8b511359601756311a5df
parentabf3eb7d8449b332c0089538d7b35339559bf323 (diff)
downloadpoi-da20cf5d63600e1655252c3e9ac6251075e83c23.tar.gz
poi-da20cf5d63600e1655252c3e9ac6251075e83c23.zip
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
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java6
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java2
-rw-r--r--src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java2
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java2
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java4
-rw-r--r--src/java/org/apache/poi/poifs/property/NPropertyTable.java2
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawShape.java2
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawSimpleShape.java8
-rw-r--r--src/java/org/apache/poi/sl/draw/geom/Formula.java58
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java4
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java4
15 files changed, 52 insertions, 52 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
index 4de1207f42..301d7ed784 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
@@ -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.
diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java
index a27e9485cd..306e14a22f 100644
--- a/src/java/org/apache/poi/hpsf/Section.java
+++ b/src/java/org/apache/poi/hpsf/Section.java
@@ -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]);
diff --git a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
index e781c9d894..1a31d2a0c5 100644
--- a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
+++ b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
@@ -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];
diff --git a/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java b/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java
index 0d09c47147..d193b05ca1 100644
--- a/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java
+++ b/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java
@@ -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
diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
index f987c43b31..ac8f8ff9f6 100644
--- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
+++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
@@ -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);
diff --git a/src/java/org/apache/poi/poifs/property/NPropertyTable.java b/src/java/org/apache/poi/poifs/property/NPropertyTable.java
index 7117bc2e0f..12b4ffe194 100644
--- a/src/java/org/apache/poi/poifs/property/NPropertyTable.java
+++ b/src/java/org/apache/poi/poifs/property/NPropertyTable.java
@@ -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) {
diff --git a/src/java/org/apache/poi/sl/draw/DrawShape.java b/src/java/org/apache/poi/sl/draw/DrawShape.java
index 1d0eca0008..b7b0915c18 100644
--- a/src/java/org/apache/poi/sl/draw/DrawShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawShape.java
@@ -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);
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
index 1032750690..cfd6cf991b 100644
--- a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
@@ -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) {
diff --git a/src/java/org/apache/poi/sl/draw/geom/Formula.java b/src/java/org/apache/poi/sl/draw/geom/Formula.java
index 47453475af..06730ffc4a 100644
--- a/src/java/org/apache/poi/sl/draw/geom/Formula.java
+++ b/src/java/org/apache/poi/sl/draw/geom/Formula.java
@@ -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.;
}
});
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java b/src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java
index d1fc0cb1df..0040d64fa9 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java
@@ -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.
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
index 8f409fce31..5c7395ed3e 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
@@ -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());
diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
index 39cd93bc5b..59ace3b599 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
@@ -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 );
diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
index 315836c91e..df55f4c687 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
@@ -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();
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 dd88b90fe3..8f02df41de 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
@@ -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());
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
index 1e10bd6e3f..dcb40b6932 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
@@ -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 );