diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-12-09 00:39:49 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-12-09 00:39:49 +0000 |
commit | 49fc21b8129bb4310d4cbe20888c9e47cfda04d0 (patch) | |
tree | b56709281330aeaf3eeaec2d92a650bf72ba1a6f | |
parent | d520b11b59dda6bed44a902035b213b438e76721 (diff) | |
download | poi-49fc21b8129bb4310d4cbe20888c9e47cfda04d0.tar.gz poi-49fc21b8129bb4310d4cbe20888c9e47cfda04d0.zip |
SonarCube fix - make members private
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773315 13f79535-47bb-0310-9956-ffa450edef68
11 files changed, 64 insertions, 47 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java b/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java index f584bd8a8b..2619af9f98 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java @@ -37,7 +37,7 @@ public abstract class Bitmap extends HSLFPictureData { @Override public byte[] getData(){ byte[] rawdata = getRawData(); - int prefixLen = 16*uidInstanceCount+1; + int prefixLen = 16*getUIDInstanceCount()+1; byte[] imgdata = new byte[rawdata.length-prefixLen]; System.arraycopy(rawdata, prefixLen, imgdata, 0, imgdata.length); return imgdata; @@ -45,9 +45,10 @@ public abstract class Bitmap extends HSLFPictureData { @Override public void setData(byte[] data) throws IOException { + byte[] checksum = getChecksum(data); ByteArrayOutputStream out = new ByteArrayOutputStream(); - for (int i=0; i<uidInstanceCount; i++) { - byte[] checksum = getChecksum(data); + out.write(checksum); + if (getUIDInstanceCount() == 2) { out.write(checksum); } out.write(0); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java index a0283aabd5..e71d2b4af8 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java @@ -41,7 +41,7 @@ public final class DIB extends Bitmap { * @return DIB signature ({@code 0x7A80} or {@code 0x7A90}) */ public int getSignature(){ - return (uidInstanceCount == 1 ? 0x7A80 : 0x7A90); + return (getUIDInstanceCount() == 1 ? 0x7A80 : 0x7A90); } /** @@ -50,10 +50,10 @@ public final class DIB extends Bitmap { public void setSignature(int signature) { switch (signature) { case 0x7A80: - uidInstanceCount = 1; + setUIDInstanceCount(1); break; case 0x7A90: - uidInstanceCount = 2; + setUIDInstanceCount(2); break; default: throw new IllegalArgumentException(signature+" is not a valid instance/signature value for DIB"); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java index c3f07fa8e7..39cd93bc5b 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java @@ -74,7 +74,7 @@ public final class EMF extends Metafile { byte[] checksum = getChecksum(data); ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(checksum); - if (uidInstanceCount == 2) { + if (getUIDInstanceCount() == 2) { out.write(checksum); } header.write(out); @@ -94,7 +94,7 @@ public final class EMF extends Metafile { * @return EMF signature ({@code 0x3D40} or {@code 0x3D50}) */ public int getSignature(){ - return (uidInstanceCount == 1 ? 0x3D40 : 0x3D50); + return (getUIDInstanceCount() == 1 ? 0x3D40 : 0x3D50); } /** @@ -103,10 +103,10 @@ public final class EMF extends Metafile { public void setSignature(int signature) { switch (signature) { case 0x3D40: - uidInstanceCount = 1; + setUIDInstanceCount(1); break; case 0x3D50: - uidInstanceCount = 2; + setUIDInstanceCount(2); break; default: throw new IllegalArgumentException(signature+" is not a valid instance/signature value for EMF"); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java b/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java index 72cac5f90d..08ba6b73e7 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java @@ -47,8 +47,8 @@ public final class JPEG extends Bitmap { */ public int getSignature(){ return (colorSpace == ColorSpace.rgb) - ? (uidInstanceCount == 1 ? 0x46A0 : 0x46B0) - : (uidInstanceCount == 1 ? 0x6E20 : 0x6E30); + ? (getUIDInstanceCount() == 1 ? 0x46A0 : 0x46B0) + : (getUIDInstanceCount() == 1 ? 0x6E20 : 0x6E30); } /** @@ -57,19 +57,19 @@ public final class JPEG extends Bitmap { public void setSignature(int signature) { switch (signature) { case 0x46A0: - uidInstanceCount = 1; + setUIDInstanceCount(1); colorSpace = ColorSpace.rgb; break; case 0x46B0: - uidInstanceCount = 2; + setUIDInstanceCount(2); colorSpace = ColorSpace.rgb; break; case 0x6E20: - uidInstanceCount = 1; + setUIDInstanceCount(1); colorSpace = ColorSpace.cymk; break; case 0x6E30: - uidInstanceCount = 2; + setUIDInstanceCount(2); colorSpace = ColorSpace.cymk; break; default: diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java b/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java index 5c7da5a2c7..88d8a6198d 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java @@ -152,7 +152,7 @@ public abstract class Metafile extends HSLFPictureData { @Override public Dimension getImageDimension() { - int prefixLen = 16*uidInstanceCount; + int prefixLen = 16*getUIDInstanceCount(); Header header = new Header(); header.read(getRawData(), prefixLen); return new Dimension( diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java index 4a378c46f9..7494b55337 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java @@ -43,7 +43,7 @@ public final class PICT extends Metafile { byte[] macheader = new byte[512]; ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(macheader); - int pos = CHECKSUM_SIZE*uidInstanceCount; + int pos = CHECKSUM_SIZE*getUIDInstanceCount(); byte[] pict = read(rawdata, pos); out.write(pict); return out.toByteArray(); @@ -105,7 +105,7 @@ public final class PICT extends Metafile { byte[] checksum = getChecksum(data); ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(checksum); - if (uidInstanceCount == 2) { + if (getUIDInstanceCount() == 2) { out.write(checksum); } header.write(out); @@ -125,7 +125,7 @@ public final class PICT extends Metafile { * @return PICT signature ({@code 0x5420} or {@code 0x5430}) */ public int getSignature(){ - return (uidInstanceCount == 1 ? 0x5420 : 0x5430); + return (getUIDInstanceCount() == 1 ? 0x5420 : 0x5430); } /** @@ -134,10 +134,10 @@ public final class PICT extends Metafile { public void setSignature(int signature) { switch (signature) { case 0x5420: - uidInstanceCount = 1; + setUIDInstanceCount(1); break; case 0x5430: - uidInstanceCount = 2; + setUIDInstanceCount(2); break; default: throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PICT"); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java b/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java index b338d9d171..f2abc4068d 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java @@ -50,7 +50,7 @@ public final class PNG extends Bitmap { * @return PNG signature ({@code 0x6E00} or {@code 0x6E10}) */ public int getSignature(){ - return (uidInstanceCount == 1 ? 0x6E00 : 0x6E10); + return (getUIDInstanceCount() == 1 ? 0x6E00 : 0x6E10); } /** @@ -59,10 +59,10 @@ public final class PNG extends Bitmap { public void setSignature(int signature) { switch (signature) { case 0x6E00: - uidInstanceCount = 1; + setUIDInstanceCount(1); break; case 0x6E10: - uidInstanceCount = 2; + setUIDInstanceCount(2); break; default: throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PNG"); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java index d54f1384b2..dd88b90fe3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java @@ -41,9 +41,9 @@ public final class WMF extends Metafile { ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream is = new ByteArrayInputStream( rawdata ); Header header = new Header(); - header.read(rawdata, CHECKSUM_SIZE*uidInstanceCount); - long len = is.skip(header.getSize() + CHECKSUM_SIZE*uidInstanceCount); - assert(len == header.getSize() + CHECKSUM_SIZE*uidInstanceCount); + header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount()); + long len = is.skip(header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount()); + assert(len == header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount()); ImageHeaderWMF aldus = new ImageHeaderWMF(header.getBounds()); aldus.write(out); @@ -78,7 +78,8 @@ public final class WMF extends Metafile { byte[] checksum = getChecksum(data); ByteArrayOutputStream out = new ByteArrayOutputStream(); - for (int i=0; i<uidInstanceCount; i++) { + out.write(checksum); + if (getUIDInstanceCount() == 2) { out.write(checksum); } header.write(out); @@ -96,7 +97,7 @@ public final class WMF extends Metafile { * WMF signature is either {@code 0x2160} or {@code 0x2170} */ public int getSignature(){ - return (uidInstanceCount == 1 ? 0x2160 : 0x2170); + return (getUIDInstanceCount() == 1 ? 0x2160 : 0x2170); } /** @@ -105,10 +106,10 @@ public final class WMF extends Metafile { public void setSignature(int signature) { switch (signature) { case 0x2160: - uidInstanceCount = 1; + setUIDInstanceCount(1); break; case 0x2170: - uidInstanceCount = 2; + setUIDInstanceCount(2); break; default: throw new IllegalArgumentException(signature+" is not a valid instance/signature value for WMF"); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java index 4d68995480..8eb18ee69c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java @@ -47,8 +47,7 @@ import org.apache.poi.util.Units; * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint. */ public final class HSLFFill { - // For logging - protected POILogger logger = POILogFactory.getLogger(this.getClass()); + private static final POILogger LOG = POILogFactory.getLogger(HSLFFill.class); /** * Fill with a solid color @@ -107,7 +106,7 @@ public final class HSLFFill { /** * The shape this background applies to */ - protected HSLFShape shape; + private HSLFShape shape; /** * Construct a <code>Fill</code> object for a shape. @@ -141,7 +140,7 @@ public final class HSLFFill { case FILL_PICTURE: return getTexturePaint(); default: - logger.log(POILogger.WARN, "unsuported fill type: " + fillType); + LOG.log(POILogger.WARN, "unsuported fill type: " + fillType); return null; } } @@ -255,7 +254,7 @@ public final class HSLFFill { protected EscherBSERecord getEscherBSERecord(int idx){ HSLFSheet sheet = shape.getSheet(); if(sheet == null) { - logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); + LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); return null; } HSLFSlideShow ppt = sheet.getSlideShow(); @@ -263,7 +262,7 @@ public final class HSLFFill { EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { - logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); + LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List<EscherRecord> lst = bstore.getChildRecords(); @@ -362,7 +361,7 @@ public final class HSLFFill { java.util.List<EscherRecord> lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); if (idx == 0){ - logger.log(POILogger.WARN, "no reference to picture data found "); + LOG.log(POILogger.WARN, "no reference to picture data found "); } else { EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); for (HSLFPictureData pd : pict) { diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java index 740d9532d7..0e8437ae1a 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java @@ -65,10 +65,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh enum PathInfo { lineTo(0),curveTo(1),moveTo(2),close(3),end(4),escape(5),clientEscape(6); - int flag; + private final int flag; PathInfo(int flag) { this.flag = flag; } + public int getFlag() { + return flag; + } static PathInfo valueOf(int flag) { for (PathInfo v : values()) { if (v.flag == flag) { @@ -104,10 +107,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh FILL_COLOR(0X0015), LINE_COLOR(0X0016); - int flag; + private final int flag; EscapeInfo(int flag) { this.flag = flag; } + public int getFlag() { + return flag; + } static EscapeInfo valueOf(int flag) { for (EscapeInfo v : values()) { if (v.flag == flag) { @@ -125,10 +131,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh CURVES_CLOSED(3), COMPLEX(4); - int flag; + private final int flag; ShapePath(int flag) { this.flag = flag; } + public int getFlag() { + return flag; + } static ShapePath valueOf(int flag) { for (ShapePath v : values()) { if (v.flag == flag) { diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java index f3da760972..1a8061d3c9 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java @@ -30,8 +30,6 @@ import org.apache.poi.util.*; /** * A class that represents image data contained in a slide show. - * - * @author Yegor Kozlov */ public abstract class HSLFPictureData implements PictureData { @@ -47,17 +45,17 @@ public abstract class HSLFPictureData implements PictureData { /** * The offset to the picture in the stream */ - protected int offset; + private int offset; /** * The instance type/signatures defines if one or two UID instances will be included */ - protected int uidInstanceCount = 1; + private int uidInstanceCount = 1; /** * The 1-based index within the pictures stream */ - protected int index = -1; + private int index = -1; /** * Blip signature. @@ -74,6 +72,15 @@ public abstract class HSLFPictureData implements PictureData { } /** + * The instance type/signatures defines if one or two UID instances will be included + * + * @param uidInstanceCount the number of uid sequences + */ + protected void setUIDInstanceCount(int uidInstanceCount) { + this.uidInstanceCount = uidInstanceCount; + } + + /** * Returns the raw binary data of this Picture excluding the first 8 bytes * which hold image signature and size of the image data. * |