mirror of https://github.com/apache/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
This commit is contained in:
parent
fcb41adacd
commit
6d6520a8c4
|
@ -16,11 +16,17 @@
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.xslf;
|
package org.apache.poi.xslf;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.poi.POIXMLDocumentPart;
|
||||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
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.XSLFSlide;
|
||||||
|
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
|
||||||
|
|
||||||
public class TestXSLFBugs extends TestCase {
|
public class TestXSLFBugs extends TestCase {
|
||||||
|
|
||||||
|
@ -61,6 +67,43 @@ public class TestXSLFBugs extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testTIKA705() {
|
public void testTIKA705() {
|
||||||
XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("with_japanese.pptx");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue