From commits-return-11533-archive-asf-public=cust-asf.ponee.io@poi.apache.org Sat Aug 11 03:55:43 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 04212180630 for ; Sat, 11 Aug 2018 03:55:41 +0200 (CEST) Received: (qmail 26723 invoked by uid 500); 11 Aug 2018 01:55:41 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 26714 invoked by uid 99); 11 Aug 2018 01:55:40 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Aug 2018 01:55:40 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 3EB073A0116 for ; Sat, 11 Aug 2018 01:55:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1837839 - in /poi: site/src/documentation/content/xdocs/ trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ trunk/src/ooxml/testcases/org/apache/poi/xslf/ Date: Sat, 11 Aug 2018 01:55:39 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180811015540.3EB073A0116@svn01-us-west.apache.org> Author: kiwiwings Date: Sat Aug 11 01:55:39 2018 New Revision: 1837839 URL: http://svn.apache.org/viewvc?rev=1837839&view=rev Log: #62587 - repeated call to XSLFSheet.removeShape leads to java.lang.IllegalArgumentException: partName Modified: poi/site/src/documentation/content/xdocs/changes.xml poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Modified: poi/site/src/documentation/content/xdocs/changes.xml URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/changes.xml?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/site/src/documentation/content/xdocs/changes.xml (original) +++ poi/site/src/documentation/content/xdocs/changes.xml Sat Aug 11 01:55:39 2018 @@ -90,6 +90,7 @@ Removed support for Java 6 and 7 making Java 8 the minimum version supported + repeated call to XSLFSheet.removeShape leads to java.lang.IllegalArgumentException: partName Don't try to parse embedded package relationships Work on providing an updated version of XMLBeans Document last printed in the year 27321 Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Sat Aug 11 01:55:39 2018 @@ -25,9 +25,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.openxml4j.opc.TargetMode; +import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart; import org.apache.poi.sl.draw.DrawPictureShape; import org.apache.poi.sl.usermodel.GroupShape; import org.apache.poi.sl.usermodel.PictureData; @@ -74,7 +72,7 @@ implements XSLFShapeContainer, GroupShap return _grpSpPr; } - protected CTGroupTransform2D getSafeXfrm() { + private CTGroupTransform2D getSafeXfrm() { CTGroupTransform2D xfrm = getXfrm(); return (xfrm == null ? getGrpSpPr().addNewXfrm() : xfrm); } @@ -267,13 +265,9 @@ implements XSLFShapeContainer, GroupShap if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } - XSLFPictureData xPictureData = (XSLFPictureData)pictureData; - PackagePart pic = xPictureData.getPackagePart(); + RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); - PackageRelationship rel = getSheet().getPackagePart().addRelationship( - pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation()); - - XSLFPictureShape sh = getDrawing().createPicture(rel.getId()); + XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); _shapes.add(sh); sh.setParent(this); @@ -285,13 +279,10 @@ implements XSLFShapeContainer, GroupShap if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } - XSLFPictureData xPictureData = (XSLFPictureData)pictureData; - PackagePart pic = xPictureData.getPackagePart(); - PackageRelationship rel = getSheet().getPackagePart().addRelationship( - pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation()); - - XSLFObjectShape sh = getDrawing().createOleShape(rel.getId()); + RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); + + XSLFObjectShape sh = getDrawing().createOleShape(rp.getRelationship().getId()); CTOleObject oleObj = sh.getCTOleObject(); Dimension dim = pictureData.getImageDimension(); oleObj.setImgW(Units.toEMU(dim.getWidth())); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java Sat Aug 11 01:55:39 2018 @@ -19,10 +19,9 @@ package org.apache.poi.xslf.usermodel; import java.net.URI; import org.apache.poi.common.usermodel.HyperlinkType; +import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart; import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackagePartName; import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.sl.usermodel.Hyperlink; import org.apache.poi.sl.usermodel.Slide; import org.apache.poi.util.Internal; @@ -30,8 +29,8 @@ import org.apache.poi.util.Removal; import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink; public class XSLFHyperlink implements Hyperlink { - final XSLFSheet _sheet; - final CTHyperlink _link; + private final XSLFSheet _sheet; + private final CTHyperlink _link; XSLFHyperlink(CTHyperlink link, XSLFSheet sheet){ _sheet = sheet; @@ -128,14 +127,12 @@ public class XSLFHyperlink implements Hy @Override public void linkToSlide(Slide slide) { - PackagePart thisPP = _sheet.getPackagePart(); - PackagePartName otherPPN = ((XSLFSheet)slide).getPackagePart().getPartName(); if (_link.isSetId() && !_link.getId().isEmpty()) { - thisPP.removeRelationship(_link.getId()); + _sheet.getPackagePart().removeRelationship(_link.getId()); } - PackageRelationship rel = - thisPP.addRelationship(otherPPN, TargetMode.INTERNAL, XSLFRelation.SLIDE.getRelation()); - _link.setId(rel.getId()); + + RelationPart rp = _sheet.addRelation(null, XSLFRelation.SLIDE, (XSLFSheet) slide); + _link.setId(rp.getRelationship().getId()); _link.setAction("ppaction://hlinksldjump"); } Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java Sat Aug 11 01:55:39 2018 @@ -24,7 +24,6 @@ import java.net.URI; import javax.xml.namespace.QName; -import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.PictureShape; @@ -95,10 +94,7 @@ public class XSLFPictureShape extends XS * (image lives outside)? */ public boolean isExternalLinkedPicture() { - if (getBlipId() == null && getBlipLink() != null) { - return true; - } - return false; + return getBlipId() == null && getBlipLink() != null; } /** @@ -108,19 +104,10 @@ public class XSLFPictureShape extends XS public XSLFPictureData getPictureData() { if(_data == null){ String blipId = getBlipId(); - if (blipId == null) return null; - - PackagePart p = getSheet().getPackagePart(); - PackageRelationship rel = p.getRelationship(blipId); - if (rel != null) { - try { - PackagePart imgPart = p.getRelatedPart(rel); - _data = new XSLFPictureData(imgPart); - } - catch (Exception e) { - throw new POIXMLException(e); - } + if (blipId == null) { + return null; } + _data = (XSLFPictureData)getSheet().getRelationById(blipId); } return _data; } @@ -181,12 +168,14 @@ public class XSLFPictureShape extends XS return getBlipFill().getBlip(); } + @SuppressWarnings("WeakerAccess") protected String getBlipLink(){ String link = getBlip().getLink(); if (link.isEmpty()) return null; return link; } - + + @SuppressWarnings("WeakerAccess") protected String getBlipId(){ String id = getBlip().getEmbed(); if (id.isEmpty()) return null; @@ -210,7 +199,7 @@ public class XSLFPictureShape extends XS return; } - String relId = getSheet().importBlip(blipId, p.getSheet().getPackagePart()); + String relId = getSheet().importBlip(blipId, p.getSheet()); CTPicture ct = (CTPicture)getXmlObject(); CTBlip blip = getBlipFill().getBlip(); @@ -224,13 +213,14 @@ public class XSLFPictureShape extends XS if(blip.isSetExtLst()) { CTOfficeArtExtensionList extLst = blip.getExtLst(); + //noinspection deprecation for(CTOfficeArtExtension ext : extLst.getExtArray()){ String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer"; XmlObject[] obj = ext.selectPath(xpath); if(obj != null && obj.length == 1){ XmlCursor c = obj[0].newCursor(); String id = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"));//selectPath("declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' $this//[@embed]"); - String newId = getSheet().importBlip(id, p.getSheet().getPackagePart()); + String newId = getSheet().importBlip(id, p.getSheet()); c.setAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"), newId); c.dispose(); } Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Sat Aug 11 01:55:39 2018 @@ -18,7 +18,6 @@ package org.apache.poi.xslf.usermodel; import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS; -import javax.xml.namespace.QName; import java.awt.Dimension; import java.awt.Graphics2D; import java.io.IOException; @@ -32,9 +31,10 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import javax.xml.namespace.QName; + import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.ooxml.POIXMLException; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageNamespaces; import org.apache.poi.openxml4j.opc.PackagePart; @@ -82,14 +82,14 @@ implements XSLFShapeContainer, Sheet buildShapes(CTGroupShape spTree, XSLFShapeContainer parent){ final XSLFSheet sheet = (parent instanceof XSLFSheet) ? (XSLFSheet)parent : ((XSLFShape)parent).getSheet(); @@ -261,10 +265,8 @@ implements XSLFShapeContainer, Sheetthis. */ + @SuppressWarnings("unused") public XSLFSheet appendContent(XSLFSheet src){ int numShapes = getShapes().size(); CTGroupShape spTree = getSpTree(); @@ -523,6 +524,7 @@ implements XSLFShapeContainer, Sheetsheet displays the specified shape. - * - * Subclasses can override it and skip certain shapes from drawings, - * for instance, slide masters and layouts don't display placeholders - */ - protected boolean canDraw(XSLFShape shape){ - return true; + return _placeholders.toArray(new XSLFTextShape[0]); } /** @@ -650,39 +644,35 @@ implements XSLFShapeContainer, Sheetnull * if outline is turned off */ + @SuppressWarnings("WeakerAccess") public Color getLineColor() { PaintStyle ps = getLinePaint(); if (ps instanceof SolidPaint) { @@ -310,6 +311,7 @@ public abstract class XSLFSimpleShape ex return null; } + @SuppressWarnings("WeakerAccess") protected PaintStyle getLinePaint() { XSLFSheet sheet = getSheet(); final XSLFTheme theme = sheet.getTheme(); @@ -377,6 +379,7 @@ public abstract class XSLFSimpleShape ex * * @param width line width in points. 0 means no line */ + @SuppressWarnings("WeakerAccess") public void setLineWidth(double width) { CTLineProperties lnPr = getLn(this, true); if (lnPr == null) { @@ -411,6 +414,7 @@ public abstract class XSLFSimpleShape ex /** * @return line width in points. 0 means no line. */ + @SuppressWarnings("WeakerAccess") public double getLineWidth() { PropertyFetcher fetcher = new PropertyFetcher() { @Override @@ -451,6 +455,7 @@ public abstract class XSLFSimpleShape ex /** * @param compound set the line compound style */ + @SuppressWarnings("WeakerAccess") public void setLineCompound(LineCompound compound) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -487,6 +492,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line compound */ + @SuppressWarnings("WeakerAccess") public LineCompound getLineCompound() { PropertyFetcher fetcher = new PropertyFetcher() { @Override @@ -531,6 +537,7 @@ public abstract class XSLFSimpleShape ex * * @param dash a preset line dashing scheme to stroke thr shape outline */ + @SuppressWarnings("WeakerAccess") public void setLineDash(LineDash dash) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -549,6 +556,7 @@ public abstract class XSLFSimpleShape ex /** * @return a preset line dashing scheme to stroke the shape outline */ + @SuppressWarnings("WeakerAccess") public LineDash getLineDash() { PropertyFetcher fetcher = new PropertyFetcher() { @@ -579,6 +587,7 @@ public abstract class XSLFSimpleShape ex * * @param cap the line end cap style */ + @SuppressWarnings("WeakerAccess") public void setLineCap(LineCap cap) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -598,6 +607,7 @@ public abstract class XSLFSimpleShape ex * * @return the line end cap style */ + @SuppressWarnings("WeakerAccess") public LineCap getLineCap() { PropertyFetcher fetcher = new PropertyFetcher() { @Override @@ -758,7 +768,7 @@ public abstract class XSLFSimpleShape ex CTBlip blip = fp.getBlipFill().getBlip(); String blipId = blip.getEmbed(); - String relId = getSheet().importBlip(blipId, s.getSheet().getPackagePart()); + String relId = getSheet().importBlip(blipId, s.getSheet()); blip.setEmbed(relId); } @@ -793,6 +803,7 @@ public abstract class XSLFSimpleShape ex * * @param style the line end docoration style */ + @SuppressWarnings("WeakerAccess") public void setLineHeadDecoration(DecorationShape style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -811,6 +822,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration shape */ + @SuppressWarnings("WeakerAccess") public DecorationShape getLineHeadDecoration() { CTLineProperties ln = getLn(this, false); DecorationShape ds = DecorationShape.NONE; @@ -825,6 +837,7 @@ public abstract class XSLFSimpleShape ex * * @param style the decoration width */ + @SuppressWarnings("WeakerAccess") public void setLineHeadWidth(DecorationSize style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -843,6 +856,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration width */ + @SuppressWarnings("WeakerAccess") public DecorationSize getLineHeadWidth() { CTLineProperties ln = getLn(this, false); DecorationSize ds = DecorationSize.MEDIUM; @@ -855,6 +869,7 @@ public abstract class XSLFSimpleShape ex /** * Specifies the line end width in relation to the line width. */ + @SuppressWarnings("WeakerAccess") public void setLineHeadLength(DecorationSize style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -874,6 +889,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration length */ + @SuppressWarnings("WeakerAccess") public DecorationSize getLineHeadLength() { CTLineProperties ln = getLn(this, false); @@ -887,6 +903,7 @@ public abstract class XSLFSimpleShape ex /** * Specifies the line end decoration, such as a triangle or arrowhead. */ + @SuppressWarnings("WeakerAccess") public void setLineTailDecoration(DecorationShape style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -906,6 +923,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration shape */ + @SuppressWarnings("WeakerAccess") public DecorationShape getLineTailDecoration() { CTLineProperties ln = getLn(this, false); @@ -919,6 +937,7 @@ public abstract class XSLFSimpleShape ex /** * specifies decorations which can be added to the tail of a line. */ + @SuppressWarnings("WeakerAccess") public void setLineTailWidth(DecorationSize style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -938,6 +957,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration width */ + @SuppressWarnings("WeakerAccess") public DecorationSize getLineTailWidth() { CTLineProperties ln = getLn(this, false); DecorationSize ds = DecorationSize.MEDIUM; @@ -950,6 +970,7 @@ public abstract class XSLFSimpleShape ex /** * Specifies the line end width in relation to the line width. */ + @SuppressWarnings("WeakerAccess") public void setLineTailLength(DecorationSize style) { CTLineProperties ln = getLn(this, true); if (ln == null) { @@ -969,6 +990,7 @@ public abstract class XSLFSimpleShape ex /** * @return the line end decoration length */ + @SuppressWarnings("WeakerAccess") public DecorationSize getLineTailLength() { CTLineProperties ln = getLn(this, false); @@ -984,6 +1006,7 @@ public abstract class XSLFSimpleShape ex XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties()); if (gp != null && gp.isSetPrstGeom() && gp.getPrstGeom().isSetAvLst()) { + //noinspection deprecation for (CTGeomGuide g : gp.getPrstGeom().getAvLst().getGdArray()) { if (g.getName().equals(name)) { return new Guide(g.getName(), g.getFmla()); @@ -1036,12 +1059,7 @@ public abstract class XSLFSimpleShape ex */ @Override public FillStyle getFillStyle() { - return new FillStyle() { - @Override - public PaintStyle getPaint() { - return XSLFSimpleShape.this.getFillPaint(); - } - }; + return XSLFSimpleShape.this::getFillPaint; } @Override Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1837839&r1=1837838&r2=1837839&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Sat Aug 11 01:55:39 2018 @@ -128,10 +128,12 @@ implements Slide rels = sl.getRelationParts(); + assertEquals(2, rels.size()); + RelationPart rel0 = rels.get(0); + assertEquals("rId1", rel0.getRelationship().getId()); + assertEquals(XSLFRelation.SLIDE_LAYOUT.getRelation(), rel0.getRelationship().getRelationshipType()); + RelationPart rel1 = rels.get(1); + assertEquals("rId2", rel1.getRelationship().getId()); + assertEquals(XSLFRelation.IMAGES.getRelation(), rel1.getRelationship().getRelationshipType()); + } + } + } + + + @Test public void bug60499() throws IOException, InvalidFormatException { InputStream is = slTests.openResourceAsStream("bug60499.pptx"); byte buf[] = IOUtils.toByteArray(is); @@ -314,8 +368,8 @@ public class TestXSLFBugs { ss.close(); } - protected String getSlideText(XMLSlideShow ppt, XSLFSlide slide) throws IOException { - try (SlideShowExtractor extr = new SlideShowExtractor(ppt)) { + private String getSlideText(XMLSlideShow ppt, XSLFSlide slide) throws IOException { + try (SlideShowExtractor extr = new SlideShowExtractor<>(ppt)) { // do not auto-close the slideshow extr.setFilesystem(null); extr.setSlidesByDefault(true); @@ -369,7 +423,12 @@ public class TestXSLFBugs { assertEquals(1, slide.getShapes().size()); assertEquals(1, slide.getRelations().size()); - assertRelationEquals(XSLFRelation.SLIDE_LAYOUT, slide.getRelations().get(0)); + + final XSLFRelation expected = XSLFRelation.SLIDE_LAYOUT; + final POIXMLDocumentPart relation = slide.getRelations().get(0); + + assertEquals(expected.getContentType(), relation.getPackagePart().getContentType()); + assertEquals(expected.getFileName(expected.getFileNameIndex(relation)), relation.getPackagePart().getPartName().getName()); // Some dummy pictures byte[][] pics = new byte[15][3]; @@ -472,11 +531,6 @@ public class TestXSLFBugs { } } - private void assertRelationEquals(XSLFRelation expected, POIXMLDocumentPart relation) { - assertEquals(expected.getContentType(), relation.getPackagePart().getContentType()); - assertEquals(expected.getFileName(expected.getFileNameIndex(relation)), relation.getPackagePart().getPartName().getName()); - } - @Test public void bug58205() throws IOException { XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("themes.pptx"); @@ -726,25 +780,19 @@ public class TestXSLFBugs { @Test public void testAptia() throws IOException { - XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("aptia.pptx"); - try { - XMLSlideShow saved = XSLFTestDataSamples.writeOutAndReadBack(ppt); - } catch (IOException e) { - fail("Could not read back saved presentation."); + try (XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("aptia.pptx"); + XMLSlideShow saved = XSLFTestDataSamples.writeOutAndReadBack(ppt)) { + assertEquals(ppt.getSlides().size(), saved.getSlides().size()); } - ppt.close(); } @Ignore @Test public void testDivinoRevelado() throws IOException { - XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("Divino_Revelado.pptx"); - try { - XMLSlideShow saved = XSLFTestDataSamples.writeOutAndReadBack(ppt); - } catch (IOException e) { - fail("Could not read back saved presentation."); + try (XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("Divino_Revelado.pptx"); + XMLSlideShow saved = XSLFTestDataSamples.writeOutAndReadBack(ppt)){ + assertEquals(ppt.getSlides().size(), saved.getSlides().size()); } - ppt.close(); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org