]> source.dussan.org Git - poi.git/commitdiff
Test relating to TIKA-705 - XSLF internal hyperlinks
authorNick Burch <nick@apache.org>
Mon, 19 Sep 2011 15:38:59 +0000 (15:38 +0000)
committerNick Burch <nick@apache.org>
Mon, 19 Sep 2011 15:38:59 +0000 (15:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1172670 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java

index ba49341a2e55ac9f7247482b68b43247a03af67a..455ceae9095f6266182d510f7e45557d0c433c75 100644 (file)
 ==================================================================== */
 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<POIXMLDocumentPart> 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);
+             }
+          }
+       }
     }
 }