When trying to insert an object into a document via `XWPFDocument#insertNewParagraph(XmlCursor cursor)`, where the cursor points to something in the header/footer, a `ClassCastException` is thrown. The reason for this is in `insertIntoParentElement(IBodyElement iBodyElement, Deque<XmlObject> path)`, where I assumed that the element can only be nested in a table, when in reality it can also be in a header or footer.
https://github.com/apache/poi/pull/640
I did some more work around this problem and discovered that the problem might actually lie somewhere else, as XWPFDocument.insertNewParagraph(XmlCursor) should not be invoked if the parent object is actually a XWPFHeaderFooter, instead we should use XWPFHeaderFooter.insertNewParagraph(XmlCursor).