Bug 51134

Summary: [PATCH] XWPFNumbering and XWPFStyles classes lack a constructor that doesn't call onDocumentRead
Product: POI Reporter: Mike McEuen <mceuen>
Component: XWPFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Changes in tar.gz format
Unit tests for creating and adding Numberings and Styles to a new document.

Description Mike McEuen 2011-04-28 10:26:36 UTC
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:
Comment 1 Mike McEuen 2011-05-20 21:40:35 UTC
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.
Comment 2 Mike McEuen 2011-05-20 21:40:59 UTC
Created attachment 27043 [details]
Comment 3 Nick Burch 2011-05-27 13:25:55 UTC
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
Comment 4 Mike McEuen 2011-07-06 20:12:31 UTC
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.
Comment 5 Nick Burch 2011-07-08 13:13:11 UTC
Thanks, unit tests added in r1144303.