Fix for page content column count option
This commit is contained in:
parent
b2c79c0138
commit
0926dbe218
3 changed files with 164 additions and 148 deletions
|
@ -40,7 +40,7 @@ import writer2latex.util.Misc;
|
||||||
|
|
||||||
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||||
// Implement configuration methods
|
// Implement configuration methods
|
||||||
protected int getOptionCount() { return 63; }
|
protected int getOptionCount() { return 64; }
|
||||||
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
||||||
|
|
||||||
// Override setOption: To be backwards compatible, we must accept options
|
// Override setOption: To be backwards compatible, we must accept options
|
||||||
|
@ -162,6 +162,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||||
private static final int PAGE_TAGS = 60;
|
private static final int PAGE_TAGS = 60;
|
||||||
private static final int MIN_LETTER_SPACING = 61;
|
private static final int MIN_LETTER_SPACING = 61;
|
||||||
private static final int PAGE_BREAK_STYLE = 62;
|
private static final int PAGE_BREAK_STYLE = 62;
|
||||||
|
private static final int CSS_INLINE = 63;
|
||||||
|
|
||||||
protected ComplexOption xheading = addComplexOption("heading-map");
|
protected ComplexOption xheading = addComplexOption("heading-map");
|
||||||
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
||||||
|
@ -299,6 +300,8 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||||
options[PAGE_TAGS] = new Option("page_tags","div");
|
options[PAGE_TAGS] = new Option("page_tags","div");
|
||||||
options[MIN_LETTER_SPACING] = new Option("min_letter_spacing","0.15");
|
options[MIN_LETTER_SPACING] = new Option("min_letter_spacing","0.15");
|
||||||
options[PAGE_BREAK_STYLE] = new Option("page_break_style","");
|
options[PAGE_BREAK_STYLE] = new Option("page_break_style","");
|
||||||
|
options[CSS_INLINE] = new BooleanOption("css_inline","true");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,6 +460,8 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||||
public XhtmlStyleMap getXFrameStyleMap() { return getStyleMap(xframe); }
|
public XhtmlStyleMap getXFrameStyleMap() { return getStyleMap(xframe); }
|
||||||
public XhtmlStyleMap getXListStyleMap() { return getStyleMap(xlist); }
|
public XhtmlStyleMap getXListStyleMap() { return getStyleMap(xlist); }
|
||||||
public XhtmlStyleMap getXAttrStyleMap() { return getStyleMap(xattr); }
|
public XhtmlStyleMap getXAttrStyleMap() { return getStyleMap(xattr); }
|
||||||
|
public boolean inlineCSS() { return ((BooleanOption) options[CSS_INLINE]).getValue(); }
|
||||||
|
|
||||||
|
|
||||||
private XhtmlStyleMap getStyleMap(ComplexOption co) {
|
private XhtmlStyleMap getStyleMap(ComplexOption co) {
|
||||||
XhtmlStyleMap map = new XhtmlStyleMap();
|
XhtmlStyleMap map = new XhtmlStyleMap();
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class TextParser extends Parser {
|
||||||
private boolean bInToc = false;
|
private boolean bInToc = false;
|
||||||
|
|
||||||
// Display hidden text?
|
// Display hidden text?
|
||||||
private boolean bDisplayHiddenText = false;
|
private boolean displayHiddenText = false;
|
||||||
// Current page number
|
// Current page number
|
||||||
int pageNum = 1;
|
int pageNum = 1;
|
||||||
//Current master page name
|
//Current master page name
|
||||||
|
@ -124,6 +124,7 @@ public class TextParser extends Parser {
|
||||||
private boolean inFooter = false;
|
private boolean inFooter = false;
|
||||||
private String endnotesContext = null;
|
private String endnotesContext = null;
|
||||||
private String footnotesContext = null;
|
private String footnotesContext = null;
|
||||||
|
private boolean inlineCSS;
|
||||||
PageContainer pageContainer = null;
|
PageContainer pageContainer = null;
|
||||||
|
|
||||||
public TextParser(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
public TextParser(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
||||||
|
@ -142,9 +143,10 @@ public class TextParser extends Parser {
|
||||||
nFloatMode = ofr.isText() && config.xhtmlFloatObjects() ?
|
nFloatMode = ofr.isText() && config.xhtmlFloatObjects() ?
|
||||||
DrawParser.FLOATING : DrawParser.ABSOLUTE;
|
DrawParser.FLOATING : DrawParser.ABSOLUTE;
|
||||||
outlineNumbering = new ListCounter(ofr.getOutlineStyle());
|
outlineNumbering = new ListCounter(ofr.getOutlineStyle());
|
||||||
bDisplayHiddenText = config.displayHiddenText();
|
displayHiddenText = config.displayHiddenText();
|
||||||
pageContainer = converter.pageContainer;
|
pageContainer = converter.pageContainer;
|
||||||
docSep = new Separator(config, converter);
|
docSep = new Separator(config, converter);
|
||||||
|
inlineCSS = config.inlineCSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts an office node as a complete text document
|
/** Converts an office node as a complete text document
|
||||||
|
@ -541,7 +543,7 @@ public class TextParser extends Parser {
|
||||||
boolean isLast = false;
|
boolean isLast = false;
|
||||||
if (last != null && last.equals("true")) { isLast = true;}
|
if (last != null && last.equals("true")) { isLast = true;}
|
||||||
|
|
||||||
if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; }
|
if (!displayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; }
|
||||||
|
|
||||||
if (pageWasOpened) {hnode = docSep.closePage(hnode);}
|
if (pageWasOpened) {hnode = docSep.closePage(hnode);}
|
||||||
boolean removeStyleAtExit = setSectionStyle(onode);
|
boolean removeStyleAtExit = setSectionStyle(onode);
|
||||||
|
@ -600,9 +602,7 @@ public class TextParser extends Parser {
|
||||||
/*
|
/*
|
||||||
* Process a text:h tag
|
* Process a text:h tag
|
||||||
*/
|
*/
|
||||||
private void handleHeading(Element onode, Element hnode, boolean bAfterSplit,
|
private void handleHeading(Element onode, Element hnode, boolean bAfterSplit, ListStyle listStyle, int nListLevel, boolean bUnNumbered, boolean bRestart, int nStartValue) {
|
||||||
ListStyle listStyle, int nListLevel, boolean bUnNumbered,
|
|
||||||
boolean bRestart, int nStartValue) {
|
|
||||||
|
|
||||||
// Note: nListLevel may in theory be different from the outline level,
|
// Note: nListLevel may in theory be different from the outline level,
|
||||||
// though the ui in OOo does not allow this
|
// though the ui in OOo does not allow this
|
||||||
|
@ -618,11 +618,14 @@ public class TextParser extends Parser {
|
||||||
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
||||||
|
|
||||||
// Check for hidden text
|
// Check for hidden text
|
||||||
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(TEXT_DISPLAY))) { return; }
|
if (!displayHiddenText && style != null && "none".equals(style.getProperty(TEXT_DISPLAY))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Numbering
|
// Numbering
|
||||||
if (!bUnNumbered) {
|
if (!bUnNumbered) {
|
||||||
// If the heading uses a paragraph style which sets an explicit empty list style name, it's unnumbered
|
// If the heading uses a paragraph style which sets an explicit empty
|
||||||
|
// list style name, it's unnumbered
|
||||||
if (style != null) {
|
if (style != null) {
|
||||||
String sListStyleName = style.getListStyleName();
|
String sListStyleName = style.getListStyleName();
|
||||||
if (sListStyleName != null && sListStyleName.length() == 0) {
|
if (sListStyleName != null && sListStyleName.length() == 0) {
|
||||||
|
@ -634,11 +637,14 @@ public class TextParser extends Parser {
|
||||||
String sLabel = "";
|
String sLabel = "";
|
||||||
if (!bUnNumbered) {
|
if (!bUnNumbered) {
|
||||||
counter = getListCounter(listStyle);
|
counter = getListCounter(listStyle);
|
||||||
if (bRestart) { counter.restart(nListLevel,nStartValue); }
|
if (bRestart) {
|
||||||
|
counter.restart(nListLevel, nStartValue);
|
||||||
|
}
|
||||||
sLabel = counter.step(nListLevel).getLabel();
|
sLabel = counter.step(nListLevel).getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// In EPUB export, a striked out heading will only appear in the external toc
|
// In EPUB export, a striked out heading will only appear in the external
|
||||||
|
// toc
|
||||||
boolean bTocOnly = false;
|
boolean bTocOnly = false;
|
||||||
if (converter.isOPS() && style != null) {
|
if (converter.isOPS() && style != null) {
|
||||||
String sStrikeOut = style.getProperty(STYLE_TEXT_LINE_THROUGH_STYLE, true);
|
String sStrikeOut = style.getProperty(STYLE_TEXT_LINE_THROUGH_STYLE, true);
|
||||||
|
@ -652,7 +658,9 @@ public class TextParser extends Parser {
|
||||||
// If split output, add headings of higher levels
|
// If split output, add headings of higher levels
|
||||||
if (bAfterSplit && nSplit > 0) {
|
if (bAfterSplit && nSplit > 0) {
|
||||||
int nFirst = nLevel - nRepeatLevels;
|
int nFirst = nLevel - nRepeatLevels;
|
||||||
if (nFirst<0) { nFirst=0; }
|
if (nFirst < 0) {
|
||||||
|
nFirst = 0;
|
||||||
|
}
|
||||||
for (int i = nFirst; i < nLevel; i++) {
|
for (int i = nFirst; i < nLevel; i++) {
|
||||||
if (currentHeading[i] != null) {
|
if (currentHeading[i] != null) {
|
||||||
hnode.appendChild(converter.importNode(currentHeading[i], true));
|
hnode.appendChild(converter.importNode(currentHeading[i], true));
|
||||||
|
@ -671,13 +679,13 @@ public class TextParser extends Parser {
|
||||||
applyStyle(info, heading);
|
applyStyle(info, heading);
|
||||||
traverseFloats(onode, hnode, heading);
|
traverseFloats(onode, hnode, heading);
|
||||||
// Apply writing direction
|
// Apply writing direction
|
||||||
/*String sStyleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
/*
|
||||||
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
* String sStyleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
||||||
if (style!=null) {
|
* StyleWithProperties style = ofr.getParStyle(sStyleName); if
|
||||||
StyleInfo headInfo = new StyleInfo();
|
* (style!=null) { StyleInfo headInfo = new StyleInfo();
|
||||||
StyleConverterHelper.applyDirection(style,headInfo);
|
* StyleConverterHelper.applyDirection(style,headInfo);
|
||||||
getParSc().applyStyle(headInfo,heading);
|
* getParSc().applyStyle(headInfo,heading); }
|
||||||
}*/
|
*/
|
||||||
|
|
||||||
// Prepend asapNode
|
// Prepend asapNode
|
||||||
prependAsapNode(heading);
|
prependAsapNode(heading);
|
||||||
|
@ -711,8 +719,7 @@ public class TextParser extends Parser {
|
||||||
for (int i = nLevel + 1; i <= 6; i++) {
|
for (int i = nLevel + 1; i <= 6; i++) {
|
||||||
currentHeading[i] = null;
|
currentHeading[i] = null;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!bInToc) {
|
if (!bInToc) {
|
||||||
tocCv.handleHeadingExternal(onode, hnode, sLabel);
|
tocCv.handleHeadingExternal(onode, hnode, sLabel);
|
||||||
}
|
}
|
||||||
|
@ -723,8 +730,7 @@ public class TextParser extends Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else { // beyond h6 - export as ordinary paragraph
|
||||||
else { // beyond h6 - export as ordinary paragraph
|
|
||||||
handleParagraph(onode, hnode);
|
handleParagraph(onode, hnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,7 +743,7 @@ public class TextParser extends Parser {
|
||||||
if (config.ignoreEmptyParagraphs() && bIsEmpty) { return; }
|
if (config.ignoreEmptyParagraphs() && bIsEmpty) { return; }
|
||||||
String styleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
String styleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
|
||||||
StyleWithProperties style = ofr.getParStyle(styleName);
|
StyleWithProperties style = ofr.getParStyle(styleName);
|
||||||
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(TEXT_DISPLAY))) { return; }
|
if (!displayHiddenText && style!=null && "none".equals(style.getProperty(TEXT_DISPLAY))) { return; }
|
||||||
|
|
||||||
Element par;
|
Element par;
|
||||||
if (ofr.isSpreadsheet()) { // attach inline text directly to parent (always a table cell)
|
if (ofr.isSpreadsheet()) { // attach inline text directly to parent (always a table cell)
|
||||||
|
@ -1380,14 +1386,15 @@ public class TextParser extends Parser {
|
||||||
|
|
||||||
private void handleSpan(Node onode, Node hnode) {
|
private void handleSpan(Node onode, Node hnode) {
|
||||||
StyleWithProperties style = ofr.getTextStyle(Misc.getAttribute(onode, TEXT_STYLE_NAME));
|
StyleWithProperties style = ofr.getTextStyle(Misc.getAttribute(onode, TEXT_STYLE_NAME));
|
||||||
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(TEXT_DISPLAY))) { return; }
|
if (!displayHiddenText && style != null && "none".equals(style.getProperty(TEXT_DISPLAY))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!bInToc) {
|
if (!bInToc) {
|
||||||
String sStyleName = Misc.getAttribute(onode, TEXT_STYLE_NAME);
|
String sStyleName = Misc.getAttribute(onode, TEXT_STYLE_NAME);
|
||||||
Element span = createInline((Element) hnode, sStyleName);
|
Element span = createInline((Element) hnode, sStyleName);
|
||||||
traverseInlineText(onode, span);
|
traverseInlineText(onode, span);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
traverseInlineText(onode, hnode);
|
traverseInlineText(onode, hnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1814,9 +1821,11 @@ public class TextParser extends Parser {
|
||||||
private void setPageContainerStyle() {
|
private void setPageContainerStyle() {
|
||||||
MasterPage mp = ofr.getFullMasterPage(currentMasterPage);
|
MasterPage mp = ofr.getFullMasterPage(currentMasterPage);
|
||||||
PageLayout layout = ofr.getPageLayout(mp.getPageLayoutName());
|
PageLayout layout = ofr.getPageLayout(mp.getPageLayoutName());
|
||||||
|
if (layout.getColCount() != 1) {
|
||||||
String containerStyle = "column-count: " + layout.getColCount() + ";";
|
String containerStyle = "column-count: " + layout.getColCount() + ";";
|
||||||
pageContainer.setRootStyle(containerStyle);
|
pageContainer.setRootStyle(containerStyle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fitPageNumberToMasterPageStyle() {
|
private void fitPageNumberToMasterPageStyle() {
|
||||||
// TODO: READ master-page style
|
// TODO: READ master-page style
|
||||||
|
|
|
@ -61,6 +61,7 @@ public abstract class StyleParser extends Parser {
|
||||||
private String sScale;
|
private String sScale;
|
||||||
private String sColScale;
|
private String sColScale;
|
||||||
private boolean bConvertToPx;
|
private boolean bConvertToPx;
|
||||||
|
private boolean inlineCSS;
|
||||||
|
|
||||||
/** Create a new <code>StyleConverterHelper</code>
|
/** Create a new <code>StyleConverterHelper</code>
|
||||||
* @param ofr an <code>OfficeReader</code> to read style information from
|
* @param ofr an <code>OfficeReader</code> to read style information from
|
||||||
|
@ -76,6 +77,7 @@ public abstract class StyleParser extends Parser {
|
||||||
sScale = config.getXhtmlScaling();
|
sScale = config.getXhtmlScaling();
|
||||||
sColScale = config.getXhtmlColumnScaling();
|
sColScale = config.getXhtmlColumnScaling();
|
||||||
bConvertToPx = config.xhtmlConvertToPx();
|
bConvertToPx = config.xhtmlConvertToPx();
|
||||||
|
inlineCSS = config.inlineCSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String scale(String s) {
|
public String scale(String s) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue