diff --git a/source/java/writer2latex/xhtml/TextConverter.java b/source/java/writer2latex/xhtml/TextConverter.java index 24d7b5a..48b66f9 100644 --- a/source/java/writer2latex/xhtml/TextConverter.java +++ b/source/java/writer2latex/xhtml/TextConverter.java @@ -151,8 +151,7 @@ public class TextConverter extends ConverterHelper { if (!config.includeToc()){ extractRealTOC(onode); } - - //Split pages + //Split pages onode = (Element) PageSplitter.splitSoftPageBreak(onode,ofr); // Convert content hnode = (Element)traverseBlockText(onode,hnode); @@ -181,18 +180,30 @@ public class TextConverter extends ConverterHelper { if (tocs == null){ return; } - System.out.println("extractRealTOC"); + System.out.println("extractRealTOC " + tocs.getLength()); while (i < tocs.getLength()){ Node toc = tocs.item(i); - NodeList indexTitle = onode.getElementsByTagName(XMLString.TEXT_INDEX_TITLE); - if (indexTitle == null || indexTitle.item(0) == null){ + NodeList indexBody = ((Element)toc).getElementsByTagName(XMLString.TEXT_INDEX_BODY); + if (indexBody == null || indexBody.item(0) == null){ i++; continue; } - while (indexTitle.item(0).hasChildNodes()){ - Node child = indexTitle.item(0).getFirstChild(); + while (indexBody.item(0).hasChildNodes()){ + Node child = indexBody.item(0).getFirstChild(); + if (child.getNodeType() == Node.ELEMENT_NODE + && + ((Element) child).getTagName().equals(XMLString.TEXT_INDEX_TITLE) + ){ + while(child.hasChildNodes()){ + + toc.getParentNode().insertBefore(child.getFirstChild(),toc); + } + //kamikadze + child.getParentNode().removeChild(child); + continue; + + } //Move childnodes before text:table-of-content - System.out.println("insertBefore"); toc.getParentNode().insertBefore(child, toc); } i++;