aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-12-26 00:08:19 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-12-26 00:08:19 +0000
commitd121353f612c6efbcf156e166158f1d403e8697e (patch)
tree078baea3d2ad8cb33ae4752e677aa8887372389f /src/examples
parentbe1afe5ff586cfc01c68ca6dc58e84f951aca2ef (diff)
downloadpoi-d121353f612c6efbcf156e166158f1d403e8697e.tar.gz
poi-d121353f612c6efbcf156e166158f1d403e8697e.zip
Sonar fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/examples/xslf/LinkVideoToPptx.java121
1 files changed, 62 insertions, 59 deletions
diff --git a/src/examples/src/org/apache/poi/examples/xslf/LinkVideoToPptx.java b/src/examples/src/org/apache/poi/examples/xslf/LinkVideoToPptx.java
index d2988478d2..9fcf312011 100644
--- a/src/examples/src/org/apache/poi/examples/xslf/LinkVideoToPptx.java
+++ b/src/examples/src/org/apache/poi/examples/xslf/LinkVideoToPptx.java
@@ -52,66 +52,69 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeFillType
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeRestartType;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeType;
-public class LinkVideoToPptx {
- public static void main(String[] args) throws IOException, URISyntaxException {
- XMLSlideShow pptx = new XMLSlideShow();
-
- String videoFileName = "file_example_MP4_640_3MG.mp4";
- XSLFSlide slide1 = pptx.createSlide();
-
- PackagePart pp = slide1.getPackagePart();
- URI mp4uri = new URI("./"+videoFileName);
- PackageRelationship prsEmbed1 = pp.addRelationship(mp4uri, TargetMode.EXTERNAL, "http://schemas.microsoft.com/office/2007/relationships/media");
- PackageRelationship prsExec1 = pp.addRelationship(mp4uri, TargetMode.EXTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
-
-
- File previewJpg = new File("preview.jpg");
- XSLFPictureData snap = pptx.addPicture(previewJpg, PictureData.PictureType.JPEG);
- XSLFPictureShape pic1 = slide1.createPicture(snap);
- pic1.setAnchor(new Rectangle(100, 100, 500, 400));
-
- CTPicture xpic1 = (CTPicture)pic1.getXmlObject();
- CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
- link1.setId("");
- link1.setAction("ppaction://media");
-
-
- CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
- nvPr.addNewVideoFile().setLink(prsExec1.getId());
- CTExtension ext = nvPr.addNewExtLst().addNewExt();
- ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
-
- String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
- 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());
- cur.dispose();
-
-
- CTSlide xslide = slide1.getXmlObject();
- CTTimeNodeList ctnl;
- if (!xslide.isSetTiming()) {
- CTTLCommonTimeNodeData ctn = xslide.addNewTiming().addNewTnLst().addNewPar().addNewCTn();
- ctn.setDur(STTLTimeIndefinite.INDEFINITE);
- ctn.setRestart(STTLTimeNodeRestartType.NEVER);
- ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
- ctnl = ctn.addNewChildTnLst();
- } else {
- ctnl = xslide.getTiming().getTnLst().getParArray(0).getCTn().getChildTnLst();
- }
- CTTLCommonMediaNodeData cmedia = ctnl.addNewVideo().addNewCMediaNode();
- cmedia.setVol(80000);
- CTTLCommonTimeNodeData ctn = cmedia.addNewCTn();
- ctn.setFill(STTLTimeNodeFillType.HOLD);
- ctn.setDisplay(false);
- ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
- cmedia.addNewTgtEl().addNewSpTgt().setSpid(pic1.getShapeId());
+public final class LinkVideoToPptx {
+ private LinkVideoToPptx() {}
-
- try (FileOutputStream fos = new FileOutputStream("mp4test/mp4test-poi.pptx")) {
- pptx.write(fos);
+ public static void main(String[] args) throws IOException, URISyntaxException {
+ try (XMLSlideShow pptx = new XMLSlideShow()) {
+
+ String videoFileName = "file_example_MP4_640_3MG.mp4";
+ XSLFSlide slide1 = pptx.createSlide();
+
+ PackagePart pp = slide1.getPackagePart();
+ URI mp4uri = new URI("./" + videoFileName);
+ PackageRelationship prsEmbed1 = pp.addRelationship(mp4uri, TargetMode.EXTERNAL, "http://schemas.microsoft.com/office/2007/relationships/media");
+ PackageRelationship prsExec1 = pp.addRelationship(mp4uri, TargetMode.EXTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
+
+
+ File previewJpg = new File("preview.jpg");
+ XSLFPictureData snap = pptx.addPicture(previewJpg, PictureData.PictureType.JPEG);
+ XSLFPictureShape pic1 = slide1.createPicture(snap);
+ pic1.setAnchor(new Rectangle(100, 100, 500, 400));
+
+ CTPicture xpic1 = (CTPicture) pic1.getXmlObject();
+ CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
+ link1.setId("");
+ link1.setAction("ppaction://media");
+
+
+ CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
+ nvPr.addNewVideoFile().setLink(prsExec1.getId());
+ CTExtension ext = nvPr.addNewExtLst().addNewExt();
+ ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
+
+ String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
+ 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());
+ cur.dispose();
+
+
+ CTSlide xslide = slide1.getXmlObject();
+ CTTimeNodeList ctnl;
+ if (!xslide.isSetTiming()) {
+ CTTLCommonTimeNodeData ctn = xslide.addNewTiming().addNewTnLst().addNewPar().addNewCTn();
+ ctn.setDur(STTLTimeIndefinite.INDEFINITE);
+ ctn.setRestart(STTLTimeNodeRestartType.NEVER);
+ ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
+ ctnl = ctn.addNewChildTnLst();
+ } else {
+ ctnl = xslide.getTiming().getTnLst().getParArray(0).getCTn().getChildTnLst();
+ }
+ CTTLCommonMediaNodeData cmedia = ctnl.addNewVideo().addNewCMediaNode();
+ cmedia.setVol(80000);
+ CTTLCommonTimeNodeData ctn = cmedia.addNewCTn();
+ ctn.setFill(STTLTimeNodeFillType.HOLD);
+ ctn.setDisplay(false);
+ ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
+ cmedia.addNewTgtEl().addNewSpTgt().setSpid(pic1.getShapeId());
+
+
+ try (FileOutputStream fos = new FileOutputStream("mp4test/mp4test-poi.pptx")) {
+ pptx.write(fos);
+ }
}
}
}