mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
d8e2b007e3
commit
d5e4e462fc
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue