]> source.dussan.org Git - poi.git/commitdiff
Sonarqube fixes - Cast one of the operands of this multiplication operation to a ...
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 1 Jan 2017 22:59:35 +0000 (22:59 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 1 Jan 2017 22:59:35 +0000 (22:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1776894 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
src/java/org/apache/poi/hpsf/Section.java
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java
src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
src/java/org/apache/poi/poifs/property/NPropertyTable.java
src/java/org/apache/poi/sl/draw/DrawShape.java
src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
src/java/org/apache/poi/sl/draw/geom/Formula.java
src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java

index 4de1207f429c7b60dce61dffe2155d038524bfa0..301d7ed784d171c1a588b50070e73f17ae562582 100644 (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.
index a27e9485cd6e4f126951af9d9c19623b2001e3aa..306e14a22f281d1a5acb6008f23a000792369c4e 100644 (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]);
index e781c9d894b1bea9465891e44b5e6218b2cc115b..1a31d2a0c5a9a65b9ba6c43902db4c0580b4660a 100644 (file)
@@ -170,7 +170,7 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
         LittleEndianInputStream leis = new LittleEndianInputStream(sbis);\r
         int streamDescriptorArrayOffset = (int) leis.readUInt();\r
         /* int streamDescriptorArraySize = (int) */ leis.readUInt();\r
-        sbis.skip(streamDescriptorArrayOffset - 8);\r
+        sbis.skip(streamDescriptorArrayOffset - 8L);\r
         sbis.setBlock(0);\r
         int encryptedStreamDescriptorCount = (int) leis.readUInt();\r
         StreamDescriptorEntry entries[] = new StreamDescriptorEntry[encryptedStreamDescriptorCount];\r
index 0d09c47147faea1ae8e280f09fb97f10a3558ff7..d193b05ca1a99a0cc4fddbb3d4e55effc5294169 100644 (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
index f987c43b31ceea18f72aa555afff8e1b7a1d1efd..ac8f8ff9f6313d8ebe5894deeb18da118d093ea4 100644 (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);
index 7117bc2e0f795b40c06cc1d19a51b83252facdb9..12b4ffe194e3022d54c19df03f6c5725c5a0e422 100644 (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) {
index 1d0eca0008e61017c11b6430de13f3d610541523..b7b0915c1829db378dfd50707ad5d912b7bb292a 100644 (file)
@@ -128,7 +128,7 @@ public class DrawShape implements Drawable {
                         graphics.rotate(rot);\r
                     }\r
                     graphics.scale(scaleX, scaleY);\r
-                    rot = Math.toRadians(quadrant*90);\r
+                    rot = Math.toRadians(quadrant*90.);\r
                     if (rot != 0) {\r
                         graphics.rotate(rot);\r
                     }\r
index 1032750690a41d93db9c11df0e342c0e2a208e42..cfd6cf991b8c7027b710f32342098f7736a64d76 100644 (file)
@@ -156,8 +156,8 @@ public class DrawSimpleShape extends DrawShape {
         java.awt.Shape tailShape = null;\r
         Path p = null;\r
         Rectangle2D bounds;\r
-        final double scaleY = Math.pow(DECO_SIZE_POW, tailWidth.ordinal()+1);\r
-        final double scaleX = Math.pow(DECO_SIZE_POW, tailLength.ordinal()+1);\r
+        final double scaleY = Math.pow(DECO_SIZE_POW, tailWidth.ordinal()+1.);\r
+        final double scaleX = Math.pow(DECO_SIZE_POW, tailLength.ordinal()+1.);\r
 \r
         DecorationShape tailShapeEnum = deco.getTailShape();\r
 \r
@@ -230,8 +230,8 @@ public class DrawSimpleShape extends DrawShape {
         java.awt.Shape headShape = null;\r
         Path p = null;\r
         Rectangle2D bounds;\r
-        final double scaleY = Math.pow(DECO_SIZE_POW, headWidth.ordinal()+1);\r
-        final double scaleX = Math.pow(DECO_SIZE_POW, headLength.ordinal()+1);\r
+        final double scaleY = Math.pow(DECO_SIZE_POW, headWidth.ordinal()+1.);\r
+        final double scaleX = Math.pow(DECO_SIZE_POW, headLength.ordinal()+1.);\r
         DecorationShape headShapeEnum = deco.getHeadShape();\r
 \r
         if (headShapeEnum == null) {\r
index 47453475af903175d3066ac121bdd40ae2012b66..06730ffc4acaf7571d5354ed1008f154f9566181 100644 (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.;
             }
          });
     }
index d1fc0cb1df31d156b31b3fd618e245a56796ede6..0040d64fa94b31af7254529dc3bf13f15db72346 100644 (file)
@@ -51,10 +51,10 @@ public class ZipSecureFile extends ZipFile {
     private static long MAX_ENTRY_SIZE = 0xFFFFFFFFL;\r
     \r
     // don't alert for expanded sizes smaller than 100k\r
-    private final static long GRACE_ENTRY_SIZE = 100*1024;\r
+    private final static long GRACE_ENTRY_SIZE = 100*1024L;\r
 \r
     // The default maximum size of extracted text \r
-    private static long MAX_TEXT_SIZE = 10*1024*1024;\r
+    private static long MAX_TEXT_SIZE = 10*1024*1024L;\r
     \r
     /**\r
      * Sets the ratio between de- and inflated bytes to detect zipbomb.\r
index 8f409fce318b225d88ac70578ee5140a3f1a5245..5c7395ed3ebd673addb46e4ccbc22d1f18e6394e 100644 (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());
index 39cd93bc5bcbacc0b76c50a6c6178f0f23e0d960..59ace3b59984bd04ca439bfadbe710c827a142f5 100644 (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 );
index 315836c91e10f6771c5266322ede1d4c17bbcb79..df55f4c687eee293ab04029508aee7ffeb956bbc 100644 (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();
index dd88b90fe38bb499e9e362ca9678a21d2ef91f23..8f02df41dee70c53ab6e5204b5441a9ebcfc87eb 100644 (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());
index 1e10bd6e3f86e176b062ed0ae1e9be6e3ae55405..dcb40b6932c643153e6e40fd35663c7af4e818ca 100644 (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 );