Refactored list item split method

This commit is contained in:
Georgy Litvinov 2020-07-24 19:31:05 +02:00
parent 874aae1e80
commit 457caad4fc

View file

@ -199,12 +199,12 @@ public class ODFPageSplitter {
} else if (nodeName.equals(TEXT_LIST_ITEM)) { } else if (nodeName.equals(TEXT_LIST_ITEM)) {
if (containsSPB(child)){ if (containsSPB(child)){
Node listItemFirstPart = child.cloneNode(false);
//remove SPB, move previous nodes to firstPart. //remove SPB, move previous nodes to firstPart.
if (handleListItem(listItemFirstPart,child)){ if (handleListItem(child)){
dataMoved = true; dataMoved = true;
//Add first part of list item to previous list item //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 //Get list parent node and move cutted node
//After First Part and SPB but before this list; //After First Part and SPB but before this list;
//TODO!!!!!!!!!! //TODO!!!!!!!!!!
@ -242,7 +242,9 @@ public class ODFPageSplitter {
} }
//If SPB before first item - return false, remove SPB //If SPB before first item - return false, remove SPB
//Otherwise add childNodes before SPB to firstPart, return true //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; int i = 0;
boolean dataMoved = false; boolean dataMoved = false;
NodeList listItemNodes = listItem.getChildNodes(); NodeList listItemNodes = listItem.getChildNodes();
@ -283,6 +285,9 @@ public class ODFPageSplitter {
} }
//check internal nodes //check internal nodes
} }
if(dataMoved) {
parent.insertBefore(listItemFirstPart, listItem);
}
return dataMoved; return dataMoved;
} }
//Needs finish //Needs finish