diff --git a/src/main/java/w2phtml/xhtml/content/Separator.java b/src/main/java/w2phtml/xhtml/content/Separator.java index 5b79654..8f652bf 100644 --- a/src/main/java/w2phtml/xhtml/content/Separator.java +++ b/src/main/java/w2phtml/xhtml/content/Separator.java @@ -55,7 +55,7 @@ public class Separator { headingPath = new int[10]; } - public Node whatToDoWithOutlineNodeOnPage(Node currentNode, Node hnode, int pageNum) { + public Node breakOutline(Node currentNode, Node hnode, int pageNum) { // Get outline level if (isBadOutlineNode(currentNode)) { return hnode; @@ -519,7 +519,7 @@ public class Separator { return hnode; } else { - hnode = whatToDoWithOutlineNodeOnPage(currentNode, hnode, pageNum); + hnode = breakOutline(currentNode, hnode, pageNum); } return hnode; } diff --git a/src/main/java/w2phtml/xhtml/content/TextParser.java b/src/main/java/w2phtml/xhtml/content/TextParser.java index 5233165..3ec5072 100644 --- a/src/main/java/w2phtml/xhtml/content/TextParser.java +++ b/src/main/java/w2phtml/xhtml/content/TextParser.java @@ -121,7 +121,7 @@ public class TextParser extends Parser { private String footnotesContext = null; PageContainer pageContainer = null; private boolean applyAnnotationMetadata; - private boolean breakBeforeSectionInProcessFlag = false; + private boolean breakBeforeSectionInProcess = false; private StyleWithProperties lastSectionStyle; public TextParser(OfficeReader ofr, XhtmlConfig config, Converter converter) { @@ -1205,43 +1205,38 @@ public class TextParser extends Parser { if (wasProcessedWithSection(currentNode, style)) { return hnode; } + if (hasBreakBefore(style)) { + if (currentNode.getNodeName() == TEXT_SECTION) { + if (breakBeforeSectionInProcess) { + //skip one more section; + return hnode; + } else { + breakBeforeSectionInProcess = true; + } + } else { + //assume in inner element, break happened, skip break. + if (breakBeforeSectionInProcess) { + breakBeforeSectionInProcess = false; + return hnode; + } + } + } + boolean firstSeparation = (currentMasterPage == null) ; if (firstSeparation && style != null) { hnode = startDocument(hnode, style); } if (isPageBreakFound(style) && !firstSeparation) { - if (hasBreakBefore(style)) { - - if (currentNode.getNodeName() == TEXT_SECTION) { - if (breakBeforeSectionInProcessFlag) { - //skip one more section; - return hnode; - } else { - breakBeforeSectionInProcessFlag = true; - } - } else { - //assume in inner element, break happened, skip break. - if (breakBeforeSectionInProcessFlag) { - breakBeforeSectionInProcessFlag = false; - return hnode; - } - } - } hnode = breakPage(currentNode, hnode, style); - - return hnode; - } else { - hnode = docSep.whatToDoWithOutlineNodeOnPage(currentNode, hnode, pageNum); + hnode = docSep.breakOutline(currentNode, hnode, pageNum); } - - setBreakPageBeforeNextNode(style); - + setBreakPageBeforeNextFromStyle(style); return hnode; } - private void setBreakPageBeforeNextNode(StyleWithProperties style) { + private void setBreakPageBeforeNextFromStyle(StyleWithProperties style) { if (isNewHardPageBreakAfter(style)) { breakPageBeforeNextNode = true; } else { @@ -1289,11 +1284,8 @@ public class TextParser extends Parser { } hnode = docSep.breaksOrOutline(currentNode, hnode, pageNum); - // Print new header addHeader(hnode); - //hnode = enterPageContainer(hnode); - breakPageBeforeNextNode = false; return hnode; }