]> source.dussan.org Git - poi.git/commitdiff
Let IntelliJ cleanup some code-warnings across the whole code-base: unnecessary casts
authorDominik Stadler <centic@apache.org>
Sat, 16 Sep 2017 08:21:28 +0000 (08:21 +0000)
committerDominik Stadler <centic@apache.org>
Sat, 16 Sep 2017 08:21:28 +0000 (08:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808508 13f79535-47bb-0310-9956-ffa450edef68

46 files changed:
src/java/org/apache/poi/hssf/dev/FormulaViewer.java
src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
src/java/org/apache/poi/hssf/model/InternalWorkbook.java
src/java/org/apache/poi/hssf/record/EscherAggregate.java
src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java
src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
src/java/org/apache/poi/ss/usermodel/DateUtil.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
src/testcases/org/apache/poi/TestPOIDocumentMain.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java

index 4bf221f4def856c88a78165521d5dfe1b669a5f1..4ef3ede77a836f7be652feade6c354137ecb8fc7 100644 (file)
@@ -185,7 +185,7 @@ public class FormulaViewer
     
     private static String composeFormula(FormulaRecord record)
     {
-       return  HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, record.getParsedExpression());
+       return  HSSFFormulaParser.toFormulaString(null, record.getParsedExpression());
     }
 
     /**
index 107602d1c0b7b5da2360c4cf7af40cef84fefa77..f5475507a5b7fbbb80437fb218bc61924483075b 100644 (file)
@@ -203,7 +203,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or
                thisRow = frec.getRow();
 
                if(_formulasNotResults) {
-                   thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
+                   thisText = HSSFFormulaParser.toFormulaString(null, frec.getParsedExpression());
                } else {
                    if(frec.hasCachedResultString()) {
                        // Formula result is a string
index 9137e6984369842b8acb12d5f2df4e769ec1c065..72aa94696c57c376e5c2555a4791497f738398a8 100644 (file)
@@ -2169,7 +2169,7 @@ public final class InternalWorkbook {
                             sp.setShapeId(shapeId);
                         } else if (recordId == EscherOptRecord.RECORD_ID){
                             EscherOptRecord opt = (EscherOptRecord)shapeChildRecord;
-                            EscherSimpleProperty prop = (EscherSimpleProperty)opt.lookup(
+                            EscherSimpleProperty prop = opt.lookup(
                                     EscherProperties.BLIP__BLIPTODISPLAY );
                             if (prop != null){
                                 int pictureIndex = prop.getPropertyValue();
index 1fe343eb3702d9b3965064fbfd601d269ec567be..033b4a25a618de8c123aad9c31bd20db54d570d5 100644 (file)
@@ -522,7 +522,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
         }
 
         for (NoteRecord noteRecord : tailRec.values()) {
-            Record rec = (Record) noteRecord;
+            Record rec = noteRecord;
             pos += rec.serialize(pos, data);
         }
         int bytesWritten = pos - offset;
@@ -747,9 +747,9 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
      */
     public void setMainSpRecordId(int shapeId) {
         EscherContainerRecord dgContainer = getEscherContainer();
-        EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
+        EscherContainerRecord spgrConatiner = dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
         EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0);
-        EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID);
+        EscherSpRecord sp = spContainer.getChildById(EscherSpRecord.RECORD_ID);
         sp.setShapeId(shapeId);
     }
 
index 106da8b9983c0edac744fefb0d4ec1aa85d95796..ac72b997cea911ce2afcaf0a390991422d8151d5 100644 (file)
@@ -275,7 +275,7 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte
 
                short[] xfs = new short[nBlank];
                for (int i = 0; i < xfs.length; i++) {
-                       xfs[i] = ((BlankRecord)cellValues[startIx + i]).getXFIndex();
+                       xfs[i] = cellValues[startIx + i].getXFIndex();
                }
                int rowIx = cellValues[startIx].getRow();
                return new MulBlankRecord(rowIx, startIx, xfs);
