Bug 55196

Summary: XWPFDocument createTOC Exception when style names less than 7 characters
Product: POI Reporter: emberey <clive.emberey>
Component: XWPFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.9-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description emberey 2013-07-04 09:45:01 UTC
OpenXML Word Documents.

Using createTOC will raise an exception if any of your styles are less than
7 characters. This is caused by the method createTOC and the line

            if (parStyle != null && parStyle.substring(0,
7).equals("Heading")) {

Quick fix is to extend this class and override createTOC. The line should be something like

            if (parStyle != null && parStyle.startsWith("Heading")) {

Also remember to position to the location you want the TOC to be inserted.

If somebody can point me in the right direction I would happy to try to write a patch.
Comment 1 Nick Burch 2014-07-31 16:11:42 UTC
Good spot, thanks, fix applied in r1614930.