set break before next node on every processBreaks

This commit is contained in:
Georgy Litvinov 2021-03-13 19:29:28 +01:00
parent 37699b8b5a
commit 20f7e21595
2 changed files with 23 additions and 31 deletions

View file

@ -55,7 +55,7 @@ public class Separator {
headingPath = new int[10]; 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 // Get outline level
if (isBadOutlineNode(currentNode)) { if (isBadOutlineNode(currentNode)) {
return hnode; return hnode;
@ -519,7 +519,7 @@ public class Separator {
return hnode; return hnode;
} else { } else {
hnode = whatToDoWithOutlineNodeOnPage(currentNode, hnode, pageNum); hnode = breakOutline(currentNode, hnode, pageNum);
} }
return hnode; return hnode;
} }

View file

@ -121,7 +121,7 @@ public class TextParser extends Parser {
private String footnotesContext = null; private String footnotesContext = null;
PageContainer pageContainer = null; PageContainer pageContainer = null;
private boolean applyAnnotationMetadata; private boolean applyAnnotationMetadata;
private boolean breakBeforeSectionInProcessFlag = false; private boolean breakBeforeSectionInProcess = false;
private StyleWithProperties lastSectionStyle; private StyleWithProperties lastSectionStyle;
public TextParser(OfficeReader ofr, XhtmlConfig config, Converter converter) { public TextParser(OfficeReader ofr, XhtmlConfig config, Converter converter) {
@ -1205,43 +1205,38 @@ public class TextParser extends Parser {
if (wasProcessedWithSection(currentNode, style)) { if (wasProcessedWithSection(currentNode, style)) {
return hnode; 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) ; boolean firstSeparation = (currentMasterPage == null) ;
if (firstSeparation && style != null) { if (firstSeparation && style != null) {
hnode = startDocument(hnode, style); hnode = startDocument(hnode, style);
} }
if (isPageBreakFound(style) && !firstSeparation) { 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); hnode = breakPage(currentNode, hnode, style);
return hnode;
} else { } else {
hnode = docSep.whatToDoWithOutlineNodeOnPage(currentNode, hnode, pageNum); hnode = docSep.breakOutline(currentNode, hnode, pageNum);
} }
setBreakPageBeforeNextFromStyle(style);
setBreakPageBeforeNextNode(style);
return hnode; return hnode;
} }
private void setBreakPageBeforeNextNode(StyleWithProperties style) { private void setBreakPageBeforeNextFromStyle(StyleWithProperties style) {
if (isNewHardPageBreakAfter(style)) { if (isNewHardPageBreakAfter(style)) {
breakPageBeforeNextNode = true; breakPageBeforeNextNode = true;
} else { } else {
@ -1289,11 +1284,8 @@ public class TextParser extends Parser {
} }
hnode = docSep.breaksOrOutline(currentNode, hnode, pageNum); hnode = docSep.breaksOrOutline(currentNode, hnode, pageNum);
// Print new header // Print new header
addHeader(hnode); addHeader(hnode);
//hnode = enterPageContainer(hnode);
breakPageBeforeNextNode = false;
return hnode; return hnode;
} }