fix exception when calling importContent, see Bugzilla 54407
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1436608 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3680179e47
commit
7cde4a3ea7
@ -92,13 +92,18 @@ public final class XSLFPictureData extends POIXMLDocumentPart {
|
|||||||
*/
|
*/
|
||||||
public static final int PICTURE_TYPE_WPG = 12;
|
public static final int PICTURE_TYPE_WPG = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Media Photo image (.wdp)
|
||||||
|
*/
|
||||||
|
public static final int PICTURE_TYPE_WDP = 13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relationships for each known picture type
|
* Relationships for each known picture type
|
||||||
*/
|
*/
|
||||||
protected static final POIXMLRelation[] RELATIONS;
|
protected static final POIXMLRelation[] RELATIONS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
RELATIONS = new POIXMLRelation[13];
|
RELATIONS = new POIXMLRelation[14];
|
||||||
RELATIONS[PICTURE_TYPE_EMF] = XSLFRelation.IMAGE_EMF;
|
RELATIONS[PICTURE_TYPE_EMF] = XSLFRelation.IMAGE_EMF;
|
||||||
RELATIONS[PICTURE_TYPE_WMF] = XSLFRelation.IMAGE_WMF;
|
RELATIONS[PICTURE_TYPE_WMF] = XSLFRelation.IMAGE_WMF;
|
||||||
RELATIONS[PICTURE_TYPE_PICT] = XSLFRelation.IMAGE_PICT;
|
RELATIONS[PICTURE_TYPE_PICT] = XSLFRelation.IMAGE_PICT;
|
||||||
@ -110,6 +115,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart {
|
|||||||
RELATIONS[PICTURE_TYPE_EPS] = XSLFRelation.IMAGE_EPS;
|
RELATIONS[PICTURE_TYPE_EPS] = XSLFRelation.IMAGE_EPS;
|
||||||
RELATIONS[PICTURE_TYPE_BMP] = XSLFRelation.IMAGE_BMP;
|
RELATIONS[PICTURE_TYPE_BMP] = XSLFRelation.IMAGE_BMP;
|
||||||
RELATIONS[PICTURE_TYPE_WPG] = XSLFRelation.IMAGE_WPG;
|
RELATIONS[PICTURE_TYPE_WPG] = XSLFRelation.IMAGE_WPG;
|
||||||
|
RELATIONS[PICTURE_TYPE_WDP] = XSLFRelation.IMAGE_WDP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long checksum = null;
|
private Long checksum = null;
|
||||||
|
@ -23,17 +23,15 @@ import org.apache.poi.POIXMLException;
|
|||||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||||
import org.apache.poi.util.Beta;
|
import org.apache.poi.util.Beta;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
|
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
|
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
|
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
|
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@ -153,6 +151,21 @@ public class XSLFPictureShape extends XSLFSimpleShape {
|
|||||||
// discard any custom tags associated with the picture being copied
|
// discard any custom tags associated with the picture being copied
|
||||||
nvPr.unsetCustDataLst();
|
nvPr.unsetCustDataLst();
|
||||||
}
|
}
|
||||||
|
if(blip.isSetExtLst()) {
|
||||||
|
|
||||||
|
CTOfficeArtExtensionList extLst = blip.getExtLst();
|
||||||
|
for(CTOfficeArtExtension ext : extLst.getExtList()){
|
||||||
|
String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer";
|
||||||
|
XmlObject[] obj = ext.selectPath(xpath);
|
||||||
|
if(obj != null && obj.length == 1){
|
||||||
|
XmlCursor c = obj[0].newCursor();
|
||||||
|
String id = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"));//selectPath("declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' $this//[@embed]");
|
||||||
|
String newId = getSheet().importBlip(id, p.getSheet().getPackagePart());
|
||||||
|
c.setAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"), newId);
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,6 +213,12 @@ public class XSLFRelation extends POIXMLRelation {
|
|||||||
"/ppt/media/image#.wpg",
|
"/ppt/media/image#.wpg",
|
||||||
XSLFPictureData.class
|
XSLFPictureData.class
|
||||||
);
|
);
|
||||||
|
public static final XSLFRelation IMAGE_WDP = new XSLFRelation(
|
||||||
|
"image/vnd.ms-photo",
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
||||||
|
"/ppt/media/image#.wdp",
|
||||||
|
XSLFPictureData.class
|
||||||
|
);
|
||||||
|
|
||||||
public static final XSLFRelation IMAGES = new XSLFRelation(
|
public static final XSLFRelation IMAGES = new XSLFRelation(
|
||||||
null,
|
null,
|
||||||
|
Loading…
Reference in New Issue
Block a user