extract real TOC
This commit is contained in:
parent
4c6cc14c95
commit
3b64ebe942
1 changed files with 19 additions and 8 deletions
|
@ -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++;
|
||||
|
|
Loading…
Add table
Reference in a new issue