diff --git a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java index 5ac4872..80772b5 100644 --- a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java @@ -61,10 +61,10 @@ public class FrameStyleParser extends StyleWithPropertiesParser { /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { + public String composeStyleDeclarations() { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); - buf.append(super.getStyleSelectors()); + buf.append(super.composeStyleDeclarations()); Enumeration names = styleNames.keys(); while (names.hasMoreElements()) { String sDisplayName = names.nextElement(); diff --git a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java index 081ff3d..18d3fca 100644 --- a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java @@ -56,7 +56,7 @@ public class HeadingStyleParser extends StyleParser { } @Override - public String getStyleSelectors() { + public String composeStyleDeclarations() { if (!bConvertStyles) { return ""; } diff --git a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java index bf0efdd..7bd8295 100644 --- a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java @@ -90,7 +90,7 @@ public class ListStyleParser extends StyleParser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { + public String composeStyleDeclarations() { if (!bConvertStyles) { return ""; } diff --git a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java index 5253232..2dbb412 100644 --- a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java @@ -132,7 +132,7 @@ public class PageStyleParser extends StyleParser { /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { + public String composeStyleDeclarations() { StringBuilder buf = new StringBuilder(); // This will be master pages for presentations only diff --git a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java index 71a008d..77a3d78 100644 --- a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java @@ -86,12 +86,12 @@ public class PresentationStyleParser extends FrameStyleParser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public String getStyleSelectors() { + public String composeStyleDeclarations() { if (!bConvertStyles) { return ""; } StringBuilder buf = new StringBuilder(); - buf.append(super.getStyleSelectors()); + buf.append(super.composeStyleDeclarations()); Enumeration names = outlineStyleNames.keys(); while (names.hasMoreElements()) { String sDisplayName = names.nextElement(); diff --git a/src/main/java/writer2latex/xhtml/style/StyleParser.java b/src/main/java/writer2latex/xhtml/style/StyleParser.java index 66a5bc0..69f5148 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleParser.java @@ -123,6 +123,6 @@ public abstract class StyleParser extends Parser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public abstract String getStyleSelectors(); + public abstract String composeStyleDeclarations(); } diff --git a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java index 1fb125e..1446047 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java @@ -95,7 +95,7 @@ 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() { + public String composeStyleDeclarations() { if (!bConvertStyles) { return ""; } @@ -103,26 +103,42 @@ public abstract class StyleWithPropertiesParser extends StyleParser { 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()); - styleNames.addName(sDisplayName); - buf.append(styleNames.getName(sDisplayName)); - buf.append(" {"); - buf.append(props.toString()); - buf.append("}"); - buf.append(prettyPrint ? "\n" : " "); - // TODO: Create a method "getStyleDeclarationsInner" - // to be used by eg. FrameStyleConverter - } + buf.append(composeStyleDeclaration(sDisplayName)); } return buf.toString(); } + + private String composeStyleDeclaration( String displayName) { + StringBuilder declaration = new StringBuilder(); + StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName); + if (!style.isAutomatic()) { + + declaration.append(indent); + + declaration.append(selector(displayName)); + + declaration.append(" {"); + + declaration.append(declarations(displayName)); + + declaration.append("}" + (prettyPrint ? "\n" : " ")); + // TODO: Create a method "getStyleDeclarationsInner" + // to be used by eg. FrameStyleConverter + } + return declaration.toString(); + } + + private String declarations(String displayName) { + StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName); + CSVList props = new CSVList(";"); + applyProperties(style, props, true); + return props.toString(); + } + + private String selector(String displayName) { + styleNames.addName(displayName); + return getStyleTag() + "." + getClassNamePrefix() + styleNames.getName(displayName); + } /** Return a prefix to be used in generated css class names * @return the prefix diff --git a/src/main/java/writer2latex/xhtml/style/Styles.java b/src/main/java/writer2latex/xhtml/style/Styles.java index aed9cf8..9f1d7fb 100644 --- a/src/main/java/writer2latex/xhtml/style/Styles.java +++ b/src/main/java/writer2latex/xhtml/style/Styles.java @@ -140,17 +140,17 @@ public class Styles extends Parser { // Text documents: text, par, list, frame // Spreadsheet documents: cell // Presentation documents: frame, presentation, page - buf.append(textStyleParser.getStyleSelectors()); - buf.append(parStyleParser.getStyleSelectors()); - buf.append(headingStyleParser.getStyleSelectors()); - buf.append(listStyleParser.getStyleSelectors()); - buf.append(sectionStyleParser.getStyleSelectors()); - buf.append(cellStyleParser.getStyleSelectors()); - buf.append(tableStyleParser.getStyleSelectors()); - buf.append(rowStyleParser.getStyleSelectors()); - buf.append(frameStyleParser.getStyleSelectors()); - buf.append(presentationStyleParser.getStyleSelectors()); - buf.append(pageStyleParser.getStyleSelectors()); + buf.append(textStyleParser.composeStyleDeclarations()); + buf.append(parStyleParser.composeStyleDeclarations()); + buf.append(headingStyleParser.composeStyleDeclarations()); + buf.append(listStyleParser.composeStyleDeclarations()); + buf.append(sectionStyleParser.composeStyleDeclarations()); + buf.append(cellStyleParser.composeStyleDeclarations()); + buf.append(tableStyleParser.composeStyleDeclarations()); + buf.append(rowStyleParser.composeStyleDeclarations()); + buf.append(frameStyleParser.composeStyleDeclarations()); + buf.append(presentationStyleParser.composeStyleDeclarations()); + buf.append(pageStyleParser.composeStyleDeclarations()); return buf.toString(); } diff --git a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java index 9497caa..35c9934 100644 --- a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java @@ -155,8 +155,8 @@ public class TextStyleParser extends StyleWithPropertiesParser { * @param sIndent a String of spaces to add before each line */ StringBuilder buf = new StringBuilder(); - public String getStyleSelectors() { - buf.append(super.getStyleSelectors()); + public String composeStyleDeclarations() { + buf.append(super.composeStyleDeclarations()); if (bConvertStyles) { // Export anchor styles // Default is always the styles "Internet link" and "Visited Internet Link"(?)