diff options
-rw-r--r-- | src/integrationtest/org/apache/poi/TestAllFiles.java | 1 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java | 25 | ||||
-rw-r--r-- | test-data/slideshow/bug59273.potx | bin | 0 -> 617839 bytes |
4 files changed, 27 insertions, 5 deletions
diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index dcce6269f1..3974c06319 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -91,6 +91,7 @@ public class TestAllFiles { HANDLERS.put(".ppsm", new XSLFFileHandler()); HANDLERS.put(".ppsx", new XSLFFileHandler()); HANDLERS.put(".thmx", new XSLFFileHandler()); + HANDLERS.put(".potx", new XSLFFileHandler()); // Outlook HANDLERS.put(".msg", new HSMFFileHandler()); diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java index 506344f93c..5220529fd3 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -1654,7 +1654,13 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { if (packagePart.getContentType().equals(oldContentType)) { PackagePartName partName = packagePart.getPartName(); contentTypeManager.addContentType(partName, newContentType); + try { + packagePart.setContentType(newContentType); + } catch (InvalidFormatException e) { + throw new OpenXML4JRuntimeException("invalid content type - "+newContentType, e); + } success = true; + this.isDirty = true; } } return success; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java index cd475fcced..7c02ba282b 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java @@ -31,10 +31,7 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.net.URI; import java.util.Collection; @@ -43,6 +40,7 @@ import javax.imageio.ImageIO; import org.apache.poi.POIDataSamples; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLDocumentPart.RelationPart; +import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.sl.draw.DrawPaint; import org.apache.poi.sl.usermodel.PaintStyle; import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; @@ -52,8 +50,6 @@ import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.sl.usermodel.ShapeType; import org.apache.poi.sl.usermodel.VerticalAlignment; import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor; -import org.apache.poi.xslf.usermodel.DrawingParagraph; -import org.apache.poi.xslf.usermodel.DrawingTextBody; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFAutoShape; import org.apache.poi.xslf.usermodel.XSLFHyperlink; @@ -541,4 +537,23 @@ public class TestXSLFBugs { newPptx.close(); srcPptx.close(); } + + @Test + public void bug59273() throws IOException { + XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("bug59273.potx"); + ppt.getPackage().replaceContentType( + XSLFRelation.PRESENTATIONML_TEMPLATE.getContentType(), + XSLFRelation.MAIN.getContentType() + ); + + XMLSlideShow rwPptx = XSLFTestDataSamples.writeOutAndReadBack(ppt); + OPCPackage pkg = rwPptx.getPackage(); + int size = pkg.getPartsByContentType(XSLFRelation.MAIN.getContentType()).size(); + assertEquals(1, size); + size = pkg.getPartsByContentType(XSLFRelation.PRESENTATIONML_TEMPLATE.getContentType()).size(); + assertEquals(0, size); + + rwPptx.close(); + ppt.close(); + } } diff --git a/test-data/slideshow/bug59273.potx b/test-data/slideshow/bug59273.potx Binary files differnew file mode 100644 index 0000000000..72815da71a --- /dev/null +++ b/test-data/slideshow/bug59273.potx |