Writer2xhtml: Some work on lists and headings

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@62 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2010-05-09 13:40:00 +00:00
parent 54a7c265f2
commit d7f1b41599
18 changed files with 295 additions and 145 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-04-23)
* Version 1.2 (2010-05-09)
*
*/
@ -40,7 +40,6 @@ import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import writer2latex.api.Config;

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2008 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.0 (2008-09-08)
* Version 1.2 (2010-05-09)
*
*/
@ -41,6 +41,8 @@ public class ConverterHelper {
protected ParStyleConverter getParSc() { return converter.getStyleCv().getParSc(); }
protected HeadingStyleConverter getHeadingSc() { return converter.getStyleCv().getHeadingSc(); }
protected ListStyleConverter getListSc() { return converter.getStyleCv().getListSc(); }
protected SectionStyleConverter getSectionSc() { return converter.getStyleCv().getSectionSc(); }

View file

@ -0,0 +1,125 @@
/************************************************************************
*
* HeadingStyleConverter.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-09)
*
*/package writer2latex.xhtml;
import writer2latex.office.OfficeReader;
import writer2latex.office.OfficeStyleFamily;
import writer2latex.office.StyleWithProperties;
import writer2latex.util.CSVList;
public class HeadingStyleConverter extends StyleConverterHelper {
public HeadingStyleConverter(OfficeReader ofr, XhtmlConfig config,
Converter converter, int nType) {
super(ofr, config, converter, nType);
this.styleMap = config.getXHeadingStyleMap();
this.bConvertStyles = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD;
this.bConvertHard = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_STYLES;
}
@Override
public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) {
StringBuffer buf = new StringBuffer();
for (int i=1; i<=6; i++) {
if (ofr.getHeadingStyle(i)!=null) {
CSVList props = new CSVList(";");
getParSc().applyProperties(ofr.getHeadingStyle(i),props,true);
props.addValue("clear","left");
buf.append(sIndent).append("h").append(i)
.append(" {").append(props.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
}
}
return buf.toString();
}
return "";
}
@Override
public OfficeStyleFamily getStyles() {
return ofr.getParStyles();
}
/** Apply a style on a heading
*
* @param nLevel the heading level
* @param sStyleName the style name
* @param info add style information to this StyleInfo
*/
public void applyStyle(int nLevel, String sStyleName, StyleInfo info) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
if (style!=null) {
if (config.multilingual()) { applyLang(style,info); }
applyDirection(style,info);
if (style.isAutomatic()) {
// Apply parent style + hard formatting
applyStyle(nLevel, style.getParentName(),info);
if (bConvertHard) { getParSc().applyProperties(style,info.props,false); }
}
else {
String sDisplayName = style.getDisplayName();
if (styleMap.contains(sDisplayName)) {
// Apply attributes as specified in style map from user
info.sTagName = styleMap.getBlockElement(sDisplayName);
if (!"(none)".equals(styleMap.getBlockCss(sDisplayName))) {
info.sClass = styleMap.getBlockCss(sDisplayName);
}
}
else {
// TODO: Apply style if different from main style for this level
}
}
}
}
/** Apply an inner style on a heading. The inner style surrounds the text content, excluding the numbering label.
* Inner styles are not an OpenDocument feature, but is provided as an additional style hook for own style sheets.
* An inner style is only applied if there is an explicit style map for the style.
*
* @param nLevel the heading level
* @param sStyleName the style name
* @param info add style information to this StyleInfo
*/
public void applyInnerStyle(int nLevel, String sStyleName, StyleInfo info) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
if (style!=null) {
if (style.isAutomatic()) {
// Apply parent style
applyInnerStyle(nLevel, style.getParentName(), info);
}
else {
String sDisplayName = style.getDisplayName();
if (styleMap.contains(sDisplayName)) {
// Apply attributes as specified in style map from user
info.sTagName = styleMap.getElement(sDisplayName);
if (!"(none)".equals(styleMap.getCss(sDisplayName))) {
info.sClass = styleMap.getCss(sDisplayName);
}
}
}
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-04)
* Version 1.2 (2010-05-05)
*
*/
@ -102,7 +102,7 @@ public class ListStyleConverter extends StyleConverterHelper {
buf.append(props.toString());
buf.append("}");
buf.append(config.prettyPrint() ? "\n" : " ");
if (config.useHardListNumbering()) {
if (config.listFormatting()==XhtmlConfig.HARD_LABELS) {
// Apply left margin and text indent to the paragraphs contained in the list
CSVList parProps = new CSVList(";");
cssListParMargins(style,nLevel,parProps);
@ -137,7 +137,7 @@ public class ListStyleConverter extends StyleConverterHelper {
// so we will stick with the simpler CSS1-like list style properties
props.addValue("margin-top","0");
props.addValue("margin-bottom","0");
if (!config.useHardListNumbering()) {
if (config.listFormatting()!=XhtmlConfig.HARD_LABELS) {
// Export the numbering to CSS1
String sLevelType = style.getLevelType(nLevel);
if (XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(sLevelType)) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-03-01)
* Version 1.2 (2010-05-09)
*
*/
@ -38,23 +38,19 @@ import writer2latex.util.CSVList;
pseudo-element or to an additional inline element.
*/
/**
* This class converts OpenDocument paragraph styles to CSS2 styles for
* use in paragraphs and headings.
* use in ordinary paragraphs.
* This also includes conversion of paragraph properties in other styles
* (cell styles).
* (heading styles, cell styles).
*/
public class ParStyleConverter extends StyleWithPropertiesConverterHelper {
// Some bookkeeping for headings
private String[] sHeadingStyles = new String[7];
/** Create a new <code>ParStyleConverter</code>
* @param ofr an <code>OfficeReader</code> to read style information from
* @param config the configuration to use
* @param converter the main <code>Converter</code> class
* @param nType the type of xhtml to use
* @param nType the type of XHTML to use
*/
public ParStyleConverter(OfficeReader ofr, XhtmlConfig config, Converter converter, int nType) {
super(ofr,config,converter,nType);
@ -63,37 +59,6 @@ public class ParStyleConverter extends StyleWithPropertiesConverterHelper {
this.bConvertHard = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_STYLES;
}
// TODO: Remove me, OfficeReader takes care of this
public void setHeadingStyle(int nLevel, String sStyleName) {
if (sHeadingStyles[nLevel]==null) {
sHeadingStyles[nLevel] = sStyleName;
}
}
/** Convert style information for used styles
* @param sIndent a String of spaces to add before each line
*/
public String getStyleDeclarations(String sIndent) {
StringBuffer buf = new StringBuffer();
buf.append(super.getStyleDeclarations(sIndent));
if (bConvertStyles) {
// Styles for headings
for (int i=1; i<=6; i++) {
if (sHeadingStyles[i]!=null) {
StyleWithProperties style = ofr.getParStyle(sHeadingStyles[i]);
if (style!=null) {
CSVList props = new CSVList(";");
applyProperties(style,props,true);
props.addValue("clear","left");
buf.append(sIndent).append("h").append(i)
.append(" {").append(props.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
}
}
}
}
return buf.toString();
}
/** Get the family of paragraph styles
* @return the style family
*/

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-02-27)
* Version 1.2 (2010-05-09)
*
*/
@ -49,6 +49,7 @@ class StyleConverter extends ConverterHelper {
// Helpers for text styles
private TextStyleConverter textSc;
private ParStyleConverter parSc;
private HeadingStyleConverter headingSc;
private ListStyleConverter listSc;
private SectionStyleConverter sectionSc;
@ -71,6 +72,7 @@ class StyleConverter extends ConverterHelper {
// Create the helpers
textSc = new TextStyleConverter(ofr,config,converter,nType);
parSc = new ParStyleConverter(ofr,config,converter,nType);
headingSc = new HeadingStyleConverter(ofr,config,converter,nType);
listSc = new ListStyleConverter(ofr,config,converter,nType);
sectionSc = new SectionStyleConverter(ofr,config,converter,nType);
tableSc = new TableStyleConverter(ofr,config,converter,nType);
@ -86,6 +88,8 @@ class StyleConverter extends ConverterHelper {
protected ParStyleConverter getParSc() { return parSc; }
protected HeadingStyleConverter getHeadingSc() { return headingSc; }
protected ListStyleConverter getListSc() { return listSc; }
protected SectionStyleConverter getSectionSc() { return sectionSc; }
@ -147,6 +151,7 @@ class StyleConverter extends ConverterHelper {
// Presentation documents: frame, presentation, page
buf.append(getTextSc().getStyleDeclarations(sIndent));
buf.append(getParSc().getStyleDeclarations(sIndent));
buf.append(getHeadingSc().getStyleDeclarations(sIndent));
buf.append(getListSc().getStyleDeclarations(sIndent));
buf.append(getSectionSc().getStyleDeclarations(sIndent));
buf.append(getCellSc().getStyleDeclarations(sIndent));

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-04)
* Version 1.2 (2010-05-09)
*
*/
@ -396,7 +396,7 @@ public class TextConverter extends ConverterHelper {
int nOutlineLevel = getOutlineLevel((Element)child);
Node rememberNode = hnode;
hnode = maybeSplit(hnode,nOutlineLevel,bAfterHeading);
handleHeading(child,hnode,rememberNode!=hnode);
handleHeading((Element)child,hnode,rememberNode!=hnode);
}
else if (nodeName.equals(XMLString.TEXT_LIST) || // oasis
nodeName.equals(XMLString.TEXT_UNORDERED_LIST) || // old
@ -498,7 +498,7 @@ public class TextConverter extends ConverterHelper {
return newhnode.getParentNode();
}
private void handleHeading(Node onode, Node hnode, boolean bAfterSplit) {
private void handleHeading(Element onode, Node hnode, boolean bAfterSplit) {
int nListLevel = getOutlineLevel((Element)onode);
boolean bUnNumbered = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_IS_LIST_HEADER));
boolean bRestart = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_RESTART_NUMBERING));
@ -510,9 +510,10 @@ public class TextConverter extends ConverterHelper {
/*
* Process a text:h tag
*/
private void handleHeading(Node onode, Node hnode, boolean bAfterSplit,
private void handleHeading(Element onode, Node hnode, boolean bAfterSplit,
ListStyle listStyle, int nListLevel, boolean bUnNumbered,
boolean bRestart, int nStartValue) {
String sStyleName = onode.getAttribute(XMLString.TEXT_STYLE_NAME);
// Note: nListLevel may in theory be different from the outline level,
// though the ui in OOo does not allow this
@ -521,9 +522,9 @@ public class TextConverter extends ConverterHelper {
// TODO: Offer CSS2 solution as an alternative later.
// Note: Conditional styles are not supported
int nLevel = getOutlineLevel((Element)onode);
int nLevel = getOutlineLevel(onode);
if (nLevel<=6) {
if (nLevel==1) { currentChapter = (Element) onode; }
if (nLevel==1) { currentChapter = onode; }
// If split output, add headings of higher levels
if (bAfterSplit && nSplit>0) {
int nFirst = nLevel-nRepeatLevels;
@ -534,22 +535,26 @@ public class TextConverter extends ConverterHelper {
}
}
}
// Apply style
StyleInfo info = new StyleInfo();
info.sTagName = "h"+nLevel;
getHeadingSc().applyStyle(nLevel, sStyleName, info);
// add Hx element
Element heading = converter.createElement("h"+nLevel);
traverseFloats(onode,hnode,heading);
// add root element
Element heading = converter.createElement(info.sTagName);
hnode.appendChild(heading);
applyStyle(info,heading);
traverseFloats(onode,hnode,heading);
// Apply writing direction
String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
/*String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
StyleWithProperties style = ofr.getParStyle(sStyleName);
if (style!=null) {
StyleInfo headInfo = new StyleInfo();
StyleConverterHelper.applyDirection(style,headInfo);
getParSc().applyStyle(headInfo,heading);
}
}*/
getParSc().setHeadingStyle(nLevel,sStyleName);
// Prepend asapNode
prependAsapNode(heading);
@ -573,7 +578,7 @@ public class TextConverter extends ConverterHelper {
// Add to real toc
TocEntry entry = new TocEntry();
entry.onode = (Element) onode;
entry.onode = onode;
entry.sLabel = sLabel;
entry.nFileIndex = converter.getOutFileIndex();
entry.nOutlineLevel = nLevel;
@ -581,7 +586,16 @@ public class TextConverter extends ConverterHelper {
tocEntries.add(entry);
}
traverseInlineText(onode,heading);
// Convert content
StyleInfo innerInfo = new StyleInfo();
getHeadingSc().applyInnerStyle(nLevel, sStyleName, innerInfo);
Element content = heading;
if (innerInfo.sTagName!=null && innerInfo.sTagName.length()>0) {
content = converter.createElement(innerInfo.sTagName);
heading.appendChild(content);
applyStyle(innerInfo, content);
}
traverseInlineText(onode,content);
// Keep track of current headings for split output
currentHeading[nLevel] = heading;
@ -627,7 +641,7 @@ public class TextConverter extends ConverterHelper {
if (!bIsEmpty) {
par = createTextBackground(par, sStyleName);
if (config.useHardListNumbering()) {
if (config.listFormatting()==XhtmlConfig.HARD_LABELS) {
insertListLabel(currentListStyle, nCurrentListLevel, "ItemNumber", sCurrentListLabel, par);
}
sCurrentListLabel = null;
@ -682,16 +696,19 @@ public class TextConverter extends ConverterHelper {
// Helper: Insert a list label formatted with a list style
private void insertListLabel(ListStyle style, int nLevel, String sDefaultStyle, String sLabel, Element hnode) {
if (sLabel!=null && sLabel.length()>0) {
Element span = converter.createElement("span");
StyleInfo info = new StyleInfo();
info.sClass = sDefaultStyle;
if (style!=null) {
String sTextStyleName = style.getLevelProperty(nLevel,XMLString.TEXT_STYLE_NAME);
getTextSc().applyStyle(sTextStyleName, info);
}
getTextSc().applyStyle(info, span);
hnode.appendChild(span);
span.appendChild( converter.createTextNode(sLabel) );
if (info.sTagName==null) { info.sTagName = "span"; }
if (info.sClass==null) { info.sClass = sDefaultStyle; }
Element content = converter.createElement(info.sTagName);
getTextSc().applyStyle(info, content);
hnode.appendChild(content);
content.appendChild( converter.createTextNode(sLabel) );
}
}
@ -775,7 +792,7 @@ public class TextConverter extends ConverterHelper {
if (!bContinueNumbering && counter!=null) {
counter.restart(nLevel);
}
if (config.xhtmlUseListHack() && !config.useHardListNumbering() && counter.getValue(nLevel)>0) {
if (config.listFormatting()==XhtmlConfig.CSS1_HACK && counter.getValue(nLevel)>0) {
hnode.setAttribute("start",Integer.toString(counter.getValue(nLevel)+1));
}
}
@ -800,7 +817,7 @@ public class TextConverter extends ConverterHelper {
bIsImmediateNestedList = true;
}
if (config.xhtmlUseListHack() && bIsImmediateNestedList) {
if (config.listFormatting()==XhtmlConfig.CSS1_HACK && bIsImmediateNestedList) {
traverseListItem(child,nLevel,styleName,hnode);
}
else {
@ -813,7 +830,7 @@ public class TextConverter extends ConverterHelper {
getPresentationSc().applyOutlineStyle(nLevel,info);
applyStyle(info,item);
hnode.appendChild(item);
if (config.xhtmlUseListHack() && !config.useHardListNumbering()) {
if (config.listFormatting()==XhtmlConfig.CSS1_HACK) {
boolean bRestart = "true".equals(Misc.getAttribute(child,
XMLString.TEXT_RESTART_NUMBERING));
int nStartValue = Misc.getPosInteger(Misc.getAttribute(child,
@ -1001,7 +1018,7 @@ public class TextConverter extends ConverterHelper {
int nOutlineLevel = getOutlineLevel((Element)onode);
Node rememberNode = hnode;
hnode = maybeSplit(hnode,nOutlineLevel,bAfterHeading);
handleHeading(child, hnode, rememberNode!=hnode,
handleHeading((Element)child, hnode, rememberNode!=hnode,
ofr.getListStyle(sStyleName), nLevel,
bUnNumbered, bRestart, nStartValue);
nDontSplitLevel--;

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-04)
* Version 1.2 (2010-05-09)
*
*/
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
public class XhtmlConfig extends writer2latex.base.ConfigBase {
// Implement configuration methods
protected int getOptionCount() { return 43; }
protected int getOptionCount() { return 42; }
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
// Override setOption: To be backwards compatible, we must accept options
@ -50,6 +50,12 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
if (sName.startsWith("xhtml_")) { sName = sName.substring(6); }
// this option has been renamed:
if (sName.equals("keep_image_size")) { sName = "original_image_size"; }
// this option has been renamed and extended:
if (sName.equals("use_list_hack")) {
sName = "list_formatting";
if (sValue.equals("true")) { sValue = "css1_hack"; }
else { sValue = "css1"; }
}
super.setOption(sName, sValue);
}
@ -59,12 +65,17 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
public static final int IGNORE_HARD = 2;
public static final int CONVERT_ALL = 3;
// List formatting
public static final int CSS1 = 0;
public static final int CSS1_HACK = 1;
public static final int HARD_LABELS = 2;
// 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;
public static final int IMAGE_LATEX = 3;
// Options
private static final int IGNORE_HARD_LINE_BREAKS = 0;
private static final int IGNORE_EMPTY_PARAGRAPHS = 1;
@ -85,31 +96,31 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
private static final int SECTION_FORMATTING = 16;
private static final int TABLE_FORMATTING = 17;
private static final int IGNORE_TABLE_DIMENSIONS = 18;
private static final int USE_DUBLIN_CORE = 19;
private static final int NOTES = 20;
private static final int CONVERT_TO_PX = 21;
private static final int SCALING = 22;
private static final int COLUMN_SCALING = 23;
private static final int FLOAT_OBJECTS = 24;
private static final int TABSTOP_STYLE = 25;
private static final int USE_LIST_HACK = 26;
private static final int USE_HARD_LIST_NUMBERING = 27;
private static final int FORMULAS = 28;
private static final int SPLIT_LEVEL = 29;
private static final int REPEAT_LEVELS = 30;
private static final int CALC_SPLIT = 31;
private static final int DISPLAY_HIDDEN_SHEETS = 32;
private static final int DISPLAY_HIDDEN_ROWS_COLS = 33;
private static final int DISPLAY_FILTERED_ROWS_COLS = 34;
private static final int APPLY_PRINT_RANGES = 35;
private static final int USE_TITLE_AS_HEADING = 36;
private static final int USE_SHEET_NAMES_AS_HEADINGS = 37;
private static final int XSLT_PATH = 38;
private static final int SAVE_IMAGES_IN_SUBDIR = 39;
private static final int UPLINK = 40;
private static final int DIRECTORY_ICON = 41;
private static final int DOCUMENT_ICON = 42;
private static final int LIST_FORMATTING = 19;
private static final int USE_DUBLIN_CORE = 20;
private static final int NOTES = 21;
private static final int CONVERT_TO_PX = 22;
private static final int SCALING = 23;
private static final int COLUMN_SCALING = 24;
private static final int FLOAT_OBJECTS = 25;
private static final int TABSTOP_STYLE = 26;
private static final int FORMULAS = 27;
private static final int SPLIT_LEVEL = 28;
private static final int REPEAT_LEVELS = 29;
private static final int CALC_SPLIT = 30;
private static final int DISPLAY_HIDDEN_SHEETS = 31;
private static final int DISPLAY_HIDDEN_ROWS_COLS = 32;
private static final int DISPLAY_FILTERED_ROWS_COLS = 33;
private static final int APPLY_PRINT_RANGES = 34;
private static final int USE_TITLE_AS_HEADING = 35;
private static final int USE_SHEET_NAMES_AS_HEADINGS = 36;
private static final int XSLT_PATH = 37;
private static final int SAVE_IMAGES_IN_SUBDIR = 38;
private static final int UPLINK = 39;
private static final int DIRECTORY_ICON = 40;
private static final int DOCUMENT_ICON = 41;
protected ComplexOption xheading = addComplexOption("heading-map");
protected ComplexOption xpar = addComplexOption("paragraph-map");
protected ComplexOption xtext = addComplexOption("text-map");
protected ComplexOption xframe = addComplexOption("frame-map");
@ -138,6 +149,14 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
options[SECTION_FORMATTING] = new XhtmlFormatOption("section_formatting","convert_all");
options[TABLE_FORMATTING] = new XhtmlFormatOption("table_formatting","convert_all");
options[IGNORE_TABLE_DIMENSIONS] = new BooleanOption("ignore_table_dimensions","false");
options[LIST_FORMATTING] = new IntegerOption("list_formatting","css1") {
@Override public void setString(String sValue) {
super.setString(sValue);
if ("css1_hack".equals(sValue)) { nValue = CSS1_HACK; }
else if ("hard_labels".equals(sValue)) { nValue = HARD_LABELS; }
else { nValue = CSS1; }
}
};
options[USE_DUBLIN_CORE] = new BooleanOption("use_dublin_core","true");
options[NOTES] = new BooleanOption("notes","true");
options[CONVERT_TO_PX] = new BooleanOption("convert_to_px","true");
@ -145,10 +164,8 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
options[COLUMN_SCALING] = new Option("column_scaling","100%");
options[FLOAT_OBJECTS] = new BooleanOption("float_objects","true");
options[TABSTOP_STYLE] = new Option("tabstop_style","");
options[USE_LIST_HACK] = new BooleanOption("use_list_hack","false");
options[USE_HARD_LIST_NUMBERING] = new BooleanOption("use_hard_list_numbering","false");
options[FORMULAS] = new IntegerOption("formulas","starmath") {
public void setString(String sValue) {
@Override public void setString(String sValue) {
super.setString(sValue);
if ("latex".equals(sValue)) { nValue = LATEX; }
else if ("image+latex".equals(sValue)) { nValue = IMAGE_LATEX; }
@ -157,13 +174,13 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
}
};
options[SPLIT_LEVEL] = new IntegerOption("split_level","0") {
public void setString(String sValue) {
@Override public void setString(String sValue) {
super.setString(sValue);
nValue = Misc.getPosInteger(sValue,0);
}
};
options[REPEAT_LEVELS] = new IntegerOption("repeat_levels","5") {
public void setString(String sValue) {
@Override public void setString(String sValue) {
super.setString(sValue);
nValue = Misc.getPosInteger(sValue,0);
}
@ -195,10 +212,16 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
Map<String,String> attr = new HashMap<String,String>();
attr.put("element", sElement);
attr.put("css", sCss);
String sBlockElement = elm.getAttribute("block-element");
String sBlockCss = elm.getAttribute("block-css");
if (sBlockCss.length()==0) { sBlockCss="(none)"; }
if ("heading".equals(sFamily)) {
attr.put("block-element", sBlockElement);
attr.put("block-css", sBlockCss);
xheading.put(sName,attr);
}
if ("paragraph".equals(sFamily)) {
String sBlockElement = elm.getAttribute("block-element");
String sBlockCss = elm.getAttribute("block-css");
if (sBlockCss.length()==0) { sBlockCss="(none)"; }
attr.put("block-element", sBlockElement);
attr.put("block-css", sBlockCss);
xpar.put(sName,attr);
@ -219,6 +242,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
}
protected void writeInner(Document dom) {
writeXStyleMap(dom,xheading,"heading");
writeXStyleMap(dom,xpar,"paragraph");
writeXStyleMap(dom,xtext,"text");
writeXStyleMap(dom,xlist,"list");
@ -262,6 +286,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
public int xhtmlSectionFormatting() { return ((XhtmlFormatOption) options[SECTION_FORMATTING]).getValue(); }
public int xhtmlTableFormatting() { return ((XhtmlFormatOption) options[TABLE_FORMATTING]).getValue(); }
public boolean xhtmlIgnoreTableDimensions() { return ((BooleanOption) options[IGNORE_TABLE_DIMENSIONS]).getValue(); }
public int listFormatting() { return ((IntegerOption) options[LIST_FORMATTING]).getValue(); }
public boolean xhtmlUseDublinCore() { return ((BooleanOption) options[USE_DUBLIN_CORE]).getValue(); }
public boolean xhtmlNotes() { return ((BooleanOption) options[NOTES]).getValue(); }
public boolean xhtmlConvertToPx() { return ((BooleanOption) options[CONVERT_TO_PX]).getValue(); }
@ -269,8 +294,6 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
public String getXhtmlColumnScaling() { return options[COLUMN_SCALING].getString(); }
public boolean xhtmlFloatObjects() { return ((BooleanOption) options[FLOAT_OBJECTS]).getValue(); }
public String getXhtmlTabstopStyle() { return options[TABSTOP_STYLE].getString(); }
public boolean xhtmlUseListHack() { return ((BooleanOption) options[USE_LIST_HACK]).getValue(); }
public boolean useHardListNumbering() { return ((BooleanOption) options[USE_HARD_LIST_NUMBERING]).getValue(); }
public int formulas() { return ((IntegerOption) options[FORMULAS]).getValue(); }
public int getXhtmlSplitLevel() { return ((IntegerOption) options[SPLIT_LEVEL]).getValue(); }
public int getXhtmlRepeatLevels() { return ((IntegerOption) options[REPEAT_LEVELS]).getValue(); }
@ -288,6 +311,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
public String getXhtmlDocumentIcon() { return options[DOCUMENT_ICON].getString(); }
public XhtmlStyleMap getXParStyleMap() { return getStyleMap(xpar); }
public XhtmlStyleMap getXHeadingStyleMap() { return getStyleMap(xheading); }
public XhtmlStyleMap getXTextStyleMap() { return getStyleMap(xtext); }
public XhtmlStyleMap getXFrameStyleMap() { return getStyleMap(xframe); }
public XhtmlStyleMap getXListStyleMap() { return getStyleMap(xlist); }