Fix bug #55196 - Correct XWPF createTOC handling of short style names

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1614930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-07-31 16:11:35 +00:00
parent 2ee05730bd
commit afa2322295

View File

@ -892,7 +892,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
TOC toc = new TOC(block); TOC toc = new TOC(block);
for (XWPFParagraph par : paragraphs) { for (XWPFParagraph par : paragraphs) {
String parStyle = par.getStyle(); String parStyle = par.getStyle();
if (parStyle != null && parStyle.substring(0, 7).equals("Heading")) { if (parStyle != null && parStyle.startsWith("Heading")) {
try { try {
int level = Integer.valueOf(parStyle.substring("Heading".length())).intValue(); int level = Integer.valueOf(parStyle.substring("Heading".length())).intValue();
toc.addRow(level, par.getText(), 1, "112723803"); toc.addRow(level, par.getText(), 1, "112723803");