<changes>
<release version="3.5-beta7" date="2009-??-??">
- <action dev="POI-DEVELOPERS" type="fix">45556 - Fixed ExtractorFactory to support .xltx and .dotx files</action>
+ <action dev="POI-DEVELOPERS" type="fix">47517 - Fixed ExtractorFactory to support .xltx and .dotx files</action>
<action dev="POI-DEVELOPERS" type="add">45556 - Support for extraction of footnotes from docx files</action>
+ <action dev="POI-DEVELOPERS" type="add">45555 - Support for extraction of endnotes from docx files</action>
<action dev="POI-DEVELOPERS" type="add">47520 - Initial support for custom XML mappings in XSSF</action>
<action dev="POI-DEVELOPERS" type="fix">47460 - Fixed NPE when retrieving core properties from a newly created workbook</action>
<action dev="POI-DEVELOPERS" type="fix">47498 - Fixed HyperlinkRecord to properly handle URL monikers</action>
protected List<XWPFParagraph> paragraphs;
protected List<XWPFTable> tables;
protected Map<Integer, XWPFFootnote> footnotes;
+ protected Map<Integer, XWPFFootnote> endnotes;
/** Handles the joy of different headers/footers for different pages */
private XWPFHeaderFooterPolicy headerFooterPolicy;
paragraphs = new ArrayList<XWPFParagraph>();
tables= new ArrayList<XWPFTable>();
footnotes = new HashMap<Integer, XWPFFootnote>();
+ endnotes = new HashMap<Integer, XWPFFootnote>();
try {
DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream());
for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteArray()) {
footnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
}
+ } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
+ EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
+
+ for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) {
+ endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
+ }
}
}
}
return footnotes.get(id);
}
+ public XWPFFootnote getEndnoteByID(int id) {
+ return endnotes.get(id);
+ }
+
public Collection<XWPFFootnote> getFootnotes() {
return footnotes == null ? new ArrayList<XWPFFootnote>() : footnotes.values();
}
if (o instanceof CTFtnEdnRef) {
CTFtnEdnRef ftn = (CTFtnEdnRef) o;
footnoteText.append("[").append(ftn.getId()).append(": ");
- XWPFFootnote footnote = document.getFootnoteByID(ftn.getId().intValue());
+ XWPFFootnote footnote =
+ ftn.getDomNode().getLocalName().equals("footnoteReference") ?
+ document.getFootnoteByID(ftn.getId().intValue()) :
+ document.getEndnoteByID(ftn.getId().intValue());
boolean first = true;
for (XWPFParagraph p : footnote.getParagraphs()) {
null,
null
);
+ public static final XWPFRelation ENDNOTE = new XWPFRelation(
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
+ null,
+ null
+ );
private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
assertTrue("Unable to find expected word in text\n" + text, text.contains("test phrase"));
}
- //TODO use the same logic as in HSSFTestDataSamples
+ public void testEndnotes() throws Exception {
+ XWPFDocument doc = open("endnotes.docx");
+ XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
+
+ assertTrue(extractor.getText().contains("XXX"));
+ }
+
+
+ //TODO use the same logic for opening test files as in HSSFTestDataSamples
private XWPFDocument open(String sampleFileName) throws IOException {
File file = new File(
System.getProperty("HWPF.testdata.path"), sampleFileName);