diff options
author | Marius Volkhart <mariusvolkhart@apache.org> | 2021-02-27 18:26:36 +0000 |
---|---|---|
committer | Marius Volkhart <mariusvolkhart@apache.org> | 2021-02-27 18:26:36 +0000 |
commit | b9bbac0005c9a5b1e3508c46389f6746232148a6 (patch) | |
tree | 96cb92e50c923ad6492ec66baa2f5ac15e2258c9 /src | |
parent | d543e89185be6034988131acf419744b4d955b6b (diff) | |
download | poi-b9bbac0005c9a5b1e3508c46389f6746232148a6.tar.gz poi-b9bbac0005c9a5b1e3508c46389f6746232148a6.zip |
Replace magic constant use of Escher Blip Start type ID with reference
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
Diffstat (limited to 'src')
4 files changed, 7 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java index bf0ba3196e..9dd6079624 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java @@ -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; } /** 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 f5b2eaa1ce..2f3371d714 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java @@ -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(); 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 98b62bfb83..b489605827 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java @@ -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 { 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 fdf0a12857..99eda8228f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java @@ -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; |