set break before next node on every processBreaks
This commit is contained in:
parent
37699b8b5a
commit
20f7e21595
2 changed files with 23 additions and 31 deletions
src/main/java/w2phtml/xhtml/content
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue