sonarcube fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1771978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-11-29 23:14:43 +00:00
parent 200850c1e4
commit 48ff8e5686
3 changed files with 31 additions and 29 deletions

View File

@ -28,15 +28,16 @@ import org.apache.poi.util.POILogger;
@Internal @Internal
public class ImageHeaderEMF { public class ImageHeaderEMF {
private static POILogger LOG = POILogFactory.getLogger(ImageHeaderEMF.class); private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderEMF.class);
private final static String EMF_SIGNATURE = " EMF"; // 0x464D4520 (LE) private static final String EMF_SIGNATURE = " EMF"; // 0x464D4520 (LE)
// rectangular inclusive-inclusive bounds, in device units, of the smallest // rectangular inclusive-inclusive bounds, in device units, of the smallest
// rectangle that can be drawn around the image stored in the metafile. // rectangle that can be drawn around the image stored in the metafile.
private final Rectangle deviceBounds; private final Rectangle deviceBounds;
public ImageHeaderEMF(byte data[], int offset) { public ImageHeaderEMF(final byte data[], final int off) {
int offset = off;
int type = (int)LittleEndian.getUInt(data, offset); offset += 4; int type = (int)LittleEndian.getUInt(data, offset); offset += 4;
if (type != 1) { if (type != 1) {
LOG.log(POILogger.WARN, "Invalid EMF picture - invalid type"); LOG.log(POILogger.WARN, "Invalid EMF picture - invalid type");

View File

@ -42,9 +42,9 @@ public class ImageHeaderPICT {
private final Rectangle bounds; private final Rectangle bounds;
private final double hRes, vRes; private final double hRes, vRes;
public ImageHeaderPICT(byte data[], int offset) { public ImageHeaderPICT(byte data[], final int off) {
// http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt // http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt
int offset = off;
// low order 16 bits of picture size - can be ignored // low order 16 bits of picture size - can be ignored
offset += 2; offset += 2;
// rectangular bounding box of picture, at 72 dpi // rectangular bounding box of picture, at 72 dpi

View File

@ -46,7 +46,7 @@ import org.apache.poi.util.Units;
public class ImageHeaderWMF { public class ImageHeaderWMF {
public static final int APMHEADER_KEY = 0x9AC6CDD7; public static final int APMHEADER_KEY = 0x9AC6CDD7;
private static POILogger LOG = POILogFactory.getLogger(ImageHeaderWMF.class); private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderWMF.class);
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final int handle; private final int handle;
@ -75,8 +75,9 @@ public class ImageHeaderWMF {
reserved = 0; reserved = 0;
} }
public ImageHeaderWMF(byte[] data, int pos) { public ImageHeaderWMF(byte[] data, final int off) {
int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key int offset = off;
int key = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; //header key
if (key != APMHEADER_KEY) { if (key != APMHEADER_KEY) {
LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing"); LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing");
handle = 0; handle = 0;
@ -89,16 +90,16 @@ public class ImageHeaderWMF {
return; return;
} }
handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE; handle = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE;
left = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE; left = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
top = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE; top = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
right = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE; right = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
bottom = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE; bottom = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE; inch = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE;
reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; reserved = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE;
checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE; checksum = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
if (checksum != getChecksum()){ if (checksum != getChecksum()){
LOG.log(POILogger.WARN, "WMF checksum does not match the header data"); LOG.log(POILogger.WARN, "WMF checksum does not match the header data");
} }