Lines 35-40
import org.apache.xmlbeans.XmlException;
Link Here
|
35 |
import org.apache.xmlbeans.XmlObject; |
35 |
import org.apache.xmlbeans.XmlObject; |
36 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; |
36 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; |
37 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; |
37 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; |
|
|
38 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData; |
38 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; |
39 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; |
39 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension; |
40 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension; |
40 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList; |
41 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList; |
Lines 43-57
import org.openxmlformats.schemas.drawingml.x2006.main.CTRelativeRect;
Link Here
|
43 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; |
44 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; |
44 |
import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; |
45 |
import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; |
45 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps; |
46 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps; |
|
|
47 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame; |
48 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrameNonVisual; |
46 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture; |
49 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture; |
47 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual; |
50 |
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual; |
48 |
|
51 |
|
|
|
52 |
|
53 |
|
49 |
/** |
54 |
/** |
50 |
* Represents a picture shape |
55 |
* Represents a picture shape |
51 |
*/ |
56 |
*/ |
52 |
@Beta |
57 |
@Beta |
53 |
public class XSLFPictureShape extends XSLFSimpleShape |
58 |
public class XSLFPictureShape extends XSLFSimpleShape |
54 |
implements PictureShape<XSLFShape,XSLFTextParagraph> { |
59 |
implements PictureShape<XSLFShape,XSLFTextParagraph> { |
|
|
60 |
|
61 |
/* package */ static final String SVG_URI = "http://schemas.microsoft.com/office/drawing/2016/SVG/main"; |
62 |
/* package */ static final String REL_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"; |
63 |
/* package */ static final String DML_URI = "http://schemas.microsoft.com/office/drawing/2010/main"; |
64 |
|
55 |
private XSLFPictureData _data; |
65 |
private XSLFPictureData _data; |
56 |
|
66 |
|
57 |
/*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) { |
67 |
/*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) { |
Lines 63-69
public class XSLFPictureShape extends XSLFSimpleShape
Link Here
|
63 |
* @param shapeId 1-based shapeId |
73 |
* @param shapeId 1-based shapeId |
64 |
* @param rel relationship to the picture data in the ooxml package |
74 |
* @param rel relationship to the picture data in the ooxml package |
65 |
*/ |
75 |
*/ |
66 |
static CTPicture prototype(int shapeId, String rel) { |
76 |
static CTPicture prototype(int shapeId, String rel, String rel2) { |
|
|
77 |
|
78 |
CTGraphicalObjectFrame frame = CTGraphicalObjectFrame.Factory.newInstance(); |
79 |
CTGraphicalObjectFrameNonVisual nvGr = frame.addNewNvGraphicFramePr(); |
80 |
|
81 |
// add empty property elements otherwise Powerpoint doesn't load the file ... |
82 |
nvGr.addNewCNvGraphicFramePr(); |
83 |
nvGr.addNewNvPr(); |
84 |
|
67 |
CTPicture ct = CTPicture.Factory.newInstance(); |
85 |
CTPicture ct = CTPicture.Factory.newInstance(); |
68 |
CTPictureNonVisual nvSpPr = ct.addNewNvPicPr(); |
86 |
CTPictureNonVisual nvSpPr = ct.addNewNvPicPr(); |
69 |
CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr(); |
87 |
CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr(); |
Lines 74-80
public class XSLFPictureShape extends XSLFSimpleShape
Link Here
|
74 |
|
92 |
|
75 |
CTBlipFillProperties blipFill = ct.addNewBlipFill(); |
93 |
CTBlipFillProperties blipFill = ct.addNewBlipFill(); |
76 |
CTBlip blip = blipFill.addNewBlip(); |
94 |
CTBlip blip = blipFill.addNewBlip(); |
77 |
blip.setEmbed(rel); |
95 |
|
|
|
96 |
/* |
97 |
frame.addNewXfrm(); |
98 |
CTGraphicalObjectData gr = frame.addNewGraphic().addNewGraphicData(); |
99 |
gr.setUri(SVG_URI); |
100 |
XmlCursor grCur = gr.newCursor(); |
101 |
grCur.toEndToken(); |
102 |
grCur.beginElement(new QName(SVG_URI, "svgBlip", "asvg")); |
103 |
grCur.insertAttributeWithValue(new QName(PML_NS, "embed", "r"), "rID3"); |
104 |
*/ |
105 |
|
106 |
if (rel2 == null) { |
107 |
blip.setEmbed(rel); |
108 |
} |
109 |
else { |
110 |
blip.setEmbed(rel2); |
111 |
// add PNG and SVG |
112 |
CTOfficeArtExtensionList extLst = blip.addNewExtLst(); |
113 |
|
114 |
// add PNG |
115 |
CTOfficeArtExtension ext = extLst.addNewExt(); |
116 |
ext.setUri("{28A0092B-C50C-407E-A947-70E740481C1C}"); |
117 |
XmlCursor cur = ext.newCursor(); |
118 |
cur.toEndToken(); |
119 |
cur.beginElement(new QName(DML_URI, "useLocalDpi", "a14")); |
120 |
cur.insertAttributeWithValue("val", "0"); |
121 |
|
122 |
// add SVG image |
123 |
ext = extLst.addNewExt(); |
124 |
ext.setUri("{96DAC541-7B7A-43D3-8B79-37D633B846F1}"); |
125 |
cur = ext.newCursor(); |
126 |
cur.toEndToken(); |
127 |
cur.beginElement(new QName(SVG_URI, "svgBlip", "asvg")); |
128 |
cur.insertAttributeWithValue(new QName(REL_URI, "embed", "rel"), rel); |
129 |
} |
130 |
|
78 |
blipFill.addNewStretch().addNewFillRect(); |
131 |
blipFill.addNewStretch().addNewFillRect(); |
79 |
|
132 |
|
80 |
CTShapeProperties spPr = ct.addNewSpPr(); |
133 |
CTShapeProperties spPr = ct.addNewSpPr(); |
Lines 84-90
public class XSLFPictureShape extends XSLFSimpleShape
Link Here
|
84 |
return ct; |
137 |
return ct; |
85 |
} |
138 |
} |
86 |
|
139 |
|
87 |
|
140 |
|
|
|
141 |
|
88 |
/** |
142 |
/** |
89 |
* Is this an internal picture (image data included within |
143 |
* Is this an internal picture (image data included within |
90 |
* the PowerPoint file), or an external linked picture |
144 |
* the PowerPoint file), or an external linked picture |