Fix the footnote doubling, and then enable the rest of the SDT tests from Tim Allison from bug #54849

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1494379 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-06-18 23:39:31 +00:00
parent 28899342eb
commit 7117fe26ad
2 changed files with 1 additions and 10 deletions

View File

@ -237,11 +237,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) { if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
this.footnotes = (XWPFFootnotes)p; this.footnotes = (XWPFFootnotes)p;
this.footnotes.onDocumentRead(); this.footnotes.onDocumentRead();
// Warning - this apparently doubles footnotes - see bug #????
FootnotesDocument footnotesDocument = FootnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteList()) {
footnotes.addFootnote(ctFtnEdn);
}
} else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){ } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());

View File

@ -43,8 +43,7 @@ public final class TestXWPFSDT extends TestCase {
break; break;
} }
} }
// TODO Fix footnotes issues then enable assertEquals("controls size", 12, sdts.size());
// assertEquals("controls size", 12, sdts.size());
assertEquals("tag", "MyTag", tag); assertEquals("tag", "MyTag", tag);
assertEquals("title", "MyTitle", title); assertEquals("title", "MyTitle", title);
@ -70,8 +69,6 @@ public final class TestXWPFSDT extends TestCase {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx"); XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
List<XWPFSDT> sdts = extractAllSDTs(doc); List<XWPFSDT> sdts = extractAllSDTs(doc);
// TODO Fix footnotes issue
/*
assertEquals("number of sdts", contents.length, sdts.size()); assertEquals("number of sdts", contents.length, sdts.size());
for (int i = 0; i < sdts.size(); i++){//contents.length; i++){ for (int i = 0; i < sdts.size(); i++){//contents.length; i++){
@ -79,7 +76,6 @@ public final class TestXWPFSDT extends TestCase {
assertEquals(i+ ": " + contents[i], contents[i], sdt.getContent().toString()); assertEquals(i+ ": " + contents[i], contents[i], sdt.getContent().toString());
} }
*/
} }
public void testFailureToGetSDTAsCell() throws Exception{ public void testFailureToGetSDTAsCell() throws Exception{