From: Nick Burch Date: Mon, 19 Sep 2011 15:38:59 +0000 (+0000) Subject: Test relating to TIKA-705 - XSLF internal hyperlinks X-Git-Tag: REL_3_8_BETA5~161 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d6520a8c45055d5d918acaa43e0f0b9386c690b;p=poi.git Test relating to TIKA-705 - XSLF internal hyperlinks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1172670 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java index ba49341a2e..455ceae909 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java @@ -16,11 +16,17 @@ ==================================================================== */ package org.apache.poi.xslf; +import java.net.URI; +import java.util.List; + import junit.framework.TestCase; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFRelation; import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFSlideLayout; public class TestXSLFBugs extends TestCase { @@ -61,6 +67,43 @@ public class TestXSLFBugs extends TestCase { */ public void testTIKA705() { XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("with_japanese.pptx"); - // TODO Check the details including the links + + // Should have one slide + assertEquals(1, ss.getSlides().length); + XSLFSlide slide = ss.getSlides()[0]; + + // Check the relations from this + List rels = slide.getRelations(); + + // Should have 6 relations: + // 1 external hyperlink (skipped from list) + // 4 internal hyperlinks + // 1 slide layout + assertEquals(5, rels.size()); + int layouts = 0; + int hyperlinks = 0; + for(POIXMLDocumentPart p : rels) { + if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) { + hyperlinks++; + } else if(p instanceof XSLFSlideLayout) { + layouts++; + } + } + assertEquals(1, layouts); + assertEquals(4, hyperlinks); + + // Hyperlinks should all be to #_ftn1 or #ftnref1 + for(POIXMLDocumentPart p : rels) { + if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation())) { + URI target = p.getPackageRelationship().getTargetURI(); + + if(target.getFragment().equals("_ftn1") || + target.getFragment().equals("_ftnref1")) { + // Good + } else { + fail("Invalid target " + target.getFragment() + " on " + target); + } + } + } } }