diff --git a/src/main/java/w2phtml/xhtml/ODFPageSplitter.java b/src/main/java/w2phtml/xhtml/ODFPageSplitter.java index db9dd90..fb01536 100644 --- a/src/main/java/w2phtml/xhtml/ODFPageSplitter.java +++ b/src/main/java/w2phtml/xhtml/ODFPageSplitter.java @@ -199,12 +199,12 @@ public class ODFPageSplitter { } else if (nodeName.equals(TEXT_LIST_ITEM)) { if (containsSPB(child)){ - Node listItemFirstPart = child.cloneNode(false); + //remove SPB, move previous nodes to firstPart. - if (handleListItem(listItemFirstPart,child)){ + if (handleListItem(child)){ dataMoved = true; //Add first part of list item to previous list item - listFirstPart.appendChild(listItemFirstPart); + listFirstPart.appendChild(child.getPreviousSibling()); //Get list parent node and move cutted node //After First Part and SPB but before this list; //TODO!!!!!!!!!! @@ -242,7 +242,9 @@ public class ODFPageSplitter { } //If SPB before first item - return false, remove SPB //Otherwise add childNodes before SPB to firstPart, return true - private static boolean handleListItem(Node listItemFirstPart, Node listItem){ + private static boolean handleListItem(Node listItem){ + Node listItemFirstPart = listItem.cloneNode(false); + Node parent = listItem.getParentNode(); int i = 0; boolean dataMoved = false; NodeList listItemNodes = listItem.getChildNodes(); @@ -283,6 +285,9 @@ public class ODFPageSplitter { } //check internal nodes } + if(dataMoved) { + parent.insertBefore(listItemFirstPart, listItem); + } return dataMoved; } //Needs finish