aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-11-10 22:54:07 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-11-10 22:54:07 +0000
commitd5e4e462fc2214fc50cae52df359bab6a4f53c2b (patch)
treec5f6c371813cbf8e3c7ba369ca320d2f40515d16
parentd8e2b007e3a66363e9f67ab576bd37845a52c815 (diff)
downloadpoi-d5e4e462fc2214fc50cae52df359bab6a4f53c2b.tar.gz
poi-d5e4e462fc2214fc50cae52df359bab6a4f53c2b.zip
Bug 59273 - Unable to create pptx file by potx file using Apache POI
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1769220 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/integrationtest/org/apache/poi/TestAllFiles.java1
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java25
-rw-r--r--test-data/slideshow/bug59273.potxbin0 -> 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
new file mode 100644
index 0000000000..72815da71a
--- /dev/null
+++ b/test-data/slideshow/bug59273.potx
Binary files differ