You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/09/29 10:31:16 UTC

svn commit: r1705814 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/eventusermodel/ java/org/apache/poi/hpsf/ java/org/apache/poi/hssf/extractor/ ooxml/java/org/apache/poi/xslf/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/java/org/...

Author: kiwiwings
Date: Tue Sep 29 08:31:15 2015
New Revision: 1705814

URL: http://svn.apache.org/viewvc?rev=1705814&view=rev
Log:
sonar fixes

Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
    poi/trunk/src/java/org/apache/poi/hpsf/Section.java
    poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java Tue Sep 29 08:31:15 2015
@@ -185,15 +185,10 @@ public class XLSX2CSV {
                     //  with a special style or format 
                     int styleIndex = Integer.parseInt(cellStyleStr);
                     XSSFCellStyle style = stylesTable.getStyleAt(styleIndex);
-                    if (style == null && stylesTable.getNumCellStyles() > 0) {
-                        style = stylesTable.getStyleAt(0);
-                    }
-                    if (style != null) {
-                        this.formatIndex = style.getDataFormat();
-                        this.formatString = style.getDataFormatString();
-                        if (this.formatString == null) {
-                            this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
-                        }
+                    this.formatIndex = style.getDataFormat();
+                    this.formatString = style.getDataFormatString();
+                    if (this.formatString == null) {
+                        this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
                     }
                 }
             }

Modified: poi/trunk/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Section.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Section.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Section.java Tue Sep 29 08:31:15 2015
@@ -447,12 +447,12 @@ public class Section
     public String getPIDString(final long pid)
     {
         String s = null;
-        if (dictionary != null)
+        if (dictionary != null) {
             s = dictionary.get(Long.valueOf(pid));
-        if (s == null)
+        }
+        if (s == null) {
             s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid);
-        if (s == null)
-            s = SectionIDMap.UNDEFINED;
+        }
         return s;
     }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java Tue Sep 29 08:31:15 2015
@@ -358,18 +358,11 @@ public class ExcelExtractor extends POIO
 											}
 											break;
 										case HSSFCell.CELL_TYPE_NUMERIC:
-										   HSSFCellStyle style = cell.getCellStyle();
-										   if(style == null) {
-										      text.append( cell.getNumericCellValue() );
-										   } else {
-	                                 text.append(
-	                                       _formatter.formatRawCellContents(
-	                                             cell.getNumericCellValue(),
-	                                             style.getDataFormat(),
-	                                             style.getDataFormatString()
-	                                       )
-	                                 );
-										   }
+											HSSFCellStyle style = cell.getCellStyle();
+											double nVal = cell.getNumericCellValue();
+											short df = style.getDataFormat();
+											String dfs = style.getDataFormatString();
+											text.append(_formatter.formatRawCellContents(nVal, df, dfs));
 											break;
 										case HSSFCell.CELL_TYPE_BOOLEAN:
 											text.append(cell.getBooleanCellValue());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java Tue Sep 29 08:31:15 2015
