W2L custom config ui refactoring + some LaTeX and EPUB fixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@78 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
a3a6b0befc
commit
84f4d5cb20
12 changed files with 834 additions and 917 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-11-22)
|
||||
* Version 1.2 (2010-11-28)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -86,7 +86,8 @@ public class TextConverter extends ConverterHelper {
|
|||
private static final int EPUB_CHARACTER_COUNT_TRESHOLD = 150000;
|
||||
private int nPageBreakSplit = XhtmlConfig.NONE; // Should we split at page breaks?
|
||||
// TODO: Collect soft page breaks between table rows
|
||||
private boolean bPendingPageBreak = false; // We have encountered a page break which should be inserted asap
|
||||
private boolean bPendingPageBreak = false; // We have encountered a page break which should be inserted asap
|
||||
private int nExternalTocDepth = 1; // The number of levels to include in the "external" table of contents
|
||||
private int nSplit = 0; // The outline level at which to split files (0=no split)
|
||||
private int nRepeatLevels = 5; // The number of levels to repeat when splitting (0=no repeat)
|
||||
private int nLastSplitLevel = 1; // The outline level at which the last split occurred
|
||||
|
@ -147,6 +148,10 @@ public class TextConverter extends ConverterHelper {
|
|||
nPageBreakSplit = config.pageBreakSplit();
|
||||
nSplit = config.getXhtmlSplitLevel();
|
||||
nRepeatLevels = config.getXhtmlRepeatLevels();
|
||||
nExternalTocDepth = config.externalTocDepth();
|
||||
if (nExternalTocDepth==0) { // A value of zero means auto (i.e. determine from split level)
|
||||
nExternalTocDepth = Math.max(nSplit,1);
|
||||
}
|
||||
nFloatMode = ofr.isText() && config.xhtmlFloatObjects() ?
|
||||
DrawConverter.FLOATING : DrawConverter.ABSOLUTE;
|
||||
outlineNumbering = new ListCounter(ofr.getOutlineStyle());
|
||||
|
@ -674,10 +679,10 @@ public class TextConverter extends ConverterHelper {
|
|||
converter.addTarget(heading,sTarget);
|
||||
|
||||
// Add in external content. For single file output we include all level 1 headings + their target
|
||||
// For multi-file output, the included heading levels depends on the split leve, and we don't include targets
|
||||
if (nLevel<=Math.max(nSplit,1)) {
|
||||
// Targets are added only when the toc level is deeper than the split level
|
||||
if (nLevel<=nExternalTocDepth) {
|
||||
converter.addContentEntry(sLabel+(sLabel.length()>0 ? " " : "")+converter.getPlainInlineText(onode), nLevel,
|
||||
nSplit==0 ? sTarget : null);
|
||||
nLevel>nSplit ? sTarget : null);
|
||||
}
|
||||
|
||||
// Add to real toc
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-12)
|
||||
* Version 1.2 (2010-12-08)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -63,6 +63,10 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
|
|||
private Hashtable<String, String> anchorCombinedStyleNames = new Hashtable<String, String>();
|
||||
private Hashtable<String, String> orgAnchorStyleNames = new Hashtable<String, String>();
|
||||
private Hashtable<String, String> orgAnchorVisitedStyleNames = new Hashtable<String, String>();
|
||||
|
||||
// Export font sizes as percentages?
|
||||
private boolean bRelativeFontSize = false;
|
||||
private String sBaseFontSize = "12pt";
|
||||
|
||||
/** Create a new <code>TextStyleConverter</code>
|
||||
* @param ofr an <code>OfficeReader</code> to read style information from
|
||||
|
@ -75,6 +79,14 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
|
|||
this.styleMap = config.getXTextStyleMap();
|
||||
this.bConvertStyles = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD;
|
||||
this.bConvertHard = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_STYLES;
|
||||
this.bRelativeFontSize = converter.isOPS() && config.xhtmlConvertToPx();
|
||||
StyleWithProperties defaultStyle = ofr.getDefaultParStyle();
|
||||
if (defaultStyle!=null) {
|
||||
String sFontSize = defaultStyle.getProperty(XMLString.FO_FONT_SIZE,false);
|
||||
if (sFontSize!=null) {
|
||||
sBaseFontSize = sFontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Apply a link style, using a combination of two text styles
|
||||
|
@ -298,14 +310,30 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
|
|||
else { // one value
|
||||
s3 = s2; s4="100%";
|
||||
}
|
||||
if (s!=null) { props.addValue("font-size",Misc.multiply(s4,scale(s))); }
|
||||
else { props.addValue("font-size",s4); }
|
||||
if (s!=null) {
|
||||
if (bRelativeFontSize) {
|
||||
String sFontSize = Misc.divide(Misc.multiply(s4,s), sBaseFontSize);
|
||||
if (!"100%".equals(sFontSize)) props.addValue("font-size", sFontSize);
|
||||
}
|
||||
else {
|
||||
props.addValue("font-size",Misc.multiply(s4,scale(s)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
props.addValue("font-size",s4);
|
||||
}
|
||||
if (!"0%".equals(s3)) {
|
||||
props.addValue("vertical-align",s3);
|
||||
}
|
||||
}
|
||||
else if (s!=null) {
|
||||
props.addValue("font-size",scale(s));
|
||||
if (bRelativeFontSize) {
|
||||
String sFontSize = Misc.divide(s,sBaseFontSize);
|
||||
if (!"100%".equals(sFontSize)) props.addValue("font-size", sFontSize);
|
||||
}
|
||||
else {
|
||||
props.addValue("font-size",scale(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-11-22)
|
||||
* Version 1.2 (2010-11-28)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
|
|||
|
||||
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||
// Implement configuration methods
|
||||
protected int getOptionCount() { return 46; }
|
||||
protected int getOptionCount() { return 47; }
|
||||
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
||||
|
||||
// Override setOption: To be backwards compatible, we must accept options
|
||||
|
@ -70,7 +70,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public static final int CSS1_HACK = 1;
|
||||
public static final int HARD_LABELS = 2;
|
||||
|
||||
// Formulas (for xhtml 1.0 strict)
|
||||
// Formulas (for XHTML 1.0 strict)
|
||||
public static final int STARMATH = 0;
|
||||
public static final int LATEX = 1;
|
||||
public static final int IMAGE_STARMATH = 2;
|
||||
|
@ -113,22 +113,23 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int TABSTOP_STYLE = 27;
|
||||
private static final int FORMULAS = 28;
|
||||
private static final int ENDNOTES_HEADING = 29;
|
||||
private static final int SPLIT_LEVEL = 30;
|
||||
private static final int REPEAT_LEVELS = 31;
|
||||
private static final int PAGE_BREAK_SPLIT = 32;
|
||||
private static final int CALC_SPLIT = 33;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 34;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 35;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 36;
|
||||
private static final int APPLY_PRINT_RANGES = 37;
|
||||
private static final int USE_TITLE_AS_HEADING = 38;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 39;
|
||||
private static final int XSLT_PATH = 40;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 41;
|
||||
private static final int UPLINK = 42;
|
||||
private static final int DIRECTORY_ICON = 43;
|
||||
private static final int DOCUMENT_ICON = 44;
|
||||
private static final int ZEN_HACK = 45; // temporary hack for ePub Zen Garden styles
|
||||
private static final int EXTERNAL_TOC_DEPTH = 30;
|
||||
private static final int SPLIT_LEVEL = 31;
|
||||
private static final int REPEAT_LEVELS = 32;
|
||||
private static final int PAGE_BREAK_SPLIT = 33;
|
||||
private static final int CALC_SPLIT = 34;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 35;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 36;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 37;
|
||||
private static final int APPLY_PRINT_RANGES = 38;
|
||||
private static final int USE_TITLE_AS_HEADING = 39;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 40;
|
||||
private static final int XSLT_PATH = 41;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 42;
|
||||
private static final int UPLINK = 43;
|
||||
private static final int DIRECTORY_ICON = 44;
|
||||
private static final int DOCUMENT_ICON = 45;
|
||||
private static final int ZEN_HACK = 46; // temporary hack for ePub Zen Garden styles
|
||||
|
||||
protected ComplexOption xheading = addComplexOption("heading-map");
|
||||
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
||||
|
@ -185,6 +186,17 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
else { nValue = IMAGE_STARMATH; }
|
||||
}
|
||||
};
|
||||
options[EXTERNAL_TOC_DEPTH] = new IntegerOption("external_toc_depth","auto") {
|
||||
@Override public void setString(String sValue) {
|
||||
super.setString(sValue);
|
||||
if ("auto".equals(sValue)) {
|
||||
nValue = 0;
|
||||
}
|
||||
else {
|
||||
nValue = Misc.getPosInteger(sValue,1);
|
||||
}
|
||||
}
|
||||
};
|
||||
options[SPLIT_LEVEL] = new IntegerOption("split_level","0") {
|
||||
@Override public void setString(String sValue) {
|
||||
super.setString(sValue);
|
||||
|
@ -319,6 +331,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public String getXhtmlTabstopStyle() { return options[TABSTOP_STYLE].getString(); }
|
||||
public String getEndnotesHeading() { return options[ENDNOTES_HEADING].getString(); }
|
||||
public int formulas() { return ((IntegerOption) options[FORMULAS]).getValue(); }
|
||||
public int externalTocDepth() { return ((IntegerOption) options[EXTERNAL_TOC_DEPTH]).getValue(); }
|
||||
public int getXhtmlSplitLevel() { return ((IntegerOption) options[SPLIT_LEVEL]).getValue(); }
|
||||
public int getXhtmlRepeatLevels() { return ((IntegerOption) options[REPEAT_LEVELS]).getValue(); }
|
||||
public int pageBreakSplit() { return ((IntegerOption) options[PAGE_BREAK_SPLIT]).getValue(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue