Bug 55196 - XWPFDocument createTOC Exception when style names less than 7 characters
Summary: XWPFDocument createTOC Exception when style names less than 7 characters
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-04 09:45 UTC by emberey
Modified: 2014-07-31 16:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.