aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarius Volkhart <mariusvolkhart@apache.org>2021-02-27 18:22:33 +0000
committerMarius Volkhart <mariusvolkhart@apache.org>2021-02-27 18:22:33 +0000
commitd543e89185be6034988131acf419744b4d955b6b (patch)
tree6330d9c9061740528c208ca8cada31f6a9c94ebf /src
parent16561e85c784cdc49884e7586c86aa397ade9876 (diff)
downloadpoi-d543e89185be6034988131acf419744b4d955b6b.tar.gz
poi-d543e89185be6034988131acf419744b4d955b6b.zip
Replace magic constant use of EscherBSERecord type ID with reference
Instead of referring to the magic constant 0xF007, reference the value in the EscherRecordTypes enum. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886986 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java5
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java74
4 files changed, 42 insertions, 43 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
index 42682f550d..ba1aaf4995 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
@@ -28,6 +28,7 @@ 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;
@@ -220,7 +221,7 @@ public class HSLFSlideShowEncrypted implements Closeable {
offset += 8;
int endOffset = offset + rlen;
- if (recType == 0xF007) {
+ if (recType == EscherRecordTypes.BSE.typeID) {
// TOOD: get a real example file ... to actual test the FBSE entry
// not sure where the foDelay block is
@@ -298,7 +299,7 @@ public class HSLFSlideShowEncrypted implements Closeable {
offset += 8;
int endOffset = offset + rlen;
- if (recType == 0xF007) {
+ if (recType == EscherRecordTypes.BSE.typeID) {
// TOOD: get a real example file ... to actual test the FBSE entry
// not sure where the foDelay block is
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
index 4295712b89..98b62bfb83 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
@@ -40,6 +40,7 @@ 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;
@@ -380,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 == 0xf007) || (type >= 0xf018 && type <= 0xf117))) {
+ if (!((type == EscherRecordTypes.BSE.typeID) || (type >= 0xf018 && type <= 0xf117))) {
break;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
index 85205b7bb1..fdf0a12857 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
@@ -22,6 +22,7 @@ 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;
@@ -71,7 +72,7 @@ public class PICFAndOfficeArtData
{
EscherRecord nextRecord = escherRecordFactory.createRecord(
dataStream, offset );
- if ( nextRecord.getRecordId() != (short) 0xF007
+ if ( nextRecord.getRecordId() != EscherRecordTypes.BSE.typeID
&& ( nextRecord.getRecordId() < (short) 0xF018 || nextRecord
.getRecordId() > (short) 0xF117 ) )
break;
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
index 315e0be475..528df95f18 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
@@ -34,6 +34,7 @@ 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;
@@ -512,56 +513,51 @@ public final class Picture {
}
EscherRecord escherRecord = _blipRecords.get( 0 );
- switch ( escherRecord.getRecordId() )
- {
- case (short) 0xF007:
- {
+ short recordId = escherRecord.getRecordId();
+ if (recordId == EscherRecordTypes.BSE.typeID) {
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;
}
- }
- case (short) 0xF01A:
+ } else if (recordId == (short) 0xF01A) {
return PictureType.EMF;
- case (short) 0xF01B:
+ } else if (recordId == (short) 0xF01B) {
return PictureType.WMF;
- case (short) 0xF01C:
+ } else if (recordId == (short) 0xF01C) {
return PictureType.PICT;
- case (short) 0xF01D:
+ } else if (recordId == (short) 0xF01D) {
return PictureType.JPEG;
- case (short) 0xF01E:
+ } else if (recordId == (short) 0xF01E) {
return PictureType.PNG;
- case (short) 0xF01F:
+ } else if (recordId == (short) 0xF01F) {
return PictureType.BMP;
- case (short) 0xF029:
+ } else if (recordId == (short) 0xF029) {
return PictureType.TIFF;
- case (short) 0xF02A:
+ } else if (recordId == (short) 0xF02A) {
return PictureType.JPEG;
- default:
- return PictureType.UNKNOWN;
}
+ return PictureType.UNKNOWN;
}
/**