]> source.dussan.org Git - poi.git/commitdiff
Replace magic constant use of Escher Blip Start type ID with reference
authorMarius Volkhart <mariusvolkhart@apache.org>
Sat, 27 Feb 2021 18:26:36 +0000 (18:26 +0000)
committerMarius Volkhart <mariusvolkhart@apache.org>
Sat, 27 Feb 2021 18:26:36 +0000 (18:26 +0000)
Instead of referring to the magic constant 0xF018, reference the value in the EscherRecordTypes enum.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886987 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java

index bf0ba3196ec9beab45fee91ec8a391085a240c4d..9dd6079624347d2ca9acba9b8d855a3df466a417 100644 (file)
@@ -72,7 +72,7 @@ public class HSSFPictureData implements PictureData
      * @see HSSFWorkbook#PICTURE_TYPE_PICT
      */
     public int getFormat(){
-        return blip.getRecordId() - (short)0xF018;
+        return blip.getRecordId() - EscherRecordTypes.BLIP_START.typeID;
     }
 
     /**
index f5b2eaa1ce9b72ec6b3c476fbff57287741d4d12..2f3371d714d234918600f81c60e6206a57466827 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.function.Supplier;
 
 import org.apache.poi.common.usermodel.GenericRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
 import org.apache.poi.hslf.blip.DIB;
 import org.apache.poi.hslf.blip.EMF;
 import org.apache.poi.hslf.blip.JPEG;
@@ -159,7 +160,7 @@ public abstract class HSLFPictureData implements PictureData, GenericRecord {
 
         data = new byte[LittleEndianConsts.SHORT_SIZE];
         PictureType pt = getType();
-        LittleEndian.putUShort(data, 0, pt.nativeId + 0xF018);
+        LittleEndian.putUShort(data, 0, pt.nativeId + EscherRecordTypes.BLIP_START.typeID);
         out.write(data);
 
         byte[] rd = getRawData();
index 98b62bfb8333d52d9935300ce0e91fe8f42d3922..b489605827eaec4c2727653c70b6ad4796072243 100644 (file)
@@ -381,7 +381,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
 
                 // When parsing the BStoreDelay stream, [MS-ODRAW] says that we
                 //  should terminate if the type isn't 0xf007 or 0xf018->0xf117
-                if (!((type == EscherRecordTypes.BSE.typeID) || (type >= 0xf018 && type <= 0xf117))) {
+                if (!((type == EscherRecordTypes.BSE.typeID) || (type >= EscherRecordTypes.BLIP_START.typeID && type <= 0xf117))) {
                     break;
                 }
 
@@ -392,8 +392,8 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
                     throw new CorruptPowerPointFileException("The file contains a picture, at position " + _pictures.size() + ", which has a negatively sized data length, so we can't trust any of the picture data");
                 }
 
-                // If they type (including the bonus 0xF018) is 0, skip it
-                PictureType pt = PictureType.forNativeID(type - 0xF018);
+                // If the type (including the bonus 0xF018) is 0, skip it
+                PictureType pt = PictureType.forNativeID(type - EscherRecordTypes.BLIP_START.typeID);
                 if (pt == null) {
                     LOG.atError().log("Problem reading picture: Invalid image type 0, on picture with length {}.\nYour document will probably become corrupted if you save it! Position: {}", box(imgsize),box(pos));
                 } else {
index fdf0a12857bd5f4a590592692223a45cd2c021b1..99eda8228f8043c71e9f9b0a1c137ee5ec0a7e90 100644 (file)
@@ -73,7 +73,7 @@ public class PICFAndOfficeArtData
             EscherRecord nextRecord = escherRecordFactory.createRecord(
                     dataStream, offset );
             if ( nextRecord.getRecordId() != EscherRecordTypes.BSE.typeID
-                    && ( nextRecord.getRecordId() < (short) 0xF018 || nextRecord
+                    && ( nextRecord.getRecordId() < EscherRecordTypes.BLIP_START.typeID || nextRecord
                             .getRecordId() > (short) 0xF117 ) )
                 break;