@@ -107,9 +107,6 @@ public final class XSLFPictureData exten
      */
     public String getFileName() {
         String name = getPackagePart().getPartName().getName();
-        if (name == null) {
-            return null;
-        }
         return name.substring(name.lastIndexOf('/') + 1);
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Tue Sep 29 08:31:15 2015
@@ -259,8 +259,7 @@ public final class XSSFCell implements C
      */
     @Override
     public String getStringCellValue() {
-        XSSFRichTextString str = getRichStringCellValue();
-        return str == null ? null : str.getString();
+        return getRichStringCellValue().getString();
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java Tue Sep 29 08:31:15 2015
@@ -112,9 +112,6 @@ public class XWPFPictureData extends POI
      */
     public String getFileName() {
         String name = getPackagePart().getPartName().getName();
-        if (name == null) {
-            return null;
-        }
         return name.substring(name.lastIndexOf('/') + 1);
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java Tue Sep 29 08:31:15 2015
@@ -139,14 +139,10 @@ public abstract class AbstractExcelConve
                 break;
             case HSSFCell.CELL_TYPE_NUMERIC:
                 HSSFCellStyle style = cell.getCellStyle();
-                if ( style == null )
-                {
-                    return false;
-                }
-
-                value = ( _formatter.formatRawCellContents(
-                        cell.getNumericCellValue(), style.getDataFormat(),
-                        style.getDataFormatString() ) );
+                double nval = cell.getNumericCellValue();
+                short df = style.getDataFormat();
+                String dfs = style.getDataFormatString();
+                value = _formatter.formatRawCellContents(nval, df, dfs);
                 break;
             case HSSFCell.CELL_TYPE_BOOLEAN:
                 value = String.valueOf( cell.getBooleanCellValue() );

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Tue Sep 29 08:31:15 2015
@@ -228,13 +228,9 @@ public class ExcelToFoConverter extends
                 break;
             case HSSFCell.CELL_TYPE_NUMERIC:
                 double nValue = cell.getNumericCellValue();
-                if ( cellStyle == null ) {
-                    value = Double.toString( nValue );
-                } else {
-                    short df = cellStyle.getDataFormat();
-                    String dfs = cellStyle.getDataFormatString();
-                    value = _formatter.formatRawCellContents(nValue, df, dfs );
-                }
+                short df = cellStyle.getDataFormat();
+                String dfs = cellStyle.getDataFormatString();
+                value = _formatter.formatRawCellContents(nValue, df, dfs );
                 break;
             case HSSFCell.CELL_TYPE_BOOLEAN:
                 value = Boolean.toString( cell.getBooleanCellValue() );
@@ -270,7 +266,7 @@ public class ExcelToFoConverter extends
         }
 
         final boolean noText = ExcelToHtmlUtils.isEmpty( value );
-        final boolean wrapInDivs = !noText && (cellStyle == null || !cellStyle.getWrapText());
+        final boolean wrapInDivs = !noText && !cellStyle.getWrapText();
 
         final boolean emptyStyle = isEmptyStyle( cellStyle );
         if ( !emptyStyle && noText ) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java?rev=1705814&r1=1705813&r2=1705814&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java Tue Sep 29 08:31:15 2015
@@ -313,13 +313,9 @@ public class ExcelToHtmlConverter extend
                 break;
             case HSSFCell.CELL_TYPE_NUMERIC:
                 double nValue = cell.getNumericCellValue();
-                if ( cellStyle == null ) {
-                    value = Double.toString(nValue);
-                } else {
-                    short df = cellStyle.getDataFormat();
-                    String dfs = cellStyle.getDataFormatString();
-                    value = _formatter.formatRawCellContents(nValue, df, dfs);
-                }
+                short df = cellStyle.getDataFormat();
+                String dfs = cellStyle.getDataFormatString();
+                value = _formatter.formatRawCellContents(nValue, df, dfs);
                 break;
             case HSSFCell.CELL_TYPE_BOOLEAN:
                 value = String.valueOf( cell.getBooleanCellValue() );
@@ -355,10 +351,9 @@ public class ExcelToHtmlConverter extend
         }
 
         final boolean noText = ExcelToHtmlUtils.isEmpty( value );
-        final boolean wrapInDivs = !noText && isUseDivsToSpan()
-                && (cellStyle == null || !cellStyle.getWrapText());
+        final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText();
 
-        if ( cellStyle != null && cellStyle.getIndex() != 0 )
+        if ( cellStyle.getIndex() != 0 )
         {
             @SuppressWarnings("resource")
             HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook();
@@ -418,9 +413,7 @@ public class ExcelToHtmlConverter extend
             innerDivStyle.append( "overflow:hidden;max-height:" );
             innerDivStyle.append( normalHeightPt );
             innerDivStyle.append( "pt;white-space:nowrap;" );
-            if (cellStyle != null) {
-                ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignment() );
-            }
+            ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignment() );
             htmlDocumentFacade.addStyleClass( outerDiv, cssClassPrefixDiv,
                     innerDivStyle.toString() );
 
@@ -433,7 +426,7 @@ public class ExcelToHtmlConverter extend
             tableCellElement.appendChild( text );
         }
 
-        return ExcelToHtmlUtils.isEmpty( value ) && (cellStyle == null || cellStyle.getIndex() == 0);
+        return ExcelToHtmlUtils.isEmpty( value ) && (cellStyle.getIndex() == 0);
     }
 
     protected void processColumnHeaders( HSSFSheet sheet, int maxSheetColumns,



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org