FileInputStream is = new FileInputStream(new File(cwd, "WithLinks.ppt"));
SlideShow ppt = new SlideShow(is);
is.close();
TextRun[] run;
Slide slide;
slide = ppt.getSlides()[0];
run = slide.getTextRuns();
for (int i = 0; i < run.length; i++) {
String text = run[i].getText();
if (text.equals(
"This page has two links:\n" +
"http://jakarta.apache.org/poi/\n" +
"\n" +
"http://slashdot.org/\n" +
"\n" +
"In addition, its notes has one link")){
Hyperlink[] links = run[i].getHyperlinks();
assertNotNull(links);
assertEquals(2, links.length);
assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());
assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());
assertEquals("http://jakarta.apache.org/poi/", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
assertEquals("http://slashdot.org/", links[1].getTitle());
assertEquals("http://slashdot.org/", links[1].getAddress());
assertEquals("http://slashdot.org/", text.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));
}
}
slide = ppt.getSlides()[1];
run = slide.getTextRuns();
for (int i = 0; i < run.length; i++) {
String text = run[i].getText();
if (text.equals(
"I have the one link:\n" +
"Jakarta HSSF")){
Hyperlink[] links = run[i].getHyperlinks();
assertNotNull(links);
assertEquals(1, links.length);
assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());
assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());
assertEquals("Jakarta HSSF", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
}
}