From 49fc21b8129bb4310d4cbe20888c9e47cfda04d0 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Fri, 9 Dec 2016 00:39:49 +0000 Subject: [PATCH] SonarCube fix - make members private git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773315 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/blip/Bitmap.java | 7 ++++--- .../src/org/apache/poi/hslf/blip/DIB.java | 6 +++--- .../src/org/apache/poi/hslf/blip/EMF.java | 8 ++++---- .../src/org/apache/poi/hslf/blip/JPEG.java | 12 ++++++------ .../src/org/apache/poi/hslf/blip/Metafile.java | 2 +- .../src/org/apache/poi/hslf/blip/PICT.java | 10 +++++----- .../src/org/apache/poi/hslf/blip/PNG.java | 6 +++--- .../src/org/apache/poi/hslf/blip/WMF.java | 15 ++++++++------- .../org/apache/poi/hslf/usermodel/HSLFFill.java | 13 ++++++------- .../poi/hslf/usermodel/HSLFFreeformShape.java | 15 ++++++++++++--- .../poi/hslf/usermodel/HSLFPictureData.java | 17 ++++++++++++----- 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; iFill 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 lst = bstore.getChildRecords(); @@ -362,7 +361,7 @@ public final class HSLFFill { java.util.List 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. @@ -73,6 +71,15 @@ public abstract class HSLFPictureData implements PictureData { return uidInstanceCount; } + /** + * 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.