diff --git a/src/main/java/writer2latex/xhtml/style/CellStyleParser.java b/src/main/java/writer2latex/xhtml/style/CellStyleParser.java index 5417630..c8d64c9 100644 --- a/src/main/java/writer2latex/xhtml/style/CellStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/CellStyleParser.java @@ -66,7 +66,7 @@ public class CellStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "td"; } diff --git a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java index b102e3e..bb7284b 100644 --- a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java @@ -77,7 +77,7 @@ public class FrameStyleParser extends StyleWithPropertiesParser { getTextSc().cssTextCommon(style, props, true); if (!props.isEmpty()) { buf.append(indent); - buf.append(getDefaultTagName(null)); + buf.append(getStyleTag()); buf.append("."); buf.append(getClassNamePrefix()); buf.append(styleNames.addToExport(sDisplayName)); @@ -110,7 +110,7 @@ public class FrameStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return ""; } diff --git a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java index 2f37b65..53dc03e 100644 --- a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java @@ -110,7 +110,7 @@ public class ListStyleParser extends StyleParser { buf.append(" {"); buf.append(props.toString()); buf.append("}"); - buf.append(config.prettyPrint() ? "\n" : " "); + buf.append(prettyPrint ? "\n" : " "); if (config.listFormatting() == XhtmlConfig.HARD_LABELS) { // Apply left margin and text indent to the paragraphs contained in // the list @@ -124,7 +124,7 @@ public class ListStyleParser extends StyleParser { buf.append(" p {"); buf.append(parProps.toString()); buf.append("}"); - buf.append(config.prettyPrint() ? "\n" : " "); + buf.append(prettyPrint ? "\n" : " "); } } } diff --git a/src/main/java/writer2latex/xhtml/style/ParStyleParser.java b/src/main/java/writer2latex/xhtml/style/ParStyleParser.java index 86c5680..3b47efd 100644 --- a/src/main/java/writer2latex/xhtml/style/ParStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/ParStyleParser.java @@ -71,7 +71,7 @@ public class ParStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "p"; } diff --git a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java index 52b5214..16d1280 100644 --- a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java @@ -79,45 +79,43 @@ public class PresentationStyleParser extends FrameStyleParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "div"; } /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { - if (bConvertStyles) { - StringBuilder buf = new StringBuilder(); - buf.append(super.getStyleSelectors()); - Enumeration names = outlineStyleNames.keys(); - while (names.hasMoreElements()) { - String sDisplayName = names.nextElement(); - StyleWithProperties style = (StyleWithProperties) - getStyles().getStyleByDisplayName(sDisplayName); - if (!style.isAutomatic()) { - // Apply style to paragraphs within a list item with this class - CSVList props = new CSVList(";"); - getFrameSc().cssMargins(style,props,true); - getParSc().cssPar(style,props,true); - getTextSc().cssTextCommon(style,props,true); - if (!props.isEmpty()) { - buf.append(indent); - buf.append("li.outline"); - buf.append(styleNames.addToExport(sDisplayName)); - buf.append(" p {"); - buf.append(props.toString()); - buf.append("}"); - buf.append(config.prettyPrint() ? "\n" : " "); - } - } - } - return buf.toString(); - } - else { - return ""; - } - } + public String getStyleSelectors() { + if (!bConvertStyles) { + return ""; + } + StringBuilder buf = new StringBuilder(); + buf.append(super.getStyleSelectors()); + Enumeration names = outlineStyleNames.keys(); + while (names.hasMoreElements()) { + String sDisplayName = names.nextElement(); + StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName); + if (!style.isAutomatic()) { + // Apply style to paragraphs within a list item with this class + CSVList props = new CSVList(";"); + getFrameSc().cssMargins(style, props, true); + getParSc().cssPar(style, props, true); + getTextSc().cssTextCommon(style, props, true); + if (!props.isEmpty()) { + buf.append(indent); + buf.append("li.outline"); + buf.append(styleNames.addToExport(sDisplayName)); + buf.append(" p {"); + buf.append(props.toString()); + buf.append("}"); + buf.append(config.prettyPrint() ? "\n" : " "); + } + } + } + return buf.toString(); + + } public void enterOutline(String sStyleName) { diff --git a/src/main/java/writer2latex/xhtml/style/RowStyleParser.java b/src/main/java/writer2latex/xhtml/style/RowStyleParser.java index a398968..c9c1d1e 100644 --- a/src/main/java/writer2latex/xhtml/style/RowStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/RowStyleParser.java @@ -66,7 +66,7 @@ public class RowStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "tr"; } diff --git a/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java b/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java index 8728150..6a8bb25 100644 --- a/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java @@ -70,7 +70,7 @@ public class SectionStyleParser extends StyleWithPropertiesParser { * @return the tag name. If the style is null, a default result should be * returned. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "div"; } diff --git a/src/main/java/writer2latex/xhtml/style/StyleParser.java b/src/main/java/writer2latex/xhtml/style/StyleParser.java index 71f9cdc..66a5bc0 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleParser.java @@ -55,8 +55,8 @@ public abstract class StyleParser extends Parser { // The type of xhtml document protected int nType; - private boolean prettyPrint = true; - String indent = null; + protected boolean prettyPrint = true; + protected String indent = null; // Scaling and unit transformation to use private String sScale; private String sColScale; diff --git a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java index 947276c..b921326 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java @@ -61,7 +61,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser { */ public void applyStyle(String sStyleName, StyleInfo info) { StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName); - info.sTagName = getDefaultTagName(style); + info.sTagName = getStyleTag(); if (style!=null) { if (config.multilingual()) { applyLang(style,info); } applyDirection(style,info); @@ -94,36 +94,33 @@ public abstract class StyleWithPropertiesParser extends StyleParser { /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { - if (bConvertStyles) { - StringBuilder buf = new StringBuilder(); - Enumeration names = styleNames.keys(); - while (names.hasMoreElements()) { - String sDisplayName = names.nextElement(); - StyleWithProperties style = (StyleWithProperties) - getStyles().getStyleByDisplayName(sDisplayName); - if (!style.isAutomatic()) { - CSVList props = new CSVList(";"); - applyProperties(style,props,true); - buf.append(indent); - buf.append(getDefaultTagName(null)); - buf.append("."); - buf.append(getClassNamePrefix()); - buf.append(styleNames.addToExport(sDisplayName)); - buf.append(" {"); - buf.append(props.toString()); - buf.append("}"); - buf.append(config.prettyPrint() ? "\n" : " "); - // TODO: Create a method "getStyleDeclarationsInner" - // to be used by eg. FrameStyleConverter - } - } - return buf.toString(); - } - else { - return ""; - } - } + public String getStyleSelectors() { + if (!bConvertStyles) { + return ""; + } + StringBuilder buf = new StringBuilder(); + Enumeration names = styleNames.keys(); + while (names.hasMoreElements()) { + String sDisplayName = names.nextElement(); + StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName); + if (!style.isAutomatic()) { + CSVList props = new CSVList(";"); + applyProperties(style, props, true); + buf.append(indent); + buf.append(getStyleTag()); + buf.append("."); + buf.append(getClassNamePrefix()); + buf.append(styleNames.addToExport(sDisplayName)); + buf.append(" {"); + buf.append(props.toString()); + buf.append("}"); + buf.append(prettyPrint ? "\n" : " "); + // TODO: Create a method "getStyleDeclarationsInner" + // to be used by eg. FrameStyleConverter + } + } + return buf.toString(); + } /** Return a prefix to be used in generated css class names * @return the prefix @@ -136,7 +133,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser { * @return the tag name. If the style is null, a default result should be * returned. */ - public abstract String getDefaultTagName(StyleWithProperties style); + public abstract String getStyleTag(); /** Convert formatting properties for a specific style. * @param style the style to convert diff --git a/src/main/java/writer2latex/xhtml/style/TableStyleParser.java b/src/main/java/writer2latex/xhtml/style/TableStyleParser.java index bcada7d..af81260 100644 --- a/src/main/java/writer2latex/xhtml/style/TableStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/TableStyleParser.java @@ -66,7 +66,7 @@ public class TableStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "table"; } diff --git a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java index 5f7850b..2ec2736 100644 --- a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java @@ -232,7 +232,7 @@ public class TextStyleParser extends StyleWithPropertiesParser { * @param style to use * @return the tag name. */ - public String getDefaultTagName(StyleWithProperties style) { + public String getStyleTag() { return "span"; }