Refactoring
This commit is contained in:
parent
bd32335e71
commit
3365665d23
11 changed files with 72 additions and 77 deletions
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "";
|
||||
}
|
||||
|
||||
|
|
|
@ -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" : " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
/** <p>Convert style information for used styles</p>
|
||||
* @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<String> 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<String> 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) {
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> 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<String> 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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue