fix lgtm issues

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1842216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-09-28 07:33:59 +00:00
parent e505160716
commit 500c64e657
5 changed files with 14 additions and 20 deletions

View File

@ -98,7 +98,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
if (num < 0) { if (num < 0) {
throw new IllegalArgumentException("Maximum Number of Data Formats must be greater than or equal to 0"); throw new IllegalArgumentException("Maximum Number of Data Formats must be greater than or equal to 0");
} else { } else {
throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity." + throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity. " +
"Data formats must be explicitly removed (via StylesTable.removeNumberFormat) before the limit can be decreased."); "Data formats must be explicitly removed (via StylesTable.removeNumberFormat) before the limit can be decreased.");
} }
} }
@ -316,7 +316,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
short nextKey = (short) (numberFormats.lastKey() + 1); short nextKey = (short) (numberFormats.lastKey() + 1);
if (nextKey < 0) { if (nextKey < 0) {
throw new IllegalStateException( throw new IllegalStateException(
"Cowardly avoiding creating a number format with a negative id." + "Cowardly avoiding creating a number format with a negative id. " +
"This is probably due to arithmetic overflow."); "This is probably due to arithmetic overflow.");
} }
formatIndex = (short) Math.max(nextKey, FIRST_USER_DEFINED_NUMBER_FORMAT_ID); formatIndex = (short) Math.max(nextKey, FIRST_USER_DEFINED_NUMBER_FORMAT_ID);

View File

@ -491,10 +491,13 @@ public final class XSSFCell implements Cell {
return cell.getCellFormula(fpb); return cell.getCellFormula(fpb);
} }
} }
if (f.getT() == STCellFormulaType.SHARED) { if (f == null) {
return null;
} else if (f.getT() == STCellFormulaType.SHARED) {
return convertSharedFormula((int)f.getSi(), fpb == null ? XSSFEvaluationWorkbook.create(getSheet().getWorkbook()) : fpb); return convertSharedFormula((int)f.getSi(), fpb == null ? XSSFEvaluationWorkbook.create(getSheet().getWorkbook()) : fpb);
} else {
return f.getStringValue();
} }
return f.getStringValue();
} }
/** /**

View File

@ -18,7 +18,6 @@
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
@ -154,12 +153,6 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
// this.cell2 = calcCell(sheet, cell1, size.getCx(), size.getCy()); // this.cell2 = calcCell(sheet, cell1, size.getCx(), size.getCy());
} }
/**
*
* @param sheet
* @param cell starting point and offsets (may be zeros)
* @param size dimensions to calculate relative to starting point
*/
private CTMarker calcCell(CTMarker cell, long w, long h) { private CTMarker calcCell(CTMarker cell, long w, long h) {
CTMarker c2 = CTMarker.Factory.newInstance(); CTMarker c2 = CTMarker.Factory.newInstance();

View File

@ -54,7 +54,7 @@ public class XSSFComment implements Comment {
// we potentially need to adjust the column/row information in the shape // we potentially need to adjust the column/row information in the shape
// the same way as we do in setRow()/setColumn() // the same way as we do in setRow()/setColumn()
if(vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) { if(comment != null && vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) {
CellReference ref = new CellReference(comment.getRef()); CellReference ref = new CellReference(comment.getRef());
CTClientData clientData = vmlShape.getClientDataArray(0); CTClientData clientData = vmlShape.getClientDataArray(0);
clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow()))); clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow())));
@ -70,7 +70,7 @@ public class XSSFComment implements Comment {
*/ */
@Override @Override
public String getAuthor() { public String getAuthor() {
return _comments.getAuthor((int) _comment.getAuthorId()); return _comments.getAuthor(_comment.getAuthorId());
} }
/** /**
@ -80,9 +80,7 @@ public class XSSFComment implements Comment {
*/ */
@Override @Override
public void setAuthor(String author) { public void setAuthor(String author) {
_comment.setAuthorId( _comment.setAuthorId(_comments.findAuthor(author));
_comments.findAuthor(author)
);
} }
/** /**

View File

@ -2262,8 +2262,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
} }
} }
private void unsetCollapsed(boolean collapsed, CTCol ci) { private void unsetCollapsed(Boolean collapsed, CTCol ci) {
if (collapsed) { if (collapsed != null && collapsed.booleanValue()) {
ci.setCollapsed(collapsed); ci.setCollapsed(collapsed);
} else { } else {
ci.unsetCollapsed(); ci.unsetCollapsed();
@ -2410,7 +2410,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
boolean endHidden = false; boolean endHidden = false;
int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx); int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
CTCol[] colArray = cols.getColArray(); CTCol[] colArray = cols.getColArray();
if (endOfOutlineGroupIdx < colArray.length) { if (endOfOutlineGroupIdx < (colArray.length - 1)) {
CTCol nextInfo = colArray[endOfOutlineGroupIdx + 1]; CTCol nextInfo = colArray[endOfOutlineGroupIdx + 1];
if (isAdjacentBefore(colArray[endOfOutlineGroupIdx], nextInfo)) { if (isAdjacentBefore(colArray[endOfOutlineGroupIdx], nextInfo)) {
endLevel = nextInfo.getOutlineLevel(); endLevel = nextInfo.getOutlineLevel();
@ -2900,7 +2900,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
// "Got srcRows[" + (index-1) + "]=Row " + prevRow.getRowNum() + ", srcRows[" + index + "]=Row " + curRow.getRowNum() + "."); // "Got srcRows[" + (index-1) + "]=Row " + prevRow.getRowNum() + ", srcRows[" + index + "]=Row " + curRow.getRowNum() + ".");
// FIXME: assumes row objects belong to non-null sheets and sheets belong to non-null workbooks. // FIXME: assumes row objects belong to non-null sheets and sheets belong to non-null workbooks.
} else if (srcStartRow.getSheet().getWorkbook() != curRow.getSheet().getWorkbook()) { } else if (srcStartRow.getSheet().getWorkbook() != curRow.getSheet().getWorkbook()) {
throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet in the same workbook." + throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet in the same workbook. " +
"Expected all rows from same workbook (" + srcStartRow.getSheet().getWorkbook() + "). " + "Expected all rows from same workbook (" + srcStartRow.getSheet().getWorkbook() + "). " +
"Got srcRows[" + index + "] from different workbook (" + curRow.getSheet().getWorkbook() + ")."); "Got srcRows[" + index + "] from different workbook (" + curRow.getSheet().getWorkbook() + ").");
} else if (srcStartRow.getSheet() != curRow.getSheet()) { } else if (srcStartRow.getSheet() != curRow.getSheet()) {