mirror of https://github.com/apache/poi.git
use try-with-resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902873 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
48e9d6a6d5
commit
369681f7f9
|
@ -165,16 +165,14 @@ public class AddVideoToPptx {
|
||||||
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
|
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
|
||||||
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
|
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
|
||||||
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
||||||
XmlCursor cur = ext.newCursor();
|
|
||||||
try {
|
try (XmlCursor cur = ext.newCursor()) {
|
||||||
cur.toEndToken();
|
cur.toEndToken();
|
||||||
cur.beginElement(new QName(p14Ns, "media", "p14"));
|
cur.beginElement(new QName(p14Ns, "media", "p14"));
|
||||||
cur.insertNamespace("p14", p14Ns);
|
cur.insertNamespace("p14", p14Ns);
|
||||||
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
|
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
|
||||||
cur.beginElement(new QName(p14Ns, "trim", "p14"));
|
cur.beginElement(new QName(p14Ns, "trim", "p14"));
|
||||||
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
|
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
|
||||||
} finally {
|
|
||||||
cur.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,14 +84,11 @@ public final class LinkVideoToPptx {
|
||||||
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
|
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
|
||||||
|
|
||||||
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
||||||
XmlCursor cur = ext.newCursor();
|
try (XmlCursor cur = ext.newCursor()) {
|
||||||
try {
|
|
||||||
cur.toEndToken();
|
cur.toEndToken();
|
||||||
cur.beginElement(new QName(p14Ns, "media", "p14"));
|
cur.beginElement(new QName(p14Ns, "media", "p14"));
|
||||||
cur.insertNamespace("p14", p14Ns);
|
cur.insertNamespace("p14", p14Ns);
|
||||||
cur.insertAttributeWithValue(new QName(CORE_PROPERTIES_ECMA376_NS, "link"), prsEmbed1.getId());
|
cur.insertAttributeWithValue(new QName(CORE_PROPERTIES_ECMA376_NS, "link"), prsEmbed1.getId());
|
||||||
} finally {
|
|
||||||
cur.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTSlide xslide = slide1.getXmlObject();
|
CTSlide xslide = slide1.getXmlObject();
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeType;
|
||||||
*/
|
*/
|
||||||
class TestXSLFExamples {
|
class TestXSLFExamples {
|
||||||
@Test
|
@Test
|
||||||
void LinkVideoToPptx() throws IOException, URISyntaxException {
|
void linkVideoToPptx() throws IOException, URISyntaxException {
|
||||||
String videoFileName = "file_example_MP4_640_3MG.mp4";
|
String videoFileName = "file_example_MP4_640_3MG.mp4";
|
||||||
File previewJpg = POIDataSamples.getDocumentInstance().getFile("abstract1.jpg");
|
File previewJpg = POIDataSamples.getDocumentInstance().getFile("abstract1.jpg");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue