headers = new ArrayList<XWPFHeader>();
footnotes = new HashMap<Integer, XWPFFootnote>();
endnotes = new HashMap<Integer, XWPFFootnote>();
try {
DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream());
ctDocument = doc.getDocument();
initFootnotes();
// parse the document with cursor and add
// the XmlObject to its lists
XmlCursor cursor = ctDocument.getBody().newCursor();
cursor.selectPath("./*");
while (cursor.toNextSelection()) {
XmlObject o = cursor.getObject();
if (o instanceof CTP) {
XWPFParagraph p = new XWPFParagraph((CTP)o, this);
bodyElements.add(p);
paragraphs.add(p);
}
if (o instanceof CTTbl) {
XWPFTable t = new XWPFTable((CTTbl)o, this);
bodyElements.add(t);
tables.add(t);
}
}
// Sort out headers and footers
if (doc.getDocument().getBody().getSectPr() != null)
headerFooterPolicy = new XWPFHeaderFooterPolicy(this);
// Create for each XML-part in the Package a PartClass
for(POIXMLDocumentPart p : getRelations()){
String relation = p.getPackageRelationship().getRelationshipType();