index ef66389c5c35ca13905a865b59126b56bb7332c5..c3d9fdafe27c577c903b1ca6d934fa92be4d54fe 100644 (file)
@@ -247,7 +247,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
      * The filename of the embedded image
      */
     public String getFileName() {
-        EscherComplexProperty propFile = (EscherComplexProperty) getOptRecord().lookup(
+        EscherComplexProperty propFile = getOptRecord().lookup(
                       EscherProperties.BLIP__BLIPFILENAME);
         return (null == propFile)
             ? ""
index 7898317e8d325a8fa1ad78eff7d9c677dd423fc8..6e029b2385a94d1784d94fd9a5f1a465c7f6cc20 100644 (file)
@@ -174,7 +174,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
      */
     public void applyFont(int startIndex, int endIndex, Font font)
     {
-        applyFont(startIndex, endIndex, ((HSSFFont) font).getIndex());
+        applyFont(startIndex, endIndex, font.getIndex());
     }
 
     /**
index 08f304ad647210c7776cfe01d60794c9894f34ae..3a01126d433163dbf5214934218f6bef72152aec 100644 (file)
@@ -2130,7 +2130,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
      */
     @Override
     public void setDefaultColumnStyle(int column, CellStyle style) {
-        _sheet.setDefaultColumnStyle(column, ((HSSFCellStyle) style).getIndex());
+        _sheet.setDefaultColumnStyle(column, style.getIndex());
     }
 
     /**
index ccb008507b1e0f9d0eee54bcac3c51cc986045a9..b38881021b0e90c89934aaa86fd50a79d1c51d34 100644 (file)
@@ -69,7 +69,7 @@ public class DirectoryNode
                   final OPOIFSFileSystem filesystem,
                   final DirectoryNode parent)
     {
-       this(property, parent, filesystem, (NPOIFSFileSystem)null);
+       this(property, parent, filesystem, null);
     }
 
     /**
@@ -84,7 +84,7 @@ public class DirectoryNode
                   final NPOIFSFileSystem nfilesystem,
                   final DirectoryNode parent)
     {
-       this(property, parent, (OPOIFSFileSystem)null, nfilesystem);
+       this(property, parent, null, nfilesystem);
     }
 
     private DirectoryNode(final DirectoryProperty property,
index 18140d9df85de707e191b1e258c012164830e2d1..3d9b9c6615640545b36dec7bc51ffc056db7cb82 100644 (file)
@@ -34,25 +34,19 @@ public class EntryUtils
      */
     @Internal
     public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
-            throws IOException
-    {
+            throws IOException {
         // logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+
         // ","+target.getName());
-        DirectoryEntry newTarget = null;
-        if ( entry.isDirectoryEntry() )
-        {
+        if ( entry.isDirectoryEntry() ) {
                DirectoryEntry dirEntry = (DirectoryEntry)entry;
-            newTarget = target.createDirectory( entry.getName() );
+            DirectoryEntry newTarget = target.createDirectory( entry.getName() );
             newTarget.setStorageClsid( dirEntry.getStorageClsid() );
             Iterator<Entry> entries = dirEntry.getEntries();
 
-            while ( entries.hasNext() )
-            {
+            while ( entries.hasNext() ) {
                 copyNodeRecursively( entries.next(), newTarget );
             }
-        }
-        else
-        {
+        } else {
             DocumentEntry dentry = (DocumentEntry) entry;
             DocumentInputStream dstream = new DocumentInputStream( dentry );
             target.createDocument( dentry.getName(), dstream );
@@ -69,27 +63,12 @@ public class EntryUtils
      *            is the target Directory to copy to
      */
     public static void copyNodes(DirectoryEntry sourceRoot,
-            DirectoryEntry targetRoot) throws IOException
-    {
+            DirectoryEntry targetRoot) throws IOException {
         for (Entry entry : sourceRoot) {
             copyNodeRecursively( entry, targetRoot );
         }
     }
 
-    /**
-     * Copies nodes from one Directory to the other minus the excepts
-     * 
-     * @param filteredSource The filtering source Directory to copy from
-     * @param filteredTarget The filtering target Directory to copy to
-     */
-    public static void copyNodes( FilteringDirectoryNode filteredSource,
-            FilteringDirectoryNode filteredTarget ) throws IOException
-    {
-        // Nothing special here, just overloaded types to make the
-        //  recommended new way to handle this clearer
-        copyNodes( (DirectoryEntry)filteredSource, (DirectoryEntry)filteredTarget );
-    }
-
     /**
      * Copies all nodes from one POIFS to the other
      * 
index 99a104ca80f84c04e828a08bb43ee62b79070672..fdd8647a72ae3521435985c15ea8647d7f02bee6 100644 (file)
@@ -927,7 +927,7 @@ public class NPOIFSFileSystem extends BlockStore
     {
         if (preferArray())
         {
-            return (( POIFSViewable ) getRoot()).getViewableArray();
+            return getRoot().getViewableArray();
         }
         return new Object[ 0 ];
     }
@@ -944,7 +944,7 @@ public class NPOIFSFileSystem extends BlockStore
     {
         if (!preferArray())
         {
-            return (( POIFSViewable ) getRoot()).getViewableIterator();
+            return getRoot().getViewableIterator();
         }
         return Collections.emptyList().iterator();
     }
@@ -959,7 +959,7 @@ public class NPOIFSFileSystem extends BlockStore
 
     public boolean preferArray()
     {
-        return (( POIFSViewable ) getRoot()).preferArray();
+        return getRoot().preferArray();
     }
 
     /**
index 0dc1798328336fb4e4b49ad36c86bb4dabea83d4..071288c2ac062cf5884c13e519f38c71fcf8e0ae 100644 (file)
@@ -494,7 +494,7 @@ public class OPOIFSFileSystem
             Property      property = properties.next();
             String        name     = property.getName();
             DirectoryNode parent   = (dir == null)
-                                     ? (( DirectoryNode ) getRoot())
+                                     ? getRoot()
                                      : dir;
 
             if (property.isDirectory())
@@ -547,7 +547,7 @@ public class OPOIFSFileSystem
     {
         if (preferArray())
         {
-            return (( POIFSViewable ) getRoot()).getViewableArray();
+            return getRoot().getViewableArray();
         }
         return new Object[ 0 ];
     }
@@ -564,7 +564,7 @@ public class OPOIFSFileSystem
     {
         if (!preferArray())
         {
-            return (( POIFSViewable ) getRoot()).getViewableIterator();
+            return getRoot().getViewableIterator();
         }
         return Collections.emptyList().iterator();
     }
@@ -579,7 +579,7 @@ public class OPOIFSFileSystem
 
     public boolean preferArray()
     {
-        return (( POIFSViewable ) getRoot()).preferArray();
+        return getRoot().preferArray();
     }
 
     /**
index 4b1fc7479e9193e27128f55ce71cc7ebd78e9cd8..8f418dba77fe289c03118b00a57b33156533b607 100644 (file)
@@ -209,14 +209,14 @@ public final class OperationEvaluationContext {
         SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);
         
         // ugly typecast - TODO - make spreadsheet version more easily accessible
-        SpreadsheetVersion ssVersion = ((FormulaParsingWorkbook)_workbook).getSpreadsheetVersion();
+        SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
 
         NameType part1refType = classifyCellReference(refStrPart1, ssVersion);
         switch (part1refType) {
             case BAD_CELL_OR_NAMED_RANGE:
                 return ErrorEval.REF_INVALID;
             case NAMED_RANGE:
-                EvaluationName nm = ((FormulaParsingWorkbook)_workbook).getName(refStrPart1, _sheetIndex);
+                EvaluationName nm = _workbook.getName(refStrPart1, _sheetIndex);
                 if(!nm.isRange()){
                     throw new RuntimeException("Specified name '" + refStrPart1 + "' is not a range as expected.");
                 }
index 1dcf023b68096c2b07865a889e568125403cb87c..e7e300e5a34dbf5691c63e557a9f9ea6fdd5699b 100644 (file)
@@ -191,7 +191,7 @@ public final class ArrayPtg extends Ptg {
                        throw new RuntimeException("Array item cannot be null");
                }
                if (o instanceof String) {
-                       return "\"" + (String)o + "\"";
+                       return "\"" + o + "\"";
                }
                if (o instanceof Double) {
                        return NumberToTextConverter.toText(((Double)o).doubleValue());
index 848334039337a0848f3d48c414bd15ca8cb7fff7..ffaaa0f1bad9b1f7d092c951910ba51fee039acf 100644 (file)
@@ -258,7 +258,7 @@ public class DateUtil {
      *  @return Java representation of the date, or null if date is not a valid Excel date
      */
     public static Calendar getJavaCalendar(double date) {
-        return getJavaCalendar(date, false, (TimeZone)null, false);
+        return getJavaCalendar(date, false, null, false);
     }
 
     /**
@@ -270,7 +270,7 @@ public class DateUtil {
      *  @return Java representation of the date, or null if date is not a valid Excel date
      */
     public static Calendar getJavaCalendar(double date, boolean use1904windowing) {
-        return getJavaCalendar(date, use1904windowing, (TimeZone)null, false);
+        return getJavaCalendar(date, use1904windowing, null, false);
     }
 
     /**
index 5405b7f6e3ddb9a519c9b80e5facff657bbe8b58..c3fbac9dae7d4a74b8ed48290c1c6f98019fa4fe 100644 (file)
@@ -489,7 +489,7 @@ implements SlideShow<XSLFShape,XSLFTextParagraph> {
         if (relType == null) {
             throw new IllegalArgumentException("Picture type "+format+" is not supported.");
         }
-        img = (XSLFPictureData) createRelationship(relType, XSLFFactory.getInstance(), imageNumber + 1, true).getDocumentPart();
+        img = createRelationship(relType, XSLFFactory.getInstance(), imageNumber + 1, true).getDocumentPart();
         img.setIndex(imageNumber);
         _pictures.add(img);
         try {
index 0362404d36f9ce0447618db00beecd8af0118719..6fce529456e65ffb0a79dcc96528934c3cd91ffc 100644 (file)
@@ -1383,7 +1383,7 @@ public class SXSSFSheet implements Sheet
     private int findStartOfRowOutlineGroup(int rowIndex) {
         // Find the start of the group.
         Row row = getRow(rowIndex);
-        int level = ((SXSSFRow) row).getOutlineLevel();
+        int level = row.getOutlineLevel();
         if(level == 0) {
             throw new IllegalArgumentException("Outline level is zero for the row (" + rowIndex + ").");
         }
index e3e8f56eb7d2a445385ef306819f4ba2554d1e3d..08c565a346eaf5f3d603296f7b723f059a3c3360 100644 (file)
@@ -521,7 +521,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
     @Override
     public int addPicture(byte[] pictureData, int format) {
         int imageNumber = getAllPictures().size() + 1;
-        XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
+        XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
         try {
             OutputStream out = img.getPackagePart().getOutputStream();
             out.write(pictureData);
index 01463c64a5e1ae35d9ee32a094740add9f8fd757..7cdfd6f7b0f5586497efdbb748266b706ac6f495 100644 (file)
@@ -637,7 +637,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
              * in the body. Otherwise, take the previous paragraph and calculate
              * the new index for the new paragraph.
              */
-            if ((!(o instanceof CTP)) || (CTP) o == p) {
+            if ((!(o instanceof CTP)) || o == p) {
                 paragraphs.add(0, newP);
             } else {
                 int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
index 8c89bf747866534ac8a1906e0cbe9e8dfa526b26..e67ed308947b8bd712278397d9171e3cceb9cafd 100644 (file)
@@ -297,7 +297,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>, IBody {
             while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
                 o = cursor.getObject();
             }
-            if ((!(o instanceof CTP)) || (CTP) o == p) {
+            if ((!(o instanceof CTP)) || o == p) {
                 paragraphs.add(0, newP);
             } else {
                 int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
index c5a9365066791f1a55d08cb80c5b49c868698a87..62ecfeed5f9584debb9d4767703791eaec82ae04 100644 (file)
@@ -400,7 +400,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
             while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
                 o = cursor.getObject();
             }
-            if ((!(o instanceof CTP)) || (CTP) o == p) {
+            if ((!(o instanceof CTP)) || o == p) {
                 paragraphs.add(0, newP);
             } else {
                 int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
index b75352c51f21b25c2c056ff84614275cb43bebad..9950aa35ac05837286859474d9886e8e73ddf2c1 100644 (file)
@@ -95,7 +95,7 @@ public class XWPFSDTContent implements ISDTContent {
                 text.append(((XWPFSDT) o).getContent().getText());
                 addNewLine = true;
             } else if (o instanceof XWPFRun) {
-                text.append(((XWPFRun) o));
+                text.append(o);
                 addNewLine = false;
             }
             if (addNewLine == true && i < bodyElements.size() - 1) {
index 27f2c43ad7c8d0cac73fa73826fc771a469b12b6..d72462ddee69a308e9619cdf33a86177bc4018f0 100644 (file)
@@ -273,7 +273,7 @@ public class XWPFTableCell implements IBody, ICell {
         while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
             o = cursor.getObject();
         }
-        if ((!(o instanceof CTP)) || (CTP) o == p) {
+        if ((!(o instanceof CTP)) || o == p) {
             paragraphs.add(0, newP);
         } else {
             int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
index 51c079619841d1ec60c8466b4c6a2fa98d72fe88..75a87ddbad30dbbef40f0acce25602a04740ccaa 100644 (file)
@@ -50,7 +50,7 @@ public class TestXSSFDrawing {
         RelationPart rp = rels.get(0);
         assertTrue(rp.getDocumentPart() instanceof XSSFDrawing);
 
-        XSSFDrawing drawing = (XSSFDrawing)rp.getDocumentPart();
+        XSSFDrawing drawing = rp.getDocumentPart();
         //sheet.createDrawingPatriarch() should return the same instance of XSSFDrawing
         assertSame(drawing, sheet.createDrawingPatriarch());
         String drawingId = rp.getRelationship().getId();
index b9aa8c28c149c8b9d192f648e24234b7a5b9b4a5..70d02d01674c8abdb1fafe4f2e47e627926424bf 100644 (file)
@@ -182,7 +182,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(0,    ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals(null, ((NameXPxg)ptgs[0]).getSheetName());
         assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
-        assertEquals("[0]!NR_Global_B2",((NameXPxg)ptgs[0]).toFormulaString());
+        assertEquals("[0]!NR_Global_B2", ptgs[0].toFormulaString());
 
         wb.close();
     }
@@ -200,7 +200,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(Ref3DPxg.class, ptgs[0].getClass());
         assertEquals(-1,   ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
-        assertEquals("Uses!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
+        assertEquals("Uses!A1", ptgs[0].toFormulaString());
         
         // Reference to a single cell in a different sheet, which needs quoting
         ptgs = parse(fpb, "'Testing 47100'!A1");
@@ -209,7 +209,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(-1,   ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals("Testing 47100", ((Ref3DPxg)ptgs[0]).getSheetName());
         assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
-        assertEquals("'Testing 47100'!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
+        assertEquals("'Testing 47100'!A1", ptgs[0].toFormulaString());
         
         // Reference to a sheet scoped named range from another sheet
         ptgs = parse(fpb, "Defines!NR_To_A1");
@@ -218,7 +218,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(-1,        ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
         assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
-        assertEquals("Defines!NR_To_A1",((NameXPxg)ptgs[0]).toFormulaString());
+        assertEquals("Defines!NR_To_A1", ptgs[0].toFormulaString());
         
         // Reference to a workbook scoped named range
         ptgs = parse(fpb, "NR_Global_B2");
@@ -243,7 +243,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(1,     ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals("Uses",((Ref3DPxg)ptgs[0]).getSheetName());
         assertEquals("$A$1",((Ref3DPxg)ptgs[0]).format2DRefAsString());
-        assertEquals("[1]Uses!$A$1",((Ref3DPxg)ptgs[0]).toFormulaString());
+        assertEquals("[1]Uses!$A$1", ptgs[0].toFormulaString());
         
         // Reference to a sheet-scoped named range in a different workbook
         ptgs = parse(fpb, "[1]Defines!NR_To_A1");
@@ -252,7 +252,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(1,         ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
         assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
-        assertEquals("[1]Defines!NR_To_A1",((NameXPxg)ptgs[0]).toFormulaString());
+        assertEquals("[1]Defines!NR_To_A1", ptgs[0].toFormulaString());
         
         // Reference to a global named range in a different workbook
         ptgs = parse(fpb, "[1]!NR_Global_B2");
@@ -261,7 +261,7 @@ public final class TestXSSFFormulaParser {
         assertEquals(1,    ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
         assertEquals(null, ((NameXPxg)ptgs[0]).getSheetName());
         assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
-        assertEquals("[1]!NR_Global_B2",((NameXPxg)ptgs[0]).toFormulaString());
+        assertEquals("[1]!NR_Global_B2", ptgs[0].toFormulaString());
 
         wb.close();
     }
index 365ca6a6f28204f2120d1a6004e30a27ade88b02..21c32c651a7e3dbc1877c26cc6665837298bd622 100644 (file)
@@ -714,7 +714,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
 
             // ensure that a memory based package part does not have lingering data from previous commit() calls
             if(sheetBack.getPackagePart() instanceof MemoryPackagePart) {
-                ((MemoryPackagePart)sheetBack.getPackagePart()).clear();
+                sheetBack.getPackagePart().clear();
             }
 
             sheetBack.commit();
index 0e23e49302a60569e5c74bf607ad991947224cf1..e9eb2b147948d647cba7f487508507d288ba6cef 100644 (file)
@@ -59,7 +59,7 @@ public class HSLFEscherRecordFactory extends DefaultEscherRecordFactory {
         escherRecord.setRecordId(recordId);
         escherRecord.setOptions(options);
         if (escherRecord instanceof EscherContainerRecord) {
-            ((EscherContainerRecord)escherRecord).fillFields(data, offset, this);
+            escherRecord.fillFields(data, offset, this);
         }
         
         return escherRecord;
index 4057acfaa4350392a7d9a2b7745feece76f185c2..ee0a2d07316a9ee2ef7b09056ae13752b6376c23 100644 (file)
@@ -262,7 +262,7 @@ public final class HSLFFill {
 
         // NOFILLHITTEST can be in the normal escher opt record but also in the tertiary record
         // the extended bit fields seem to be in the second
-        opt = (AbstractEscherOptRecord)shape.getEscherChild(RecordTypes.EscherUserDefined);
+        opt = shape.getEscherChild(RecordTypes.EscherUserDefined);
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
         int propVal = (p == null) ? 0 : p.getPropertyValue();
         final boolean rotateWithShape = FILL_USE_USE_SHAPE_ANCHOR.isSet(propVal) && FILL_USE_SHAPE_ANCHOR.isSet(propVal);
index 033f3bbebb351bff85221e7a6e781fc7000dd723..c7750d608484d2b3879714fd6d1d7c1b2b0d893f 100644 (file)
@@ -360,7 +360,7 @@ public final class HSLFHyperlink implements Hyperlink<HSLFShape,HSLFTextParagrap
         if (exobj != null && cldata != null) {
             List<HSLFHyperlink> lst = new ArrayList<HSLFHyperlink>();
             find(cldata.getHSLFChildRecords(), exobj, lst);
-            return lst.isEmpty() ? null : (HSLFHyperlink)lst.get(0);
+            return lst.isEmpty() ? null : lst.get(0);
         }
 
         return null;
index 49b7ca5671c21da5ebfd6eed1037e8839b20e770..1fb0196186d083ffee4084e229d988b3b43170b7 100644 (file)
@@ -192,13 +192,13 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
         EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
         int flags = spRecord.getFlags();
         if ((flags & EscherSpRecord.FLAG_CHILD) != 0){
-            EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(EscherChildAnchorRecord.RECORD_ID);
+            EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
             rec.setDx1(x);
             rec.setDy1(y);
             rec.setDx2(w);
             rec.setDy2(h);
         } else {
-            EscherClientAnchorRecord rec = (EscherClientAnchorRecord)getEscherChild(EscherClientAnchorRecord.RECORD_ID);
+            EscherClientAnchorRecord rec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
             rec.setCol1((short)x);
             rec.setFlag((short)y);
             rec.setDx1((short)w);
index a8583bb574898d78fc07799c623de1679d6efa2e..ce809b5518445965fccfa373b6caaa69fd6ecd57 100644 (file)
@@ -199,7 +199,7 @@ public abstract class HSLFSheet implements HSLFShapeContainer, Sheet<HSLFShape,H
         PPDrawing ppdrawing = getPPDrawing();
 
         EscherContainerRecord dgContainer = ppdrawing.getDgContainer();
-        EscherContainerRecord spgr = (EscherContainerRecord) HSLFShape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
+        EscherContainerRecord spgr = HSLFShape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
         spgr.addChildRecord(shape.getSpContainer());
 
         shape.setSheet(this);
index 793c790fdf0a546ca20e1d558a2c8644ca97a0ef..4d631157203a33e5840c58ca90c7bb8ad24f55ed 100644 (file)
@@ -162,7 +162,7 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFTe
         //initialize drawing group id
         EscherDggRecord dgg = getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
         EscherContainerRecord dgContainer = getSheetContainer().getPPDrawing().getDgContainer();
-        EscherDgRecord dg = (EscherDgRecord) HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
+        EscherDgRecord dg = HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
         int dgId = dgg.getMaxDrawingGroupId() + 1;
         dg.setOptions((short)(dgId << 4));
         dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
index c79816de38674dcefb847cab91944990301bed99..738b6422ecf956de40b596876ebd47e363bda5d4 100644 (file)
@@ -791,7 +791,7 @@ public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagrap
                EscherContainerRecord bstore;
 
                EscherContainerRecord dggContainer = _documentRecord.getPPDrawingGroup().getDggContainer();
-               bstore = (EscherContainerRecord) HSLFShape.getEscherChild(dggContainer,
+               bstore = HSLFShape.getEscherChild(dggContainer,
                                EscherContainerRecord.BSTORE_CONTAINER);
                if (bstore == null) {
                        bstore = new EscherContainerRecord();
index a3c75678beff8367007f41e287b98dd78edfd476..97ff5b4c832ff9d0f16125c2d58cdf762e48a3b1 100644 (file)
@@ -1094,7 +1094,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
         RecordContainer _txtbox = headerAtom.getParentRecord();
         if (_txtbox instanceof EscherTextboxWrapper) {
             try {
-                ((EscherTextboxWrapper) _txtbox).writeOut(null);
+                _txtbox.writeOut(null);
             } catch (IOException e) {
                 throw new HSLFException("failed dummy write", e);
             }
index 3affa20a8b90dee51bf14482cd97bd7904faee15..98c2db8d042c2a9973ee714ef161f860fea5bb0a 100644 (file)
@@ -487,7 +487,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
    public boolean has7BitEncodingStrings() {
       for(Chunk c : mainChunks.getChunks()) {
          if(c instanceof StringChunk) {
-            if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+            if( c.getType() == Types.ASCII_STRING ) {
                return true;
             }
          }
@@ -496,7 +496,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
       if (nameIdChunks!=null) {
          for(Chunk c : nameIdChunks.getChunks()) {
             if(c instanceof StringChunk) {
-               if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+               if( c.getType() == Types.ASCII_STRING ) {
                   return true;
                }
             }
@@ -506,7 +506,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
       for(RecipientChunks rc : recipientChunks) {
          for(Chunk c : rc.getAll()) {
             if(c instanceof StringChunk) {
-               if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+               if( c.getType() == Types.ASCII_STRING ) {
                   return true;
                }
             }
index 5014ae55bae6958b7672e69ca0bb9fe321832ccb..243393db96b61424270164904dc3c10f54376137 100644 (file)
@@ -93,7 +93,7 @@ public class HwmfDrawProperties {
         this.bkMode = other.bkMode;
         this.polyfillMode = other.polyfillMode;
         if (other.region instanceof Rectangle2D) {
-            this.region = ((Rectangle2D)other.region).getBounds2D();
+            this.region = other.region.getBounds2D();
         } else if (other.region instanceof Area) {
             this.region = new Area(other.region);
         }
index e137727fdad235285525972b3fa55336a291c0f3..b186197dac02e4ca1309f6e935bb728029058369 100644 (file)
@@ -103,7 +103,7 @@ public class TextPiece extends PropertyNode<TextPiece> {
     }
 
     public byte[] getRawBytes() {
-        return ((CharSequence) _buf).toString().getBytes(
+        return _buf.toString().getBytes(
                 Charset.forName(_usesUnicode ? "UTF-16LE" : "Cp1252")
         );
     }
index 0b186b56b6c0530a314e12926b99b6e6903794c2..7f64b0104756a36c122f069680602e279199191a 100644 (file)
@@ -225,19 +225,19 @@ public final class SectionSprmUncompressor extends SprmUncompressor
         break;
       case 0x3F:
         // [MS-DOC], v20140721, 2.6.4, sprmSNFtn
-        newSEP.setNFtn((int) sprm.getOperand());
+        newSEP.setNFtn(sprm.getOperand());
         break;
       case 0x40:
         // [MS-DOC], v20140721, 2.6.4, sprmSNFtnRef
-        newSEP.setNfcFtnRef((int) sprm.getOperand());
+        newSEP.setNfcFtnRef(sprm.getOperand());
         break;
       case 0x41:
         // [MS-DOC], v20140721, 2.6.4, sprmSNEdn
-        newSEP.setNEdn((int) sprm.getOperand());
+        newSEP.setNEdn(sprm.getOperand());
         break;
       case 0x42:
         // [MS-DOC], v20140721, 2.6.4, sprmSNEdnRef
-        newSEP.setNfcEdnRef((int) sprm.getOperand());
+        newSEP.setNfcEdnRef(sprm.getOperand());
         break;
       default:
         logger.log(POILogger.INFO, "Unsupported Sprm operation: " + operation + " (" + HexDump.byteToHex(operation) + ")");
index 0246501876a8b248415fdbf8fbd97e6b14218b3c..4e9c3b012d76f5690505b1c1378041dedc66ea30 100644 (file)
@@ -1035,7 +1035,7 @@ public final class TestBugs {
     public void bug60294() throws IOException {
         HSLFSlideShow ppt = open("60294.ppt");
         List<HSLFShape> shList = ppt.getSlides().get(0).getShapes();
-        assertEquals(ShapeType.NOT_PRIMITIVE, ((HSLFAutoShape)shList.get(2)).getShapeType());
+        assertEquals(ShapeType.NOT_PRIMITIVE, shList.get(2).getShapeType());
         ppt.close();
     }
 }
index ca0caf5b0ee16bb133cf2c9d79d4cd1e3ed783bb..1f222b6b2783a887618e64ed82b6d4e207a8782b 100644 (file)
@@ -46,7 +46,7 @@ public class TestOfficeDrawings extends TestCase
 
         EscherOptRecord officeArtFOPT = escherContainerRecord
                 .getChildById( (short) 0xF00B );
-        EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT
+        EscherComplexProperty gtextUNICODE = officeArtFOPT
                 .lookup( 0x00c0 );
 
         String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData());
index 3c06fd346bfca278b94d7f4e29ce65e6f058018c..83668b5c7090036e1055869020418d1abad21f99 100644 (file)
@@ -137,14 +137,14 @@ public final class TestPOIDocumentMain {
         doc.write(baos);
         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
 
-        ((HSSFWorkbook)doc).close();
+        doc.close();
 
         doc = new HSSFWorkbook(bais);
 
         assertNotNull(doc.getSummaryInformation());
         assertNotNull(doc.getDocumentSummaryInformation());
         
-        ((HSSFWorkbook)doc).close();
+        doc.close();
     }
 
     @Test
@@ -159,7 +159,7 @@ public final class TestPOIDocumentMain {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         doc.write(baos);
         
-        ((HSSFWorkbook)doc).close();
+        doc.close();
         
         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
         doc = new HSSFWorkbook(bais);
@@ -176,7 +176,7 @@ public final class TestPOIDocumentMain {
         baos = new ByteArrayOutputStream();
         doc.write(baos);
         
-        ((HSSFWorkbook)doc).close();
+        doc.close();
 
         bais = new ByteArrayInputStream(baos.toByteArray());
         doc = new HSSFWorkbook(bais);
@@ -194,6 +194,6 @@ public final class TestPOIDocumentMain {
         assertEquals("POI Testing", doc.getSummaryInformation().getAuthor());
         assertEquals("ASF", doc.getDocumentSummaryInformation().getCompany());
 
-        ((HSSFWorkbook)doc).close();
+        doc.close();
     }
 }
index eb8bedea699a7884eeea6cf52fe6f992ad47d16d..b58ccec8e9fe44ab2a5b3eb316770655bc56b9a1 100644 (file)
@@ -91,12 +91,12 @@ public final class TestFormulaParser {
      * @return parsed token array already confirmed not <code>null</code>
      */
     /* package */ static Ptg[] parseFormula(String formula) {
-        Ptg[] result = HSSFFormulaParser.parse(formula, (HSSFWorkbook)null);
+        Ptg[] result = HSSFFormulaParser.parse(formula, null);
         assertNotNull("Ptg array should not be null", result);
         return result;
     }
     private static String toFormulaString(Ptg[] ptgs) {
-        return HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, ptgs);
+        return HSSFFormulaParser.toFormulaString(null, ptgs);
     }
 
     @Test
@@ -1456,7 +1456,7 @@ public final class TestFormulaParser {
 
         MemFuncPtg mf = (MemFuncPtg)ptgs[0];
         assertEquals(57, mf.getLenRefSubexpression());
-        assertEquals("D4:E5", ((AreaPtgBase)ptgs[7]).toFormulaString());
+        assertEquals("D4:E5", ptgs[7].toFormulaString());
         assertTrue(((AttrPtg)ptgs[16]).isSum());
 
         ptgs = parseFormula("SUM(A1:B2:C3:D4)");
@@ -1567,7 +1567,7 @@ public final class TestFormulaParser {
         Ptg[] ptgs;
         try {
             ptgs = HSSFFormulaParser.parse(leadingZeroCellRef, wb);
-            assertEquals("B1", ((RefPtg) ptgs[0]).toFormulaString());
+            assertEquals("B1", ptgs[0].toFormulaString());
         } catch (FormulaParseException e) {
             confirmParseException(e, "Specified named range '"
                     + leadingZeroCellRef + "' does not exist in the current workbook.");
index a0b0b8a9aef5250a7c6c16a7166e03a344b14c9a..a6e83c77c4a4d2e90cfaa9e5e197fa314c0d8c27 100644 (file)
@@ -33,7 +33,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 public final class TestOperandClassTransformer extends TestCase {
 
        private static Ptg[] parseFormula(String formula) {
-               Ptg[] result = HSSFFormulaParser.parse(formula, (HSSFWorkbook)null);
+               Ptg[] result = HSSFFormulaParser.parse(formula, null);
                assertNotNull("Ptg array should not be null", result);
                return result;
        }
index ebdbe9ca41e827057a5db93fd966f0a3bdeb08e6..593963b14a5b3e32605e6847cd02fe9731e492bd 100644 (file)
@@ -579,6 +579,6 @@ public final class TestFormulaEvaluatorBugs {
         assertEquals(RefPtg.class, ptg.getClass());
         assertEquals(0,  ((RefPtg)ptg).getRow());
         assertEquals(0,  ((RefPtg)ptg).getColumn());
-        assertEquals(rv, ((RefPtg)ptg).getRVAType());
+        assertEquals(rv, ptg.getRVAType());
     }
 }
index f8162fcf28faf0642b37f73271cfb33e42f357a8..283d157f83ede17f69a2edaeb545d281809c7754 100644 (file)
@@ -57,7 +57,7 @@ public final class TestHSSFComment extends BaseTestCellComment {
 
     @Test
     public void defaultShapeType() {
-        HSSFComment comment = new HSSFComment((HSSFShape)null, new HSSFClientAnchor());
+        HSSFComment comment = new HSSFComment(null, new HSSFClientAnchor());
         assertEquals(HSSFSimpleShape.OBJECT_TYPE_COMMENT, comment.getShapeType());
     }
 
index 6c6631a9b19088877c42d4f698d53ec5e041ff9d..5326e759d9314fb58bf65378e3e0f32ba5fff590 100644 (file)
@@ -42,7 +42,7 @@ public final class TestHSSFPictureData extends TestCase{
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
 
         @SuppressWarnings("unchecked") // TODO - add getFormat() to interface PictureData and genericise wb.getAllPictures()
-        List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+        List<HSSFPictureData> lst = wb.getAllPictures();
         //assertEquals(2, lst.size());
 
         for (final HSSFPictureData pict : lst) {
@@ -74,7 +74,7 @@ public final class TestHSSFPictureData extends TestCase{
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("53446.xls");
 
         @SuppressWarnings("unchecked")
-        List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+        List<HSSFPictureData> lst = wb.getAllPictures();
         assertEquals(1, lst.size());
 
         HSSFPictureData pict = lst.get(0);
@@ -98,7 +98,7 @@ public final class TestHSSFPictureData extends TestCase{
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SheetWithDrawing.xls");
 
         @SuppressWarnings("unchecked") // TODO - add getFormat() to interface PictureData and genericise wb.getAllPictures()
-        List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+        List<HSSFPictureData> lst = wb.getAllPictures();
         for(HSSFPictureData pict : lst){
             assertNotNull(pict);
         }