[bug-61515] fix xlsf issue with relationships [from Alain Bearez] This closes #70

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-09-13 23:10:44 +00:00
parent 0aaff6b21d
commit e726dd68de
3 changed files with 128 additions and 88 deletions

View File

@ -251,6 +251,7 @@ implements SlideShow<XSLFShape,XSLFTextParagraph> {
slideId.setId2(rp.getRelationship().getId());
layout.copyLayout(slide);
slide.getPackagePart().clearRelationships();
slide.addRelation(null, XSLFRelation.SLIDE_LAYOUT, layout);
_slides.add(slide);

View File

@ -16,6 +16,27 @@
==================================================================== */
package org.apache.poi.xslf;
import static org.apache.poi.POITestCase.assertContains;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import javax.imageio.ImageIO;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLDocumentPart.RelationPart;
@ -29,28 +50,28 @@ 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.*;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFAutoShape;
import org.apache.poi.xslf.usermodel.XSLFGroupShape;
import org.apache.poi.xslf.usermodel.XSLFHyperlink;
import org.apache.poi.xslf.usermodel.XSLFNotes;
import org.apache.poi.xslf.usermodel.XSLFPictureData;
import org.apache.poi.xslf.usermodel.XSLFPictureShape;
import org.apache.poi.xslf.usermodel.XSLFRelation;
import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
import org.apache.poi.xslf.usermodel.XSLFTable;
import org.apache.poi.xslf.usermodel.XSLFTableCell;
import org.apache.poi.xslf.usermodel.XSLFTableRow;
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.poi.xslf.usermodel.XSLFTextRun;
import org.junit.Ignore;
import org.junit.Test;
import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import static org.apache.poi.POITestCase.assertContains;
import static org.junit.Assert.*;
public class TestXSLFBugs {
private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@ -626,9 +647,27 @@ public class TestXSLFBugs {
}
@Test
public void test60042() {
public void test60042() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("60042.pptx");
ppt.removeSlide(0);
ppt.createSlide();
ppt.close();
}
@Test
public void test61515() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("61515.pptx");
ppt.removeSlide(0);
assertEquals(1, ppt.createSlide().getRelations().size());
try {
XMLSlideShow saved = XSLFTestDataSamples.writeOutAndReadBack(ppt);
assertEquals(1, saved.getSlides().size());
XSLFSlide slide = saved.getSlides().get(0);
assertEquals(1, slide.getRelations().size());
saved.close();
} catch (IOException e) {
fail("Could not read back saved presentation.");
}
ppt.close();
}
}

Binary file not shown.