==================================================================== */
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 {
*/
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);
+ }
+ }
+ }
}
}