When creating a new Docx document, it is impossible to add a new numbering. The only option for creating an XWPFNumbering object is by reading in a document that already has a Numbering section. It was suggested on the mailing list to create an additional method on XWPFDocument that will add the numbering, and then implement the appropriate constructor on XWPFNumbering. Here's the original thread: http://mail-archives.apache.org/mod_mbox/poi-user/201104.mbox/%3Calpine.DEB.2.00.1104280351400.29085@urchin.earth.li%3E
Created attachment 27042 [details] Changes in tar.gz format Allow new XWPFDocuments to create Numbering and Styles elements from scratch. Previously, these elements could only be modified if read in from existing an existing docx. This patch also contains new methods to XWPFStyles to set default spelling language and font properties. These changes can be moved to a different patch/bug if necessary.
Created attachment 27043 [details] Diff
Thanks, committed in r1128296. Any chance you could knock up a quick unit test for this? A test that springs to mind is to create a doc, add the numbering and styles and set these. Then, save it and re-open it in XWPF, and check the expected things are all there
Created attachment 27268 [details] Unit tests for creating and adding Numberings and Styles to a new document. As per Nick's suggestion, here are some unit tests for the functionality I added.
Thanks, unit tests added in r1144303.