mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Avoid ClastCastException when handling a broken ppt file
This commit is contained in:
parent
b401b92aea
commit
1fc4f9e3b7
@ -25,6 +25,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.ddf.EscherProperty;
|
||||
import org.apache.poi.logging.PoiLogManager;
|
||||
import org.apache.poi.ddf.AbstractEscherOptRecord;
|
||||
import org.apache.poi.ddf.EscherArrayProperty;
|
||||
@ -217,7 +218,7 @@ public final class HSLFFill {
|
||||
/**
|
||||
* The shape this background applies to
|
||||
*/
|
||||
private HSLFShape shape;
|
||||
private final HSLFShape shape;
|
||||
|
||||
/**
|
||||
* Construct a {@code Fill} object for a shape.
|
||||
@ -457,7 +458,6 @@ public final class HSLFFill {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
EscherBSERecord getEscherBSERecord(int idx){
|
||||
HSLFSheet sheet = shape.getSheet();
|
||||
if(sheet == null) {
|
||||
@ -560,11 +560,10 @@ public final class HSLFFill {
|
||||
/**
|
||||
* {@code PictureData} object used in a texture, pattern of picture fill.
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public HSLFPictureData getPictureData(){
|
||||
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
|
||||
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherPropertyTypes.FILL__PATTERNTEXTURE);
|
||||
if (p == null) {
|
||||
EscherProperty p = HSLFShape.getEscherProperty(opt, EscherPropertyTypes.FILL__PATTERNTEXTURE);
|
||||
if (!(p instanceof EscherSimpleProperty)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -575,7 +574,7 @@ public final class HSLFFill {
|
||||
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
||||
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
|
||||
|
||||
int idx = p.getPropertyValue();
|
||||
int idx = ((EscherSimpleProperty)p).getPropertyValue();
|
||||
if (idx == 0){
|
||||
LOG.atWarn().log("no reference to picture data found ");
|
||||
} else {
|
||||
|
||||
@ -266,7 +266,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
||||
* @return escher property or {@code null} if not found.
|
||||
*/
|
||||
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){
|
||||
return (opt == null) ? null : opt.lookup(type);
|
||||
return opt == null ? null : opt.lookup(type);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -659,9 +659,9 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records
|
||||
* Search for EscherClientDataRecord, if found, convert its contents into a list of HSLF records
|
||||
*
|
||||
* @return an array of HSLF records contained in the shape's EscherClientDataRecord or {@code null}
|
||||
* @return a list of HSLF records contained in the shape's EscherClientDataRecord or {@code null}
|
||||
*/
|
||||
protected List<? extends Record> getClientRecords() {
|
||||
HSLFEscherClientDataRecord clientData = getClientData(false);
|
||||
|
||||
BIN
test-data/slideshow/119877_all type background_save_by_AOO.ppt
Normal file
BIN
test-data/slideshow/119877_all type background_save_by_AOO.ppt
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user