Browse Source

[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
tags/REL_5_2_4
PJ Fanning 8 months ago
parent
commit
4afcb281ce

+ 22
- 1
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java View File

return null; 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() { private CTPictureNonVisual getCTPictureNonVisual() {
XmlObject xmlObject = getXmlObject(); XmlObject xmlObject = getXmlObject();
if (xmlObject instanceof CTPicture) { if (xmlObject instanceof CTPicture) {
} }
return null; return null;
} }
}
}

+ 20
- 0
poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java View File

assertEquals(ps.getVideoFileLink(), "rId2"); 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");
}
}
} }

+ 2
- 0
src/resources/ooxml-lite-report.clazz View File

org/openxmlformats/schemas/drawingml/x2006/main/CTPositiveFixedAngle org/openxmlformats/schemas/drawingml/x2006/main/CTPositiveFixedAngle
org/openxmlformats/schemas/drawingml/x2006/chart/impl/STAxisUnitImpl org/openxmlformats/schemas/drawingml/x2006/chart/impl/STAxisUnitImpl
org/openxmlformats/schemas/drawingml/x2006/chart/STAxisUnit org/openxmlformats/schemas/drawingml/x2006/chart/STAxisUnit
org/openxmlformats/schemas/drawingml/x2006/main/impl/CTAudioFileImpl
org/openxmlformats/schemas/drawingml/x2006/main/CTAudioFile

+ 1
- 0
src/resources/ooxml-lite-report.xsb View File

stdlblpos1cf4type stdlblpos1cf4type
staxisunit6cc7type staxisunit6cc7type
chartelement2 chartelement2
ctaudiofile1563type

BIN
test-data/slideshow/EmbeddedAudio.pptx View File


Loading…
Cancel
Save