diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java index c328849e08..b5a13f875b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java @@ -101,6 +101,11 @@ public interface PackageRelationshipTypes { */ String IMAGE_PART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"; + /** + * hdphoto type. + */ + String HDPHOTO_PART = "http://schemas.microsoft.com/office/2007/relationships/hdphoto"; + /** * Hyperlink type. */ diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java index 5139e6278c..19d0c3d10f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFRelation.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; +import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.HDPHOTO_PART; import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.IMAGE_PART; import java.util.HashMap; @@ -221,7 +222,12 @@ public final class XSLFRelation extends POIXMLRelation { "/ppt/media/image#.wdp", XSLFPictureData::new, XSLFPictureData::new ); - + public static final XSLFRelation HDPHOTO_WDP = new XSLFRelation( + PictureType.WDP.contentType, + HDPHOTO_PART, + "/ppt/media/hdphoto#.wdp", + XSLFPictureData::new, XSLFPictureData::new + ); public static final XSLFRelation IMAGE_SVG = new XSLFRelation( PictureType.SVG.contentType, IMAGE_PART, diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index 3c367dd9bb..47be24663a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -648,7 +648,13 @@ implements XSLFShapeContainer, Sheet { * @return ID of the created relationship */ String importBlip(String blipId, POIXMLDocumentPart parent) { - final XSLFPictureData parData = parent.getRelationPartById(blipId).getDocumentPart(); + final POIXMLDocumentPart docPart = parent.getRelationPartById(blipId).getDocumentPart(); + XSLFPictureData parData; + if (docPart instanceof XSLFPictureData) { + parData = (XSLFPictureData)docPart; + } else { + throw new RuntimeException("cannot import blip " + blipId + " - document part is not XSLFPictureData type"); + } final XSLFPictureData pictureData; if (getPackagePart().getPackage() == parent.getPackagePart().getPackage()) { // handle ref counter correct, if the parent document is the same as this diff --git a/poi-ooxml/src/test/java/org/apache/poi/xslf/TestXSLFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xslf/TestXSLFBugs.java index 5b239a8ad6..a87738d086 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xslf/TestXSLFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xslf/TestXSLFBugs.java @@ -32,9 +32,7 @@ import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.awt.Color; import java.awt.geom.Rectangle2D; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; import java.net.URI; import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator.Attribute; @@ -49,6 +47,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; import org.apache.poi.POIDataSamples; import org.apache.poi.common.usermodel.HyperlinkType; import org.apache.poi.ooxml.POIXMLDocumentPart; @@ -75,7 +74,6 @@ import org.apache.poi.sl.usermodel.SlideShowFactory; import org.apache.poi.sl.usermodel.TextRun; import org.apache.poi.sl.usermodel.TextShape; import org.apache.poi.sl.usermodel.VerticalAlignment; -import org.apache.poi.util.IOUtils; import org.apache.commons.io.output.NullPrintStream; import org.apache.poi.xslf.usermodel.*; import org.apache.poi.xslf.util.DummyGraphics2d; @@ -1044,4 +1042,21 @@ class TestXSLFBugs { assertEquals(TextRun.TextCap.ALL, act); } } + + @Test + public void bug65523() throws IOException { + try (XMLSlideShow sourcePresentation = openSampleDocument("bug65523.pptx")) { + XMLSlideShow targetPresentation = new XMLSlideShow(); + XSLFSlide targetPresentationSlide = targetPresentation.createSlide(); + + XSLFSlide sourceSlide = sourcePresentation.getSlides().get(0); + + targetPresentationSlide.getSlideMaster().importContent(sourceSlide.getSlideMaster()); + targetPresentationSlide.getSlideLayout().importContent(sourceSlide.getSlideLayout()); + + targetPresentationSlide.importContent(sourceSlide); + + targetPresentation.write(new UnsynchronizedByteArrayOutputStream()); + } + } } diff --git a/test-data/slideshow/bug65523.pptx b/test-data/slideshow/bug65523.pptx new file mode 100644 index 0000000000..3d737d7b63 Binary files /dev/null and b/test-data/slideshow/bug65523.pptx differ