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:
PJ Fanning 2022-07-20 10:56:16 +00:00
parent 48e9d6a6d5
commit 369681f7f9
3 changed files with 4 additions and 9 deletions

View File

@ -165,16 +165,14 @@ public class AddVideoToPptx {
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
XmlCursor cur = ext.newCursor();
try {
try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
cur.beginElement(new QName(p14Ns, "trim", "p14"));
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
} finally {
cur.dispose();
}
}

View File

@ -84,14 +84,11 @@ public final class LinkVideoToPptx {
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
XmlCursor cur = ext.newCursor();
try {
try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(CORE_PROPERTIES_ECMA376_NS, "link"), prsEmbed1.getId());
} finally {
cur.dispose();
}
CTSlide xslide = slide1.getXmlObject();

View File

@ -55,7 +55,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeType;
*/
class TestXSLFExamples {
@Test
void LinkVideoToPptx() throws IOException, URISyntaxException {
void linkVideoToPptx() throws IOException, URISyntaxException {
String videoFileName = "file_example_MP4_640_3MG.mp4";
File previewJpg = POIDataSamples.getDocumentInstance().getFile("abstract1.jpg");