diff --git a/src/main/java/w2phtml/xhtml/ODFPageSplitter.java b/src/main/java/w2phtml/xhtml/ODFPageSplitter.java index 4fccd55..78f3019 100644 --- a/src/main/java/w2phtml/xhtml/ODFPageSplitter.java +++ b/src/main/java/w2phtml/xhtml/ODFPageSplitter.java @@ -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; }