diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-09-14 14:56:01 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-09-14 14:56:01 +0000 |
commit | 4afcb281cef11d7943e5c4ca4324098f7eac9b42 (patch) | |
tree | 611694480694a72ddc915e587734612587f69bd6 /poi-ooxml/src | |
parent | 3a6b91dd1fb7d0255711cca771a38b3c31c850e7 (diff) | |
download | poi-4afcb281cef11d7943e5c4ca4324098f7eac9b42.tar.gz poi-4afcb281cef11d7943e5c4ca4324098f7eac9b42.zip |
[bug-67005] XSLFPictureShape - audio-related methods. Thanks to Max
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912315 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java | 23 | ||||
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java | 20 |
2 files changed, 42 insertions, 1 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java index b7e2bb5496..3e0f6bccc3 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java @@ -469,6 +469,27 @@ public class XSLFPictureShape extends XSLFSimpleShape return null; } + private CTApplicationNonVisualDrawingProps getCTApplicationNonVisualDrawing() { + CTPictureNonVisual nvPicPr = getCTPictureNonVisual(); + return nvPicPr == null ? null : nvPicPr.getNvPr(); + } + + /** + * @return boolean; true if the picture is an audio + */ + public boolean isAudioFile() { + CTApplicationNonVisualDrawingProps nvPr = getCTApplicationNonVisualDrawing(); + return nvPr != null && nvPr.isSetAudioFile(); + } + + /** + * @return the link ID for the audio file + */ + public String getAudioFileLink() { + CTApplicationNonVisualDrawingProps nvPr = getCTApplicationNonVisualDrawing(); + return nvPr != null && nvPr.isSetAudioFile() ? nvPr.getAudioFile().getLink() : null; + } + private CTPictureNonVisual getCTPictureNonVisual() { XmlObject xmlObject = getXmlObject(); if (xmlObject instanceof CTPicture) { @@ -477,4 +498,4 @@ public class XSLFPictureShape extends XSLFSimpleShape } return null; } -}
\ No newline at end of file +} diff --git a/poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java b/poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java index 65d18e9043..48c9161501 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java @@ -359,4 +359,24 @@ class TestXSLFPictureShape { assertEquals(ps.getVideoFileLink(), "rId2"); } } + + @Test + void testIsSetAudioFile() throws IOException { + try (XMLSlideShow ppt = openSampleDocument("EmbeddedAudio.pptx")) { + XSLFSlide slide = ppt.getSlides().get(0); + XSLFPictureShape ps = (XSLFPictureShape) slide.getShapes().get(0); + + assertTrue(ps.isAudioFile()); + } + } + + @Test + void testGetAudioLink() throws IOException { + try (XMLSlideShow ppt = openSampleDocument("EmbeddedAudio.pptx")) { + XSLFSlide slide = ppt.getSlides().get(0); + XSLFPictureShape ps = (XSLFPictureShape) slide.getShapes().get(0); + + assertEquals(ps.getAudioFileLink(), "rId2"); + } + } }
\ No newline at end of file |