sonar fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1705814 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-09-29 08:31:15 +00:00
parent 3109f16a7f
commit aacf48d5aa
9 changed files with 29 additions and 63 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -358,18 +358,11 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
}
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());

View File

@ -107,9 +107,6 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture
*/
public String getFileName() {
String name = getPackagePart().getPartName().getName();
if (name == null) {
return null;
}
return name.substring(name.lastIndexOf('/') + 1);
}

View File

@ -259,8 +259,7 @@ public final class XSSFCell implements Cell {
*/
@Override
public String getStringCellValue() {
XSSFRichTextString str = getRichStringCellValue();
return str == null ? null : str.getString();
return getRichStringCellValue().getString();
}
/**

View File

@ -112,9 +112,6 @@ public class XWPFPictureData extends POIXMLDocumentPart {
*/
public String getFileName() {
String name = getPackagePart().getPartName().getName();
if (name == null) {
return null;
}
return name.substring(name.lastIndexOf('/') + 1);
}

View File

@ -139,14 +139,10 @@ public abstract class AbstractExcelConverter
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() );

View File

@ -228,13 +228,9 @@ public class ExcelToFoConverter extends AbstractExcelConverter
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 AbstractExcelConverter
}
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 ) {

View File

@ -313,13 +313,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
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 extends AbstractExcelConverter
}
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 extends AbstractExcelConverter
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 extends AbstractExcelConverter
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,