]> source.dussan.org Git - poi.git/commitdiff
fix unnecessary cast warnings
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 22 Nov 2015 12:30:42 +0000 (12:30 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 22 Nov 2015 12:30:42 +0000 (12:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1715626 13f79535-47bb-0310-9956-ffa450edef68

29 files changed:
src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java
src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java
src/java/org/apache/poi/hssf/record/CFRuleBase.java
src/java/org/apache/poi/hssf/record/cf/DataBarFormatting.java
src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java
src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java
src/java/org/apache/poi/ss/format/SimpleFraction.java
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java
src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/FSPAAbstractType.java
src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java
src/testcases/org/apache/poi/hpsf/TestVariantSupport.java
src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java
src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java
src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java
src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java
src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java

index 6482f186c0d0be9da3639da0bbad5cb9835ab0f4..77a077582f6f2bf71cf331cb56a94811705b5ec0 100644 (file)
@@ -250,7 +250,6 @@ public class AddDimensionedImage {
             String imageFile, double reqImageWidthMM, double reqImageHeightMM,
             int resizeBehaviour) throws FileNotFoundException, IOException,
                                                      IllegalArgumentException  {
-        HSSFRow row = null;
         HSSFClientAnchor anchor = null;
         HSSFPatriarch patriarch = null;
         ClientAnchorDetail rowClientAnchorDetail = null;
@@ -720,7 +719,6 @@ public class AddDimensionedImage {
     public static void main(String[] args) {
         String imageFile = null;
         String outputFile = null;
-        FileInputStream fis = null;
         FileOutputStream fos = null;
         HSSFWorkbook workbook = null;
         HSSFSheet sheet = null;
@@ -753,14 +751,20 @@ public class AddDimensionedImage {
             ioEx.printStackTrace(System.out);
         }
         finally {
-            if(fos != null) {
-                try {
+            try {
+                if (workbook != null) {
+                    workbook.close();
+                }
+            } catch(IOException ioEx) {
+                // I G N O R E
+            }
+            try {
+                if(fos != null) {
                     fos.close();
                     fos = null;
                 }
-                catch(IOException ioEx) {
-                    // I G N O R E
-                }
+            } catch(IOException ioEx) {
+                // I G N O R E
             }
         }
     }
@@ -912,7 +916,7 @@ public class AddDimensionedImage {
             int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR)
                     * UNIT_OFFSET_LENGTH;
             int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
-            pixels += Math.round((float) offsetWidthUnits /
+            pixels += Math.round(offsetWidthUnits /
                     ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));
             return pixels;
         }
index 1739eb61603479a1eda2426e0421f10fa70caf43..caace28f7fe387c76c99259ddc03b03c8a100bab 100644 (file)
@@ -163,7 +163,7 @@ public class SVSheetTable extends JTable {
       Row row = sheet.getRow(i - sheet.getFirstRowNum());
       if (row != null) {
         short h = row.getHeight();
-        int height = (int)Math.round(Math.max(1., ((double)h) / (((double)res) / 70. * 20.) + 3.));
+        int height = (int)Math.round(Math.max(1., h / (res / 70. * 20.) + 3.));
         System.out.printf("%d: %d (%d @ %d)%n", i, height, h, res);
         setRowHeight(i, height);
       }
index b0c57b0fe0875a2696c61104fa50e6b71551546c..9714b7e2b0fb8d5ba38f06930422ad4242816e2e 100644 (file)
 
 package org.apache.poi.hssf.view;
 
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.table.*;
-
-import org.apache.poi.hssf.usermodel.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+import java.util.Map;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.table.TableCellEditor;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.util.HSSFColor;
 
 /**
@@ -43,9 +54,6 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
   private HSSFWorkbook wb;
   private JTextField editor;
 
-  private HSSFCell editorValue;
-
-
   public SVTableCellEditor(HSSFWorkbook wb) {
     this.wb = wb;
     this.editor = new JTextField();
@@ -191,7 +199,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
      *
      */
     private final Color getAWTColor(int index, Color deflt) {
-      HSSFColor clr = (HSSFColor)colors.get(Integer.valueOf(index));
+      HSSFColor clr = colors.get(index);
       if (clr == null) return deflt;
       return getAWTColor(clr);
     }
index 23ffb851bdab4b296122d4201e27dd1aff3bd731..395f1cdb8d0c52de2d23d2ecd30666e94f73cba9 100644 (file)
@@ -72,7 +72,7 @@ public class SVTableUtils {
    * @return        The aWTColor value
    */
   public final static Color getAWTColor(int index, Color deflt) {
-    HSSFColor clr = (HSSFColor) colors.get(Integer.valueOf(index));
+    HSSFColor clr = colors.get(index);
     if (clr == null) {
       return deflt;
     }
index a5435c0ce3a17996bcd685b9777d67d0789f4cdb..531e66b92397b104fb20d7b551aaec1c8029636a 100644 (file)
@@ -182,7 +182,7 @@ public class TreeReaderListener implements POIFSReaderListener
                                     final String fsName,
                                     final MutableTreeNode root)
     {
-        MutableTreeNode n = (MutableTreeNode) pathToNode.get(path);
+        MutableTreeNode n = pathToNode.get(path);
         if (n != null)
             /* Node found in map, just return it. */
             return n;
@@ -193,7 +193,7 @@ public class TreeReaderListener implements POIFSReaderListener
              * the POI filesystem itself. This is a tree node with the
              * POI filesystem's name (this the operating system file's
              * name) as its key it the path-to-node map. */
-            n = (MutableTreeNode) pathToNode.get(fsName);
+            n = pathToNode.get(fsName);
             if (n == null)
             {
                 /* A tree node for the POI filesystem does not yet
index a2c61e2e2650aad959a434ce8eb205c462916e55..518ec37f48498c5922fa79f79d12601dfbcbefd7 100644 (file)
@@ -34,7 +34,7 @@ public class CreatePivotTable {
 
     public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException {
         XSSFWorkbook wb = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) wb.createSheet();
+        XSSFSheet sheet = wb.createSheet();
 
         //Create some data to build the pivot table on
         setCellData(sheet);
@@ -53,6 +53,7 @@ public class CreatePivotTable {
         FileOutputStream fileOut = new FileOutputStream("ooxml-pivottable.xlsx");
         wb.write(fileOut);
         fileOut.close();
+        wb.close();
     }
 
     public static void setCellData(XSSFSheet sheet){
index a7bfb825c5997e74a523b93c4ccbbbcb93ed3d44..e8eece7cf80e5bff1e4d02e15d7c4ec24f784f00 100644 (file)
@@ -440,10 +440,10 @@ public abstract class CFRuleBase extends StandardRecord implements Cloneable {
         rec.formatting_options = formatting_options;
         rec.formatting_not_used = formatting_not_used;
         if (containsFontFormattingBlock()) {
-            rec._fontFormatting = (FontFormatting) _fontFormatting.clone();
+            rec._fontFormatting = _fontFormatting.clone();
         }
         if (containsBorderFormattingBlock()) {
-            rec._borderFormatting = (BorderFormatting) _borderFormatting.clone();
+            rec._borderFormatting = _borderFormatting.clone();
         }
         if (containsPatternFormattingBlock()) {
             rec._patternFormatting = (PatternFormatting) _patternFormatting.clone();
index 3ca419553eab22ec98456d49f48309cae6d225bf..8810ef59c54697c8f0b5322694f3f5f25e55417e 100644 (file)
@@ -135,9 +135,9 @@ public final class DataBarFormatting implements Cloneable {
       rec.options = options;
       rec.percentMin = percentMin;
       rec.percentMax = percentMax;
-      rec.color = (ExtendedColor)color.clone();
-      rec.thresholdMin = (DataBarThreshold)thresholdMin.clone();
-      rec.thresholdMax = (DataBarThreshold)thresholdMax.clone();
+      rec.color = color.clone();
+      rec.thresholdMin = thresholdMin.clone();
+      rec.thresholdMax = thresholdMax.clone();
       return rec;
     }
     
index cd2f337fdbe18342886c35fc33e3445f9dd9e99a..36cefe532ae6e6d2ea21e9b5301c616c82396554 100644 (file)
@@ -176,7 +176,7 @@ public class CTSRgbColor {
      *     \r
      */\r
     public void setVal(byte[] value) {\r
-        this.val = ((byte[]) value);\r
+        this.val = (value != null) ? value.clone() : null;\r
     }\r
 \r
     public boolean isSetVal() {\r
index e9c21832dab435ce56a6ebce53d0a951a99aa66b..1300f87f56fccf938a55c6184ad8d915c5680b27 100644 (file)
@@ -209,7 +209,7 @@ public class CTSystemColor {
      *     \r
      */\r
     public void setLastClr(byte[] value) {\r
-        this.lastClr = ((byte[]) value);\r
+        this.lastClr = (value != null) ? value.clone() : null;\r
     }\r
 \r
     public boolean isSetLastClr() {\r
index 41d0a2aa832ebe1e7693ca4e006a4f6abe96af60..dec5a275f31bf3cecc3f5b4e6fe51c05416d5832 100644 (file)
@@ -32,7 +32,7 @@ public class SimpleFraction {
      * @return a SimpleFraction with the given values set.
      */
     public static SimpleFraction buildFractionExactDenominator(double val, int exactDenom){
-        int num =  (int)Math.round(val*(double)exactDenom);
+        int num =  (int)Math.round(val*exactDenom);
         return new SimpleFraction(num,exactDenom);
     }
     
index bd8018fbff19b7eae79bb6a02bcd399899d5ee0f..7ce130d54ea00dc95f57be392bce17b557b018a1 100644 (file)
 
 package org.apache.poi.xssf.streaming;
 
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import junit.framework.TestCase;
+import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
 
-public final class TestOutlining extends TestCase {
-       public void testSetRowGroupCollapsed() throws Exception {
+public final class TestOutlining {
+    @Test
+       public void testSetRowGroupCollapsed() throws IOException {
                SXSSFWorkbook wb2 = new SXSSFWorkbook(100);
                wb2.setCompressTempFiles(true);
-               SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet");
+               SXSSFSheet sheet2 = wb2.createSheet("new sheet");
 
                int rowCount = 20;
                for (int i = 0; i < rowCount; i++) {
@@ -45,21 +51,22 @@ public final class TestOutlining extends TestCase {
 
                sheet2.setRowGroupCollapsed(4, true);
 
-               SXSSFRow r = (SXSSFRow) sheet2.getRow(8);
+               SXSSFRow r = sheet2.getRow(8);
                assertTrue(r.getHidden());
-               r = (SXSSFRow) sheet2.getRow(10);
+               r = sheet2.getRow(10);
                assertTrue(r.getCollapsed());
-               r = (SXSSFRow) sheet2.getRow(12);
+               r = sheet2.getRow(12);
                assertNull(r.getHidden());
                wb2.dispose();
                
                wb2.close();
        }
 
-       public void testSetRowGroupCollapsedError() throws Exception {
+    @Test
+    public void testSetRowGroupCollapsedError() throws IOException {
                SXSSFWorkbook wb2 = new SXSSFWorkbook(100);
                wb2.setCompressTempFiles(true);
-               SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet");
+               SXSSFSheet sheet2 = wb2.createSheet("new sheet");
 
                int rowCount = 20;
                for (int i = 0; i < rowCount; i++) {
@@ -98,18 +105,19 @@ public final class TestOutlining extends TestCase {
                                        e.getMessage().contains("Row does not exist"));
                }
 
-               SXSSFRow r = (SXSSFRow) sheet2.getRow(8);
+               SXSSFRow r = sheet2.getRow(8);
                assertNotNull(r);
                assertNull(r.getHidden());
-               r = (SXSSFRow) sheet2.getRow(10);
+               r = sheet2.getRow(10);
                assertNull(r.getCollapsed());
-               r = (SXSSFRow) sheet2.getRow(12);
+               r = sheet2.getRow(12);
                assertNull(r.getHidden());
                wb2.dispose();
                
                wb2.close();
        }
        
+    @Test
     public void testOutlineGettersHSSF() throws IOException {
         HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
         HSSFSheet hssfSheet = hssfWorkbook.createSheet();
@@ -129,6 +137,7 @@ public final class TestOutlining extends TestCase {
         hssfWorkbook.close();
     }
     
+    @Test
     public void testOutlineGettersXSSF() throws IOException {
         XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
         XSSFSheet xssfSheet = xssfWorkbook.createSheet();
@@ -148,6 +157,7 @@ public final class TestOutlining extends TestCase {
         xssfWorkbook.close();
     }
     
+    @Test
     public void testOutlineGettersSXSSF() throws IOException {
         SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook();
         Sheet sxssfSheet = sxssfWorkbook.createSheet();
@@ -190,6 +200,7 @@ public final class TestOutlining extends TestCase {
         sxssfWorkbook.close();
     }
     
+    @Test
     public void testOutlineGettersSXSSFSetOutlineLevel() throws IOException {
         SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook();
         Sheet sxssfSheet = sxssfWorkbook.createSheet();
index 521e73e0ca69ac2e3396e4afcb6c72aa9697ccbc..110a7ef565644c190e965aa6f91260dc37531082 100644 (file)
@@ -37,7 +37,6 @@ public final class OldSectionTable extends SectionTable
      * @deprecated Use {@link #OldSectionTable(byte[],int,int)} instead
      */
     @Deprecated
-    @SuppressWarnings( "unused" )
     public OldSectionTable( byte[] documentStream, int offset, int size,
             int fcMin, TextPieceTable tpt )
     {
index 57fdaef1b29cb0c0b7f218b3df3e035ee54989ae..cae8089c48e3c45ae9873ba06422c39e119e5f20 100644 (file)
@@ -61,7 +61,6 @@ public class PAPBinTable
      *             {@link #PAPBinTable(byte[], byte[], byte[], int, int, CharIndexTranslator)}
      *             instead
      */
-    @SuppressWarnings( "unused" )
     public PAPBinTable( byte[] documentStream, byte[] tableStream,
             byte[] dataStream, int offset, int size, int fcMin,
             TextPieceTable tpt )
index 01c5d22e5df06ed38cac6e53d5eaa1823c0dc408..11f7d2af4eaa8a1784d4996d58bc2d7aadf442e5 100644 (file)
@@ -214,7 +214,7 @@ public class Sttb
 \r
             if ( _fExtend )\r
             {\r
-                LittleEndian.putUShort( buffer, offset, (int) entry.length() );\r
+                LittleEndian.putUShort( buffer, offset, entry.length() );\r
                 offset += LittleEndian.SHORT_SIZE;\r
 \r
                 StringUtil.putUnicodeLE( entry, buffer, offset );\r
index a3a916d0b2ad535c40e47eb31684e03ba8e92f8e..ee71c2bab7b923347a32ffc3b1ca6754b7a7f9e6 100644 (file)
@@ -79,7 +79,7 @@ public abstract class FSPAAbstractType
         LittleEndian.putInt(data, 0x8 + offset, field_3_yaTop);\r
         LittleEndian.putInt(data, 0xc + offset, field_4_xaRight);\r
         LittleEndian.putInt(data, 0x10 + offset, field_5_yaBottom);\r
-        LittleEndian.putShort(data, 0x14 + offset, (short)field_6_flags);\r
+        LittleEndian.putShort(data, 0x14 + offset, field_6_flags);\r
         LittleEndian.putInt(data, 0x16 + offset, field_7_cTxbx);\r
     }\r
 \r
index 44263ace5c183c1e68655c0dc36cc5c3d62c5b71..8d737299a8197d7864919a004c411bd19c049f03 100644 (file)
@@ -70,7 +70,7 @@ public final class TestCruddyExtractor extends TestCase {
                // Ensure they match
                assertEquals(allTheText.length,foundTextV.size());
                for(int i=0; i<allTheText.length; i++) {
-                       String foundText = (String)foundTextV.get(i);
+                       String foundText = foundTextV.get(i);
                        assertEquals(allTheText[i],foundText);
                }
        }
index cddaee7e439ebe0c0f6d26588ed5b419c96d8d34..72b692e882ad042ec1750fc351e542487b42b7bf 100644 (file)
 
 package org.apache.poi.hwpf.usermodel;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.TestCase;
+import java.util.List;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
 import org.apache.poi.hwpf.model.PicturesTable;
+import org.junit.Test;
 
 /**
  * Test the picture handling
  *
  * @author Nick Burch
  */
-public final class TestPictures extends TestCase {
+public final class TestPictures {
 
        /**
         * two jpegs
         */
+    @Test
        public void testTwoImages() {
                HWPFDocument doc = HWPFTestDataSamples.openSampleFile("two_images.doc");
                List<Picture> pics = doc.getPicturesTable().getAllPictures();
@@ -43,7 +47,7 @@ public final class TestPictures extends TestCase {
                assertNotNull(pics);
                assertEquals(pics.size(), 2);
                for(int i=0; i<pics.size(); i++) {
-                       Picture pic = (Picture)pics.get(i);
+                       Picture pic = pics.get(i);
                        assertNotNull(pic.suggestFileExtension());
                        assertNotNull(pic.suggestFullFileName());
                }
@@ -51,20 +55,20 @@ public final class TestPictures extends TestCase {
                Picture picA = pics.get(0);
                Picture picB = pics.get(1);
                assertEquals("jpg", picA.suggestFileExtension());
-               assertEquals("jpg", picA.suggestFileExtension());
+               assertEquals("png", picB.suggestFileExtension());
        }
 
        /**
         * pngs and jpegs
         */
+    @Test
        public void testDifferentImages() {
                HWPFDocument doc = HWPFTestDataSamples.openSampleFile("testPictures.doc");
                List<Picture> pics = doc.getPicturesTable().getAllPictures();
 
                assertNotNull(pics);
                assertEquals(7, pics.size());
-               for(int i=0; i<pics.size(); i++) {
-                       Picture pic = (Picture)pics.get(i);
+               for(Picture pic : pics) {
                        assertNotNull(pic.suggestFileExtension());
                        assertNotNull(pic.suggestFullFileName());
                }
@@ -86,6 +90,7 @@ public final class TestPictures extends TestCase {
        /**
         * emf image, nice and simple
         */
+    @Test
        public void testEmfImage() {
                HWPFDocument doc = HWPFTestDataSamples.openSampleFile("vector_image.doc");
                List<Picture> pics = doc.getPicturesTable().getAllPictures();
@@ -107,32 +112,37 @@ public final class TestPictures extends TestCase {
                }
        }
 
-       public void testPicturesWithTable() {
+    @Test
+    public void testPicturesWithTable() {
                HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug44603.doc");
 
                List<Picture> pics = doc.getPicturesTable().getAllPictures();
                assertEquals(2, pics.size());
        }
 
-       public void testPicturesInHeader() {
+    @Test
+    public void testPicturesInHeader() {
           HWPFDocument doc = HWPFTestDataSamples.openSampleFile("header_image.doc");
 
           List<Picture> pics = doc.getPicturesTable().getAllPictures();
           assertEquals(2, pics.size());
        }
 
+    @Test
     public void testFastSaved() {
        HWPFDocument doc = HWPFTestDataSamples.openSampleFile("rasp.doc");
 
        doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception
     }
 
+    @Test
     public void testFastSaved2() {
        HWPFDocument doc = HWPFTestDataSamples.openSampleFile("o_kurs.doc");
 
        doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception
     }
 
+    @Test
     public void testFastSaved3() {
        HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ob_is.doc");
 
@@ -146,7 +156,8 @@ public final class TestPictures extends TestCase {
      *  then used as-is to speed things up.
      * Check that we can properly read one of these
      */
-    public void testEmbededDocumentIcon() throws Exception {
+    @Test
+    public void testEmbededDocumentIcon() {
        // This file has two embeded excel files, an embeded powerpoint
        //   file and an embeded word file, in that order
        HWPFDocument doc = HWPFTestDataSamples.openSampleFile("word_with_embeded.doc");
@@ -231,6 +242,7 @@ public final class TestPictures extends TestCase {
         assertEquals( "image/x-emf", picture.getMimeType() );
     }
 
+    @Test
     public void testEquation()
     {
         HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "equation.doc" );
@@ -256,7 +268,8 @@ public final class TestPictures extends TestCase {
      *  \u0001 which has the offset. More than one can
      *  reference the same \u0001
      */
-    public void testFloatingPictures() throws Exception {
+    @Test
+    public void testFloatingPictures() {
        HWPFDocument doc = HWPFTestDataSamples.openSampleFile("FloatingPictures.doc");
        PicturesTable pictures = doc.getPicturesTable();
        
@@ -290,6 +303,7 @@ public final class TestPictures extends TestCase {
     }
 
     @SuppressWarnings( "deprecation" )
+    @Test
     public void testCroppedPictures() {
         HWPFDocument doc = HWPFTestDataSamples.openSampleFile("testCroppedPictures.doc");
         List<Picture> pics = doc.getPicturesTable().getAllPictures();
@@ -323,7 +337,8 @@ public final class TestPictures extends TestCase {
         assertEquals(0, pic2.getDyaCropBottom());
     }
 
-    public void testPictureDetectionWithPNG() throws Exception {
+    @Test
+    public void testPictureDetectionWithPNG() {
         HWPFDocument document = HWPFTestDataSamples.openSampleFile("PngPicture.doc");
         PicturesTable pictureTable = document.getPicturesTable();
         
@@ -334,7 +349,8 @@ public final class TestPictures extends TestCase {
         assertEquals("png", p.suggestFileExtension());
     }
     
-    public void testPictureWithAlternativeText() throws Exception {
+    @Test
+    public void testPictureWithAlternativeText() {
         HWPFDocument document = HWPFTestDataSamples.openSampleFile("Picture_Alternative_Text.doc");
         PicturesTable pictureTable = document.getPicturesTable();
         Picture picture = pictureTable.getAllPictures().get(0);
index 2e55486695e2f1d53ecd19781ac324794bf0e4d5..5e32812e8d53e3a017e267c97215244f28cacb6c 100644 (file)
 
 package org.apache.poi.hwpf.usermodel;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
 import org.apache.poi.hwpf.model.PAPX;
 
+import junit.framework.TestCase;
+
 /**
  *     Test to see if Range.delete() works even if the Range contains a
  *     CharacterRun that uses Unicode characters.
@@ -93,7 +93,7 @@ public final class TestRangeDelete extends TestCase {
                assertEquals(fillerText, para.text());
 
 
-               paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(2);
+               paraDef = daDoc.getParagraphTable().getParagraphs().get(2);
                assertEquals(132, paraDef.getStart());
                assertEquals(400, paraDef.getEnd());
 
@@ -102,7 +102,7 @@ public final class TestRangeDelete extends TestCase {
                assertEquals(originalText, para.text());
 
 
-               paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(3);
+               paraDef = daDoc.getParagraphTable().getParagraphs().get(3);
                assertEquals(400, paraDef.getStart());
                assertEquals(438, paraDef.getEnd());
 
index 963f657b96766ac43371cb38ac2a4df192b7e6ea..3b6354e4dace1362b1996193c1cde4e877a35041 100644 (file)
@@ -62,7 +62,7 @@ public class TestVariantSupport extends TestCase {
 
         PropertySet ps = PropertySetFactory.create(new ByteArrayInputStream(bytes));
         DocumentSummaryInformation dsi = (DocumentSummaryInformation) ps;
-        Section s = (Section) dsi.getSections().get(0);
+        Section s = dsi.getSections().get(0);
 
         Object hdrs =  s.getProperty(PropertyIDMap.PID_HEADINGPAIR);
 
index 8319657c690a1f5fb5fc7bdb894f6aacfd0d1991..8d69af8ba583685eee4d856bb7f81c15c1f1c085 100644 (file)
@@ -57,7 +57,7 @@ public final class TestAutoFilterInfoRecord extends TestCase {
         record.setNumEntries((short)3);
         byte[] src = record.serialize();
 
-        AutoFilterInfoRecord cloned = (AutoFilterInfoRecord)record.clone();
+        AutoFilterInfoRecord cloned = record.clone();
         assertEquals(3, record.getNumEntries());
         byte[] cln = cloned.serialize();
 
index c39e3e40487d46ad06b5b7483f240f6252d7db23..3b2591e89cbcf9484855b159699177633c0bffb8 100644 (file)
@@ -437,7 +437,7 @@ public final class TestCFRuleRecord extends TestCase {
 
         CFRuleRecord record = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5");
         
-        CFRuleRecord clone = (CFRuleRecord) record.clone();
+        CFRuleRecord clone = record.clone();
         
         byte [] serializedRecord = record.serialize();
         byte [] serializedClone = clone.serialize();
index f158f864224e5b9768e8e7b41cf1a9ccfeea5667..d8a1de9d03429d18c849a18f222975b1cd567df8 100644 (file)
@@ -56,7 +56,7 @@ public final class TestFtCblsSubRecord extends TestCase {
         FtCblsSubRecord record = new FtCblsSubRecord();
         byte[] src = record.serialize();
 
-        FtCblsSubRecord cloned = (FtCblsSubRecord)record.clone();
+        FtCblsSubRecord cloned = record.clone();
         byte[] cln = cloned.serialize();
 
         assertEquals(record.getDataSize(), cloned.getDataSize());
index d1e5631b9df6f8c18e734f8fc3d746731f8aa7d5..1bb3b1924c87a68b5f322b41a4378ca85c8766ea 100644 (file)
@@ -432,7 +432,7 @@ public final class TestHyperlinkRecord {
         for (int i = 0; i < data.length; i++) {
             RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data[i]);
             HyperlinkRecord link = new HyperlinkRecord(is);
-            HyperlinkRecord clone = (HyperlinkRecord)link.clone();
+            HyperlinkRecord clone = link.clone();
             assertArrayEquals(link.serialize(), clone.serialize());
         }
 
index a203ae4c2b04259dd423e4da4e056a8b545d62c9..1063c0c20811a5ffcd0723fad8c2014787ea9f46 100644 (file)
@@ -42,7 +42,7 @@ public final class TestMergeCellsRecord extends TestCase {
        public void testCloneReferences() {
                CellRangeAddress[] cras = { new CellRangeAddress(0, 1, 0, 2), };
                MergeCellsRecord merge = new MergeCellsRecord(cras, 0, cras.length);
-               MergeCellsRecord clone = (MergeCellsRecord)merge.clone();
+               MergeCellsRecord clone = merge.clone();
 
                assertNotSame("Merged and cloned objects are the same", merge, clone);
 
index 427a48f93513733a787aa974e34f8a84ed9d6966..4da04e014f514e25780642b09d0d9739964968cf 100644 (file)
@@ -73,7 +73,7 @@ public final class TestNoteRecord extends TestCase {
         record.setShapeId((short)1026);
         record.setAuthor("Apache Software Foundation");
 
-        NoteRecord cloned = (NoteRecord)record.clone();
+        NoteRecord cloned = record.clone();
         assertEquals(record.getRow(), cloned.getRow());
         assertEquals(record.getColumn(), cloned.getColumn());
         assertEquals(record.getFlags(), cloned.getFlags());
index db3367a033810b7c898b57755ccc33575b4da80f..1b5fb008e37a707cf66d1fc9765f09000fddcece 100644 (file)
@@ -58,7 +58,7 @@ public final class TestNoteStructureSubRecord extends TestCase {
         NoteStructureSubRecord record = new NoteStructureSubRecord();
         byte[] src = record.serialize();
 
-        NoteStructureSubRecord cloned = (NoteStructureSubRecord)record.clone();
+        NoteStructureSubRecord cloned = record.clone();
         byte[] cln = cloned.serialize();
 
         assertEquals(record.getDataSize(), cloned.getDataSize());
index 21494b39badd50329715030622b8a1f916d8d954..8153b53ea1c7ebecf6e9e7c0b4ba5f8fd857fbc9 100644 (file)
@@ -159,10 +159,7 @@ public final class TestDocument extends TestCase {
         }
         else
         {
-            copy = new OPOIFSDocument(
-                "test" + input.length,
-                ( SmallDocumentBlock [] ) document.getSmallBlocks(),
-                input.length);
+            copy = new OPOIFSDocument("test"+input.length, document.getSmallBlocks(), input.length);
         }
         return copy;
     }
index eb1b570300b942468ae21c613eb217d33e3baea5..18268068f5044726124fe4af441c6e9f5e55d09f 100644 (file)
@@ -20,8 +20,6 @@
  */
 package org.apache.poi.ss.formula.functions;
 
-import java.lang.reflect.Constructor;
-
 import org.apache.poi.ss.formula.functions.XYNumericFunction.Accumulator;
 
 
@@ -305,10 +303,10 @@ public class TestMathX extends AbstractNumericTestCase {
 
         assertEquals(0.0, MathX.mod(0, 2));
         assertEquals(Double.NaN, MathX.mod(3, 0));
-        assertEquals((double) 1.4, MathX.mod(3.4, 2));
-        assertEquals((double) -1.4, MathX.mod(-3.4, -2));
-        assertEquals((double) 0.6000000000000001, MathX.mod(-3.4, 2.0));// should actually be 0.6
-        assertEquals((double) -0.6000000000000001, MathX.mod(3.4, -2.0));// should actually be -0.6
+        assertEquals(1.4, MathX.mod(3.4, 2));
+        assertEquals(-1.4, MathX.mod(-3.4, -2));
+        assertEquals(0.6000000000000001, MathX.mod(-3.4, 2.0));// should actually be 0.6
+        assertEquals(-0.6000000000000001, MathX.mod(3.4, -2.0));// should actually be -0.6
         assertEquals(3.0, MathX.mod(3, Double.MAX_VALUE));
         assertEquals(2.0, MathX.mod(Double.MAX_VALUE, 3));