aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2018-09-28 07:33:59 +0000
committerPJ Fanning <fanningpj@apache.org>2018-09-28 07:33:59 +0000
commit08cfbcc90bffc4f348af495d013a650e96cf1dea (patch)
treeb5bded92cad7df1d602aac8fe237b749248c0c81 /src
parent0746b23fc4ef1bd88207a1c5df15cd70927c781d (diff)
downloadpoi-08cfbcc90bffc4f348af495d013a650e96cf1dea.tar.gz
poi-08cfbcc90bffc4f348af495d013a650e96cf1dea.zip
fix lgtm issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1842216 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java8
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java8
5 files changed, 14 insertions, 20 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
index eec2f146e5..843873e114 100644
--- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
@@ -98,7 +98,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
if (num < 0) {
throw new IllegalArgumentException("Maximum Number of Data Formats must be greater than or equal to 0");
} 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.");
}
}
@@ -316,7 +316,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
short nextKey = (short) (numberFormats.lastKey() + 1);
if (nextKey < 0) {
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.");
}
formatIndex = (short) Math.max(nextKey, FIRST_USER_DEFINED_NUMBER_FORMAT_ID);
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index cc732cd2ba..b3113203a6 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -491,10 +491,13 @@ public final class XSSFCell implements Cell {
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);
+ } else {
+ return f.getStringValue();
}
- return f.getStringValue();
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
index 42552b362c..80ff17b7e4 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
@@ -18,7 +18,6 @@
package org.apache.poi.xssf.usermodel;
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.Units;
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());
}
- /**
- *
- * @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) {
CTMarker c2 = CTMarker.Factory.newInstance();
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java
index 14ca5d6495..441f242f4a 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java
@@ -54,7 +54,7 @@ public class XSSFComment implements Comment {
// we potentially need to adjust the column/row information in the shape
// 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());
CTClientData clientData = vmlShape.getClientDataArray(0);
clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow())));
@@ -70,7 +70,7 @@ public class XSSFComment implements Comment {
*/
@Override
public String getAuthor() {
- return _comments.getAuthor((int) _comment.getAuthorId());
+ return _comments.getAuthor(_comment.getAuthorId());
}
/**
@@ -80,9 +80,7 @@ public class XSSFComment implements Comment {
*/
@Override
public void setAuthor(String author) {
- _comment.setAuthorId(
- _comments.findAuthor(author)
- );
+ _comment.setAuthorId(_comments.findAuthor(author));
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index a26e58e54c..423561b2ce 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -2262,8 +2262,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}
}
- private void unsetCollapsed(boolean collapsed, CTCol ci) {
- if (collapsed) {
+ private void unsetCollapsed(Boolean collapsed, CTCol ci) {
+ if (collapsed != null && collapsed.booleanValue()) {
ci.setCollapsed(collapsed);
} else {
ci.unsetCollapsed();
@@ -2410,7 +2410,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
boolean endHidden = false;
int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
CTCol[] colArray = cols.getColArray();
- if (endOfOutlineGroupIdx < colArray.length) {
+ if (endOfOutlineGroupIdx < (colArray.length - 1)) {
CTCol nextInfo = colArray[endOfOutlineGroupIdx + 1];
if (isAdjacentBefore(colArray[endOfOutlineGroupIdx], nextInfo)) {
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() + ".");
// FIXME: assumes row objects belong to non-null sheets and sheets belong to non-null workbooks.
} 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() + "). " +
"Got srcRows[" + index + "] from different workbook (" + curRow.getSheet().getWorkbook() + ").");
} else if (srcStartRow.getSheet() != curRow.getSheet()) {