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