Added page break style option

This commit is contained in:
Georgy Litvinov 2020-01-27 11:45:31 +01:00
parent aa99728e57
commit e5f5d2aa0b
3 changed files with 27 additions and 7 deletions

View file

@ -23,6 +23,7 @@ public class DocumentSeparator {
private boolean splitByPages = false;
private int lastSplitPageNum = 1;
private Integer pageNumber = null;
private String breakStyle = null;
private static LinkedList<Integer> headerStack = new LinkedList<Integer>();
private static boolean pageOpened = false;
@ -42,6 +43,7 @@ public class DocumentSeparator {
pageSeparation = config.getPageTags();
splitLevel = config.getXhtmlSplitLevel();
splitByPages = pageSeparation.equals(DIV) ? true : false;
breakStyle = config.getPageBreakStyle();
}
public void setPageContainerStyle(String style) {
@ -171,18 +173,32 @@ public class DocumentSeparator {
private void breakPage(Node node, int curPageNum) {
if (pageNumber != null && pageNumber != curPageNum) {
Document doc = node.getOwnerDocument();
Element pageBreak = (Element) doc.createElement(DIV);
pageBreak.setAttribute("class", "pageBreak");
if (breakStyleIsSet()) {
applyBreakStyle(pageBreak);
}
node.appendChild(pageBreak);
}
pageNumber = curPageNum;
}
private void applyBreakStyle(Element pageBreak) {
pageBreak.setAttribute("style", breakStyle);
}
public boolean breakStyleIsSet() {
if (breakStyle == null || breakStyle.isEmpty()) {
return false;
} else {
return true;
}
}
private void arrangePageDivs(Node node, int pageNum) {
Document newdoc = node.getOwnerDocument();
Document olddoc = prevPageNode.getOwnerDocument();
String prevPageNum = getAttribute(prevPageNode, "page");
if (prevPageNum != null && prevPageNum.equals(Integer.toString(pageNum))) {
@ -365,6 +381,6 @@ public class DocumentSeparator {
public String getPageContainerStyle() {
return this.pageContainerStyle;
}
}

View file

@ -96,7 +96,7 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
}
this.bConvertFont = !config.useDefaultFont();
String minLS = config.minLetterSpacing().replaceAll("[^0-9,.,-]", "");
String minLS = config.getMinLetterSpacing().replaceAll("[^0-9,.,-]", "");
if (!minLS.equals("")) {
try {
this.minLetterSpacing = Double.parseDouble(minLS);

View file

@ -40,7 +40,7 @@ import writer2latex.util.Misc;
public class XhtmlConfig extends writer2latex.base.ConfigBase {
// Implement configuration methods
protected int getOptionCount() { return 62; }
protected int getOptionCount() { return 63; }
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
// Override setOption: To be backwards compatible, we must accept options
@ -161,6 +161,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
private static final int HEADING_TAGS = 59;
private static final int PAGE_TAGS = 60;
private static final int MIN_LETTER_SPACING = 61;
private static final int PAGE_BREAK_STYLE = 62;
protected ComplexOption xheading = addComplexOption("heading-map");
protected ComplexOption xpar = addComplexOption("paragraph-map");
@ -297,6 +298,8 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
options[HEADING_TAGS] = new Option("heading_tags","sections");
options[PAGE_TAGS] = new Option("page_tags","div");
options[MIN_LETTER_SPACING] = new Option("min_letter_spacing","");
options[PAGE_BREAK_STYLE] = new Option("page_break_style","");
}
@ -446,8 +449,9 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
}
return options[HEADING_TAGS].getString(); }
public String getPageTags() { return options[PAGE_TAGS].getString(); }
public String minLetterSpacing() { return ( options[MIN_LETTER_SPACING]).getString(); }
public String getMinLetterSpacing() { return ( options[MIN_LETTER_SPACING]).getString(); }
public String getPageBreakStyle() { return ( options[PAGE_BREAK_STYLE]).getString(); }
public XhtmlStyleMap getXParStyleMap() { return getStyleMap(xpar); }
public XhtmlStyleMap getXHeadingStyleMap() { return getStyleMap(xheading); }
public XhtmlStyleMap getXTextStyleMap() { return getStyleMap(xtext); }