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
* @see HSSFWorkbook#PICTURE_TYPE_PICT
*/
public int getFormat(){
- return blip.getRecordId() - (short)0xF018;
+ return blip.getRecordId() - EscherRecordTypes.BLIP_START.typeID;
}
/**
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;
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();
// 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;
}
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 {
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;