Refactored section split

This commit is contained in:
Georgy Litvinov 2020-07-24 15:23:51 +02:00
parent ca2b91cb4a
commit f3e6f8efa0

View file

@ -52,9 +52,7 @@ public class ODFPageSplitter {
} else if (nodeName.equals(TEXT_ALPHABETICAL_INDEX)) {
splitABIndex(child);
} else if (nodeName.equals(TEXT_SECTION)) {
Node sectionFirstPart = handleSection(child);
if (sectionFirstPart != null) {
onode.insertBefore(sectionFirstPart, child);
if (handleSection(child)) {
style = ofr.getSectionStyle(Misc.getAttribute(child, TEXT_SECTION));
}
} else if (nodeName.equals(TEXT_TABLE_OF_CONTENT)){
@ -537,7 +535,8 @@ public class ODFPageSplitter {
}
return dataMoved;
}
private static Node handleSection(Node section) {
private static boolean handleSection(Node section) {
Node parent = section.getParentNode();
setLastAttribute(section);
Node sectionFirstPart = section.cloneNode(false);
removeLastAttribute(sectionFirstPart);
@ -571,9 +570,8 @@ public class ODFPageSplitter {
dataMoved=true;
}
} else if (nodeName.equals(TEXT_SECTION)) {
Node childSectionFirstPart = handleSection(child);
if (childSectionFirstPart != null){
sectionFirstPart.appendChild(childSectionFirstPart);
if (handleSection(child)){
sectionFirstPart.appendChild(child.getPreviousSibling());
dataMoved=true;
}
} else if (nodeName.equals(TEXT_LIST)) {
@ -595,10 +593,10 @@ public class ODFPageSplitter {
}
if (dataMoved) {
return sectionFirstPart;
parent.insertBefore(sectionFirstPart, section);
}
return null;
return dataMoved;
}