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

@ -1,11 +1,12 @@
Changelog for Writer2LaTeX version 1.0 -> 1.2
TODO: Problem med genkendelse af display formler i w2l??
---------- version 1.1.3 ----------
[w2x] New option "use_hard_list_numbering". If this option is set to true (default is false), list labels are exported as
part of the text rather than by style. This allows for full support of list numbering.
[w2x] New style map "heading" to map styles applied to headings to custom styles.
[w2x] The option "use_list_hack" has been renamed to "list_formatting" with the new values "css1", "css1_hack" and "hard_labels".
The two first values corresponds to "false" and "true" of the old option. The new value requests that
list labels are exported as part of the text rather than by style. This allows for full support of list numbering.
[w2x] Now includes a space after the list label if the list style defines that the label is followed by a tab or a space

Binary file not shown.

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-04)
* Version 1.2 (2010-05-06)
*
*/
@ -237,30 +237,32 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
}
private class Styles1Handler extends StylesPageHandler {
private final String[] sXhtmlFamilyNames = { "text", "paragraph", "list", "frame" };
private final String[] sXhtmlOOoFamilyNames = { "CharacterStyles", "ParagraphStyles", "NumberingStyles", "FrameStyles" };
private final String[] sXhtmlFamilyNames = { "text", "paragraph", "heading", "list", "frame" };
private final String[] sXhtmlOOoFamilyNames = { "CharacterStyles", "ParagraphStyles", "ParagraphStyles", "NumberingStyles", "FrameStyles" };
private final String[] sParElements = { "p", "h1", "h2", "h3", "h4", "h5", "h6", "address", "dd", "dt", "pre" };
private final String[] sParBlockElements = { "div", "blockquote", "dl" };
private final String[] sEmpty = { };
private String[][] sElements = new String[4][];
private String[][] sBlockElements = new String[4][];
private String[][] sElements = new String[5][];
private String[][] sBlockElements = new String[5][];
protected Styles1Handler() {
super(4);
super(5);
sFamilyNames = sXhtmlFamilyNames;
sOOoFamilyNames = sXhtmlOOoFamilyNames;
sElements[0] = sCharElements;
sElements[1] = sParElements;
sElements[2] = sEmpty;
sElements[2] = sParElements;
sElements[3] = sEmpty;
sElements[4] = sEmpty;
sBlockElements[0] = sEmpty;
sBlockElements[1] = sParBlockElements;
sBlockElements[2] = sEmpty;
sBlockElements[2] = sParBlockElements;
sBlockElements[3] = sEmpty;
sBlockElements[4] = sEmpty;
}
protected String getDefaultConfigName() {
@ -272,7 +274,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
if (!attr.containsKey("css")) { attr.put("css", ""); }
dlg.setComboBoxText("Element", attr.get("element"));
dlg.setTextFieldText("Css", none2empty(attr.get("css")));
if (nCurrentFamily==1) {
if (nCurrentFamily==1 || nCurrentFamily==2) {
if (!attr.containsKey("block-element")) { attr.put("block-element", ""); }
if (!attr.containsKey("block-css")) { attr.put("block-css", ""); }
dlg.setComboBoxText("BlockElement", attr.get("block-element"));
@ -287,7 +289,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
protected void getControls(DialogAccess dlg, Map<String,String> attr) {
attr.put("element", dlg.getComboBoxText("Element"));
attr.put("css", empty2none(dlg.getTextFieldText("Css")));
if (nCurrentFamily==1) {
if (nCurrentFamily==1 || nCurrentFamily==2) {
attr.put("block-element", dlg.getComboBoxText("BlockElement"));
attr.put("block-css", empty2none(dlg.getTextFieldText("BlockCss")));
}
@ -303,9 +305,9 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
protected void prepareControls(DialogAccess dlg) {
dlg.setListBoxStringItemList("Element", sElements[nCurrentFamily]);
dlg.setListBoxStringItemList("BlockElement", sBlockElements[nCurrentFamily]);
dlg.setControlEnabled("Element", nCurrentFamily<=1);
dlg.setControlEnabled("BlockElement", nCurrentFamily==1);
dlg.setControlEnabled("BlockCss", nCurrentFamily==1);
dlg.setControlEnabled("Element", nCurrentFamily<=2);
dlg.setControlEnabled("BlockElement", nCurrentFamily==1 || nCurrentFamily==2);
dlg.setControlEnabled("BlockCss", nCurrentFamily==1 || nCurrentFamily==2);
}
}
@ -349,6 +351,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
private class FormattingHandler extends PageHandler {
private final String[] sExportValues = { "convert_all", "ignore_styles", "ignore_hard", "ignore_all" };
private final String[] sListExportValues = { "css1", "css1_hack", "hard_labels" };
@Override protected void setControls(DialogAccess dlg) {
listBoxFromConfig(dlg, "Formatting", "formatting", sExportValues, (short) 0);
@ -363,8 +366,8 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
config.getOption("table_formatting").equals("ignore_styles"));
checkBoxFromConfig(dlg, "IgnoreTableDimensions", "ignore_table_dimensions");
checkBoxFromConfig(dlg, "UseListHack", "use_list_hack");
checkBoxFromConfig(dlg, "UseHardListNumbering", "use_hard_list_numbering");
listBoxFromConfig(dlg, "ListFormatting", "list_formatting", sListExportValues, (short) 0);
//TODO: These have been postponed
//checkBoxFromConfig(dlg, "ConvertToPx", "convert_to_px");
//checkBoxFromConfig(dlg, "SeparateStylesheet", "separate_stylesheet");
@ -378,8 +381,8 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
config.setOption("table_formatting", dlg.getCheckBoxStateAsBoolean("TableFormatting") ? "convert_all" : "ignore_all");
checkBoxToConfig(dlg, "IgnoreTableDimensions", "ignore_table_dimensions");
checkBoxToConfig(dlg, "UseListHack", "use_list_hack");
checkBoxToConfig(dlg, "UseHardListNumbering", "use_hard_list_numbering");
listBoxToConfig(dlg, "ListFormatting", "list_formatting", sListExportValues);
//TODO: These have been postponed
//checkBoxToConfig(dlg, "ConvertToPx", "convert_to_px");
//checkBoxToConfig(dlg, "SeparateStylesheet", "separate_stylesheet");

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-04)
* Version 1.2 (2010-05-09)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.1.3";
private static final String DATE = "2010-05-04";
private static final String DATE = "2010-05-09";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/>

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-04-27)
* Version 1.2 (2010-05-09)
*
*/
@ -58,7 +58,8 @@ public class ListStyle extends OfficeStyle {
}
public boolean isNumber(int i) {
return XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(level[i].getName());
return XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(level[i].getName()) ||
XMLString.TEXT_OUTLINE_LEVEL_STYLE.equals(level[i].getName());
}
public boolean isBullet(int i) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-03-29)
* Version 1.2 (2010-05-09)
*
*/
@ -1022,7 +1022,7 @@ public class OfficeReader {
//collectMasterPage(getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME)));
}
else if (sName.equals(XMLString.TEXT_H)) {
int nLevel = Misc.getPosInteger(node.getAttribute(XMLString.TEXT_LEVEL),1);
int nLevel = Misc.getPosInteger(node.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
StyleWithProperties style = getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME));
//collectMasterPage(style);
if (1<=nLevel && nLevel<=10 && heading[nLevel]==null) {
@ -1030,7 +1030,7 @@ public class OfficeReader {
heading[nLevel] = getParStyle(style.getParentName());
}
else {
heading[nLevel] = null;
heading[nLevel] = style;
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-02-19)
* Version 1.2 (2010-05-09)
*
*/
@ -250,6 +250,7 @@ public class XMLString {
public static final String TEXT_SEQUENCE_DECLS="text:sequence-decls";
public static final String TEXT_SEQUENCE_DECL="text:sequence-decl";
public static final String TEXT_OUTLINE_STYLE="text:outline-style";
public static final String TEXT_OUTLINE_LEVEL_STYLE="text:outline-level-style";
public static final String TEXT_LIST_STYLE="text:list-style";
public static final String TEXT_LIST_LEVEL_STYLE_NUMBER="text:list-level-style-number";
public static final String TEXT_LIST_LEVEL_STYLE_BULLET="text:list-level-style-bullet";

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); }

View file

@ -66,7 +66,7 @@
<dlg:checkbox dlg:id="SplitToplevelSections" dlg:tab-index="20" dlg:left="12" dlg:top="204" dlg:width="160" dlg:height="12" dlg:help-text="&amp;60.LaTeXOptions.SplitToplevelSections.HelpText" dlg:value="&amp;61.LaTeXOptions.SplitToplevelSections.Label" dlg:checked="false" dlg:help-url="org.openoffice.da.writer2latex.oxt:OptionsSplitToplevelSections"/>
<dlg:checkbox dlg:id="SaveImagesInSubdir" dlg:tab-index="21" dlg:left="12" dlg:top="218" dlg:width="149" dlg:height="12" dlg:help-text="&amp;62.LaTeXOptions.SaveImagesInSubdir.HelpText" dlg:value="&amp;63.LaTeXOptions.SaveImagesInSubdir.Label" dlg:checked="false" dlg:help-url="org.openoffice.da.writer2latex.oxt:OptionsSaveImagesInSubdir"/>
<dlg:text dlg:id="SpecialContentLabel" dlg:tab-index="22" dlg:left="186" dlg:top="8" dlg:width="156" dlg:height="12" dlg:help-text="&amp;64.LaTeXOptions.SpecialContentLabel.HelpText" dlg:value="&amp;65.LaTeXOptions.SpecialContentLabel.Label"/>
<dlg:text dlg:id="NotesLabel" dlg:tab-index="23" dlg:left="193" dlg:top="22" dlg:width="47" dlg:height="12" dlg:help-text="&amp;66.LaTeXOptions.NotesLabel.HelpText" dlg:value="&amp;67.LaTeXOptions.NotesLabel.Label"/>
<dlg:text dlg:id="NotesLabel" dlg:tab-index="23" dlg:left="193" dlg:top="22" dlg:width="51" dlg:height="12" dlg:help-text="&amp;66.LaTeXOptions.NotesLabel.HelpText" dlg:value="&amp;67.LaTeXOptions.NotesLabel.Label"/>
<dlg:menulist dlg:id="Notes" dlg:tab-index="24" dlg:left="246" dlg:top="20" dlg:width="96" dlg:height="12" dlg:help-text="&amp;68.LaTeXOptions.Notes.HelpText" dlg:spin="true" dlg:linecount="4" dlg:help-url="org.openoffice.da.writer2latex.oxt:OptionsNotes">
<dlg:menupopup>
<dlg:menuitem dlg:value="&amp;128.Notes.StringItemList"/>

View file

@ -23,9 +23,15 @@
<dlg:checkbox dlg:id="SectionFormatting" dlg:tab-index="4" dlg:left="10" dlg:top="36" dlg:width="240" dlg:height="12" dlg:value="Convert section formatting" dlg:checked="false"/>
<dlg:checkbox dlg:id="TableFormatting" dlg:tab-index="5" dlg:left="10" dlg:top="50" dlg:width="240" dlg:height="12" dlg:value="Convert table formatting" dlg:checked="false"/>
<dlg:checkbox dlg:id="IgnoreTableDimensions" dlg:tab-index="6" dlg:left="10" dlg:top="64" dlg:width="240" dlg:height="12" dlg:value="Ignore table dimensions" dlg:checked="false"/>
<dlg:checkbox dlg:id="UseListHack" dlg:tab-index="7" dlg:left="10" dlg:top="78" dlg:width="240" dlg:height="12" dlg:value="Use non-standard continued lists" dlg:checked="false"/>
<dlg:checkbox dlg:id="UseHardListNumbering" dlg:tab-index="8" dlg:left="10" dlg:top="92" dlg:width="240" dlg:height="12" dlg:value="Use hard list numbering" dlg:checked="false"/>
<dlg:checkbox dlg:id="ConvertToPx" dlg:tab-index="9" dlg:visible="false" dlg:left="10" dlg:top="106" dlg:width="240" dlg:height="12" dlg:value="Convert units to px (pixels)" dlg:checked="false"/>
<dlg:checkbox dlg:id="SeparateStylesheet" dlg:tab-index="10" dlg:visible="false" dlg:left="10" dlg:top="120" dlg:width="240" dlg:height="12" dlg:value="Create separate styles sheet on file split" dlg:checked="false"/>
<dlg:text dlg:id="ListFormattingLabel" dlg:tab-index="7" dlg:left="10" dlg:top="78" dlg:width="110" dlg:height="12" dlg:value="List formatting"/>
<dlg:menulist dlg:id="ListFormatting" dlg:tab-index="8" dlg:left="130" dlg:top="76" dlg:width="120" dlg:height="12" dlg:spin="true" dlg:linecount="3">
<dlg:menupopup>
<dlg:menuitem dlg:value="Use CSS1"/>
<dlg:menuitem dlg:value="Use CSS1 and non-standard lists"/>
<dlg:menuitem dlg:value="Use hard labels"/>
</dlg:menupopup>
</dlg:menulist>
<dlg:checkbox dlg:id="ConvertToPx" dlg:tab-index="9" dlg:visible="false" dlg:left="10" dlg:top="92" dlg:width="240" dlg:height="12" dlg:value="Convert units to px (pixels)" dlg:checked="false"/>
<dlg:checkbox dlg:id="SeparateStylesheet" dlg:tab-index="10" dlg:visible="false" dlg:left="10" dlg:top="106" dlg:width="240" dlg:height="12" dlg:value="Create separate styles sheet on file split" dlg:checked="false"/>
</dlg:bulletinboard>
</dlg:window>

View file

@ -4,10 +4,11 @@
<dlg:bulletinboard>
<dlg:text dlg:id="StyleMappingsLabel" dlg:tab-index="0" dlg:left="5" dlg:top="8" dlg:width="245" dlg:height="12" dlg:value="Style mappings"/>
<dlg:text dlg:id="StyleFamilyLabel" dlg:tab-index="1" dlg:left="10" dlg:top="22" dlg:width="60" dlg:height="12" dlg:value="Style family"/>
<dlg:menulist dlg:id="StyleFamily" dlg:tab-index="2" dlg:left="80" dlg:top="20" dlg:width="170" dlg:height="12" dlg:spin="true">
<dlg:menulist dlg:id="StyleFamily" dlg:tab-index="2" dlg:left="80" dlg:top="20" dlg:width="170" dlg:height="12" dlg:spin="true" dlg:linecount="5">
<dlg:menupopup>
<dlg:menuitem dlg:value="Character"/>
<dlg:menuitem dlg:value="Paragraph"/>
<dlg:menuitem dlg:value="Heading"/>
<dlg:menuitem dlg:value="List"/>
<dlg:menuitem dlg:value="Frame"/>
</dlg:menupopup>