sonar fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1832748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7088a68f1d
commit
611c15f412
@ -844,10 +844,10 @@ public class Section {
|
|||||||
if (cp == CodePageUtil.CP_UNICODE) {
|
if (cp == CodePageUtil.CP_UNICODE) {
|
||||||
pad = 2+((4 - ((nrBytes+2) & 0x3)) & 0x3);
|
pad = 2+((4 - ((nrBytes+2) & 0x3)) & 0x3);
|
||||||
}
|
}
|
||||||
leis.skip(pad);
|
IOUtils.skipFully(leis, pad);
|
||||||
|
|
||||||
dic.put(id, str);
|
dic.put(id, str);
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException|IOException ex) {
|
||||||
LOG.log(POILogger.WARN, errMsg, ex);
|
LOG.log(POILogger.WARN, errMsg, ex);
|
||||||
isCorrupted = true;
|
isCorrupted = true;
|
||||||
break;
|
break;
|
||||||
|
@ -812,6 +812,9 @@ public class DataFormatter implements Observer {
|
|||||||
* @return Formatted value
|
* @return Formatted value
|
||||||
*/
|
*/
|
||||||
private String getFormattedDateString(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {
|
private String getFormattedDateString(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {
|
||||||
|
if (cell == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Format dateFormat = getFormat(cell, cfEvaluator);
|
Format dateFormat = getFormat(cell, cfEvaluator);
|
||||||
if(dateFormat instanceof ExcelStyleDateFormatter) {
|
if(dateFormat instanceof ExcelStyleDateFormatter) {
|
||||||
// Hint about the raw excel value
|
// Hint about the raw excel value
|
||||||
@ -837,7 +840,9 @@ public class DataFormatter implements Observer {
|
|||||||
* @return a formatted number string
|
* @return a formatted number string
|
||||||
*/
|
*/
|
||||||
private String getFormattedNumberString(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {
|
private String getFormattedNumberString(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {
|
||||||
|
if (cell == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Format numberFormat = getFormat(cell, cfEvaluator);
|
Format numberFormat = getFormat(cell, cfEvaluator);
|
||||||
double d = cell.getNumericCellValue();
|
double d = cell.getNumericCellValue();
|
||||||
if (numberFormat == null) {
|
if (numberFormat == null) {
|
||||||
|
@ -146,7 +146,7 @@ public class ExtractorFactory {
|
|||||||
// ensure file-handle release
|
// ensure file-handle release
|
||||||
IOUtils.closeQuietly(fs);
|
IOUtils.closeQuietly(fs);
|
||||||
throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an OOXML file");
|
throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an OOXML file");
|
||||||
} catch (OpenXML4JException | Error | RuntimeException | IOException | XmlException e) {
|
} catch (OpenXML4JException | Error | RuntimeException | IOException | XmlException e) { // NOSONAR
|
||||||
// ensure file-handle release
|
// ensure file-handle release
|
||||||
IOUtils.closeQuietly(fs);
|
IOUtils.closeQuietly(fs);
|
||||||
throw e;
|
throw e;
|
||||||
@ -245,7 +245,7 @@ public class ExtractorFactory {
|
|||||||
|
|
||||||
throw new IllegalArgumentException("No supported documents found in the OOXML package (found "+contentType+")");
|
throw new IllegalArgumentException("No supported documents found in the OOXML package (found "+contentType+")");
|
||||||
|
|
||||||
} catch (IOException | Error | RuntimeException | XmlException | OpenXML4JException e) {
|
} catch (IOException | Error | RuntimeException | XmlException | OpenXML4JException e) { // NOSONAR
|
||||||
// ensure that we close the package again if there is an error opening it, however
|
// ensure that we close the package again if there is an error opening it, however
|
||||||
// we need to revert the package to not re-write the file via close(), which is very likely not wanted for a TextExtractor!
|
// we need to revert the package to not re-write the file via close(), which is very likely not wanted for a TextExtractor!
|
||||||
pkg.revert();
|
pkg.revert();
|
||||||
|
@ -68,7 +68,7 @@ public final class SAXHelper {
|
|||||||
saxFactory = SAXParserFactory.newInstance();
|
saxFactory = SAXParserFactory.newInstance();
|
||||||
saxFactory.setValidating(false);
|
saxFactory.setValidating(false);
|
||||||
saxFactory.setNamespaceAware(true);
|
saxFactory.setNamespaceAware(true);
|
||||||
} catch (RuntimeException | Error re) {
|
} catch (RuntimeException | Error re) { // NOSONAR
|
||||||
// this also catches NoClassDefFoundError, which may be due to a local class path issue
|
// this also catches NoClassDefFoundError, which may be due to a local class path issue
|
||||||
// This may occur if the code is run inside a web container
|
// This may occur if the code is run inside a web container
|
||||||
// or a restricted JVM
|
// or a restricted JVM
|
||||||
|
@ -106,13 +106,12 @@ public final class SXSSFPicture implements Picture {
|
|||||||
@Override
|
@Override
|
||||||
public void resize(double scale){
|
public void resize(double scale){
|
||||||
XSSFClientAnchor anchor = getClientAnchor();
|
XSSFClientAnchor anchor = getClientAnchor();
|
||||||
if (anchor == null) {
|
XSSFClientAnchor pref = getPreferredSize(scale);
|
||||||
|
if (anchor == null || pref == null) {
|
||||||
logger.log(POILogger.WARN, "picture is not anchored via client anchor - ignoring resize call");
|
logger.log(POILogger.WARN, "picture is not anchored via client anchor - ignoring resize call");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSSFClientAnchor pref = getPreferredSize(scale);
|
|
||||||
|
|
||||||
int row2 = anchor.getRow1() + (pref.getRow2() - pref.getRow1());
|
int row2 = anchor.getRow1() + (pref.getRow2() - pref.getRow1());
|
||||||
int col2 = anchor.getCol1() + (pref.getCol2() - pref.getCol1());
|
int col2 = anchor.getCol1() + (pref.getCol2() - pref.getCol1());
|
||||||
|
|
||||||
|
@ -176,8 +176,11 @@ public final class XSSFPicture extends XSSFShape implements Picture {
|
|||||||
*/
|
*/
|
||||||
public void resize(double scaleX, double scaleY){
|
public void resize(double scaleX, double scaleY){
|
||||||
XSSFClientAnchor anchor = getClientAnchor();
|
XSSFClientAnchor anchor = getClientAnchor();
|
||||||
|
|
||||||
XSSFClientAnchor pref = getPreferredSize(scaleX,scaleY);
|
XSSFClientAnchor pref = getPreferredSize(scaleX,scaleY);
|
||||||
|
if (anchor == null || pref == null) {
|
||||||
|
logger.log(POILogger.WARN, "picture is not anchored via client anchor - ignoring resize call");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int row2 = anchor.getRow1() + (pref.getRow2() - pref.getRow1());
|
int row2 = anchor.getRow1() + (pref.getRow2() - pref.getRow1());
|
||||||
int col2 = anchor.getCol1() + (pref.getCol2() - pref.getCol1());
|
int col2 = anchor.getCol1() + (pref.getCol2() - pref.getCol1());
|
||||||
|
@ -92,21 +92,11 @@ public class XWPFChart extends XDDFChart {
|
|||||||
|
|
||||||
public Long getChecksum() {
|
public Long getChecksum() {
|
||||||
if (this.checksum == null) {
|
if (this.checksum == null) {
|
||||||
InputStream is = null;
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
try {
|
try (InputStream is = getPackagePart().getInputStream()) {
|
||||||
is = getPackagePart().getInputStream();
|
|
||||||
data = IOUtils.toByteArray(is);
|
data = IOUtils.toByteArray(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new POIXMLException(e);
|
throw new POIXMLException(e);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (is != null) {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new POIXMLException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.checksum = IOUtils.calculateChecksum(data);
|
this.checksum = IOUtils.calculateChecksum(data);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||||||
import org.apache.poi.hslf.model.textproperties.HSLFTabStop;
|
import org.apache.poi.hslf.model.textproperties.HSLFTabStop;
|
||||||
import org.apache.poi.hslf.model.textproperties.HSLFTabStopPropCollection;
|
import org.apache.poi.hslf.model.textproperties.HSLFTabStopPropCollection;
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
||||||
import org.apache.poi.util.LittleEndianOutputStream;
|
import org.apache.poi.util.LittleEndianOutputStream;
|
||||||
@ -89,7 +90,7 @@ public final class TextRulerAtom extends RecordAtom {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the header.
|
// Get the header.
|
||||||
leis.read(_header);
|
IOUtils.readFully(leis, _header);
|
||||||
|
|
||||||
// Get the record data.
|
// Get the record data.
|
||||||
read(leis);
|
read(leis);
|
||||||
|
Loading…
Reference in New Issue
Block a user