]> source.dussan.org Git - poi.git/commitdiff
Revert "Replace magic constant with reference" changes
authorMarius Volkhart <mariusvolkhart@apache.org>
Sat, 27 Feb 2021 19:08:49 +0000 (19:08 +0000)
committerMarius Volkhart <mariusvolkhart@apache.org>
Sat, 27 Feb 2021 19:08:49 +0000 (19:08 +0000)
Reverts r1886986, r1886987 and r1886988. Incorrect conversion between int and shorts led to incorrect logic.

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

src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java

index ba1aaf499535021b07ae39f2f1dcd15fafb69473..42682f550d0ef12aa5ca8e6071480cc1253c002e 100644 (file)
@@ -28,7 +28,6 @@ import java.util.NavigableMap;
 import java.util.TreeMap;
 
 import org.apache.poi.EncryptedDocumentException;
-import org.apache.poi.ddf.EscherRecordTypes;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
 import org.apache.poi.hslf.record.DocumentEncryptionAtom;
@@ -221,7 +220,7 @@ public class HSLFSlideShowEncrypted implements Closeable {
             offset += 8;
             int endOffset = offset + rlen;
 
-            if (recType == EscherRecordTypes.BSE.typeID) {
+            if (recType == 0xF007) {
                 // TOOD: get a real example file ... to actual test the FBSE entry
                 // not sure where the foDelay block is
 
@@ -299,7 +298,7 @@ public class HSLFSlideShowEncrypted implements Closeable {
             offset += 8;
             int endOffset = offset + rlen;
 
-            if (recType == EscherRecordTypes.BSE.typeID) {
+            if (recType == 0xF007) {
                 // TOOD: get a real example file ... to actual test the FBSE entry
                 // not sure where the foDelay block is
 
index 4ebe43518faf33033615df1e40f98444f64cfdd1..9c663e385f3719810bd04476a53795a70f5f67f8 100644 (file)
@@ -40,7 +40,6 @@ import java.util.TreeMap;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.poi.POIDocument;
-import org.apache.poi.ddf.EscherRecordTypes;
 import org.apache.poi.hpsf.PropertySet;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.HSLFException;
@@ -381,8 +380,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 >= EscherRecordTypes.BLIP_START.typeID && type <= EscherRecordTypes.BLIP_END.typeID))) {
+                if (!((type == 0xf007) || (type >= 0xf018 && type <= 0xf117))) {
                     break;
                 }
 
@@ -394,7 +392,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
                 }
 
                 // If the type (including the bonus 0xF018) is 0, skip it
-                PictureType pt = PictureType.forNativeID(type - EscherRecordTypes.BLIP_START.typeID);
+                PictureType pt = PictureType.forNativeID(type - 0xF018);
                 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 b778fea19f18459e479117be6dba3e2292ca1109..85205b7bb1a4302b4d3d51858a7f82877736edd5 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 import org.apache.poi.ddf.DefaultEscherRecordFactory;
 import org.apache.poi.ddf.EscherContainerRecord;
 import org.apache.poi.ddf.EscherRecord;
-import org.apache.poi.ddf.EscherRecordTypes;
 import org.apache.poi.hwpf.model.types.PICFAbstractType;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -72,9 +71,9 @@ public class PICFAndOfficeArtData
         {
             EscherRecord nextRecord = escherRecordFactory.createRecord(
                     dataStream, offset );
-            if ( nextRecord.getRecordId() != EscherRecordTypes.BSE.typeID
-                    && ( nextRecord.getRecordId() < EscherRecordTypes.BLIP_START.typeID || nextRecord
-                            .getRecordId() > EscherRecordTypes.BLIP_END.typeID ) )
+            if ( nextRecord.getRecordId() != (short) 0xF007
+                    && ( nextRecord.getRecordId() < (short) 0xF018 || nextRecord
+                            .getRecordId() > (short) 0xF117 ) )
                 break;
 
             int blipRecordSize = nextRecord.fillFields( dataStream, offset,
index 528df95f1823403c0b54f2503aa85252b75f88d9..315e0be4755b90f6dcc269ec47b392a454af9cfd 100644 (file)
@@ -34,7 +34,6 @@ import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperty;
 import org.apache.poi.ddf.EscherPropertyTypes;
 import org.apache.poi.ddf.EscherRecord;
-import org.apache.poi.ddf.EscherRecordTypes;
 import org.apache.poi.hwpf.model.PICF;
 import org.apache.poi.hwpf.model.PICFAndOfficeArtData;
 import org.apache.poi.sl.image.ImageHeaderPNG;
@@ -513,51 +512,56 @@ public final class Picture {
         }
 
         EscherRecord escherRecord = _blipRecords.get( 0 );
-        short recordId = escherRecord.getRecordId();
-        if (recordId == EscherRecordTypes.BSE.typeID) {
+        switch ( escherRecord.getRecordId() )
+        {
+        case (short) 0xF007:
+        {
             EscherBSERecord bseRecord = (EscherBSERecord) escherRecord;
-            switch (bseRecord.getBlipTypeWin32()) {
-                case 0x00:
-                    return PictureType.UNKNOWN;
-                case 0x01:
-                    return PictureType.UNKNOWN;
-                case 0x02:
-                    return PictureType.EMF;
-                case 0x03:
-                    return PictureType.WMF;
-                case 0x04:
-                    return PictureType.PICT;
-                case 0x05:
-                    return PictureType.JPEG;
-                case 0x06:
-                    return PictureType.PNG;
-                case 0x07:
-                    return PictureType.BMP;
-                case 0x11:
-                    return PictureType.TIFF;
-                case 0x12:
-                    return PictureType.JPEG;
-                default:
-                    return PictureType.UNKNOWN;
+            switch ( bseRecord.getBlipTypeWin32() )
+            {
+            case 0x00:
+                return PictureType.UNKNOWN;
+            case 0x01:
+                return PictureType.UNKNOWN;
+            case 0x02:
+                return PictureType.EMF;
+            case 0x03:
+                return PictureType.WMF;
+            case 0x04:
+                return PictureType.PICT;
+            case 0x05:
+                return PictureType.JPEG;
+            case 0x06:
+                return PictureType.PNG;
+            case 0x07:
+                return PictureType.BMP;
+            case 0x11:
+                return PictureType.TIFF;
+            case 0x12:
+                return PictureType.JPEG;
+            default:
+                return PictureType.UNKNOWN;
             }
-        } else if (recordId == (short) 0xF01A) {
+        }
+        case (short) 0xF01A:
             return PictureType.EMF;
-        } else if (recordId == (short) 0xF01B) {
+        case (short) 0xF01B:
             return PictureType.WMF;
-        } else if (recordId == (short) 0xF01C) {
+        case (short) 0xF01C:
             return PictureType.PICT;
-        } else if (recordId == (short) 0xF01D) {
+        case (short) 0xF01D:
             return PictureType.JPEG;
-        } else if (recordId == (short) 0xF01E) {
+        case (short) 0xF01E:
             return PictureType.PNG;
-        } else if (recordId == (short) 0xF01F) {
+        case (short) 0xF01F:
             return PictureType.BMP;
-        } else if (recordId == (short) 0xF029) {
+        case (short) 0xF029:
             return PictureType.TIFF;
-        } else if (recordId == (short) 0xF02A) {
+        case (short) 0xF02A:
             return PictureType.JPEG;
+        default:
+            return PictureType.UNKNOWN;
         }
-        return PictureType.UNKNOWN;
     }
 
     /**