]> source.dussan.org Git - poi.git/commitdiff
SonarCube fix - make members private
authorAndreas Beeker <kiwiwings@apache.org>
Fri, 9 Dec 2016 00:39:49 +0000 (00:39 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Fri, 9 Dec 2016 00:39:49 +0000 (00:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773315 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java
src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java
src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java
src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java
src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java

index f584bd8a8b0dba600e4eae768c831aec0347d232..2619af9f98bf4a600fee358af060340e8f9d32f2 100644 (file)
@@ -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);
index a0283aabd5e4b6153efd25b94572da9680fe8264..e71d2b4af84acdaf0a122a31aa247ab70c38e573 100644 (file)
@@ -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");
index c3f07fa8e7e5ebbe05489334d9cf1259435700d2..39cd93bc5bcbacc0b76c50a6c6178f0f23e0d960 100644 (file)
@@ -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");
index 72cac5f90dc257f189726e533107521a3aafa9e6..08ba6b73e73c18933b8d9824f121fcb0759691dc 100644 (file)
@@ -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:
index 5c7da5a2c70d481942f4c1a40b699ee18848bee8..88d8a6198d864d09c1632b70599eb2cd4a0f9af0 100644 (file)
@@ -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(
index 4a378c46f9399e02821818bbce65fe3ea6b6ea23..7494b55337b84548de3a64400daeb07a7e4e744e 100644 (file)
@@ -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");
index b338d9d171550e4ab8c236b63e77b59da32e748e..f2abc4068dd581e6ebc30304e5725dc06a46dc56 100644 (file)
@@ -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");
index d54f1384b21fff24bb3b20238dee68a76c25e0ff..dd88b90fe38bb499e9e362ca9678a21d2ef91f23 100644 (file)
@@ -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");
index 4d68995480714dbd4ef27aa292822d9cc64a84db..8eb18ee69cc39dfaa975a91f1077de6a565fc5d4 100644 (file)
@@ -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) {
index 740d9532d7ce236ecc0e51225834882f82285c11..0e8437ae1ad877d753b6a266e6fc9f8dbf4f9bac 100644 (file)
@@ -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) {
index f3da76097231aaffb45e9bc1482ef2c3ca71483d..1a8061d3c9c99928d5daaced3009e28d469892bd 100644 (file)
@@ -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.