Refactoring
This commit is contained in:
parent
0bde7de8c3
commit
9c2e95425e
3 changed files with 76 additions and 60 deletions
|
@ -59,36 +59,38 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
|
|||
/** Convert style information for used styles
|
||||
* @param sIndent a String of spaces to add before each line
|
||||
*/
|
||||
public String getStyleDeclarations(String sIndent) {
|
||||
if (bConvertStyles) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(super.getStyleDeclarations(sIndent));
|
||||
Enumeration<String> names = styleNames.keys();
|
||||
while (names.hasMoreElements()) {
|
||||
String sDisplayName = names.nextElement();
|
||||
StyleWithProperties style = (StyleWithProperties)
|
||||
getStyles().getStyleByDisplayName(sDisplayName);
|
||||
if (!style.isAutomatic()) {
|
||||
// Apply style to paragraphs contained in this frame
|
||||
CSVList props = new CSVList(";");
|
||||
getFrameSc().cssMargins(style,props,true);
|
||||
getParSc().cssPar(style,props,true);
|
||||
getTextSc().cssTextCommon(style,props,true);
|
||||
if (!props.isEmpty()) {
|
||||
buf.append(sIndent)
|
||||
.append(getDefaultTagName(null))
|
||||
.append(".").append(getClassNamePrefix())
|
||||
.append(styleNames.addToExport(sDisplayName))
|
||||
.append(" p {").append(props.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public String getStyleDeclarations(String sIndent) {
|
||||
if (bConvertStyles) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(super.getStyleDeclarations(sIndent));
|
||||
Enumeration<String> names = styleNames.keys();
|
||||
while (names.hasMoreElements()) {
|
||||
String sDisplayName = names.nextElement();
|
||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName);
|
||||
if (!style.isAutomatic()) {
|
||||
// Apply style to paragraphs contained in this frame
|
||||
CSVList props = new CSVList(";");
|
||||
getFrameSc().cssMargins(style, props, true);
|
||||
getParSc().cssPar(style, props, true);
|
||||
getTextSc().cssTextCommon(style, props, true);
|
||||
if (!props.isEmpty()) {
|
||||
buf.append(sIndent);
|
||||
buf.append(getDefaultTagName(null));
|
||||
buf.append(".");
|
||||
buf.append(getClassNamePrefix());
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
buf.append(" p {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
buf.append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** Return a prefix to be used in generated css class names
|
||||
* @return the prefix
|
||||
|
|
|
@ -53,31 +53,42 @@ public class HeadingStyleConverter extends StyleConverterHelper {
|
|||
|
||||
@Override
|
||||
public String getStyleDeclarations(String sIndent) {
|
||||
if (bConvertStyles) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i=1; i<=6; i++) {
|
||||
// Convert main style for this level
|
||||
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" : " ");
|
||||
}
|
||||
// Convert other styles for this level
|
||||
for (String sDisplayName : otherLevelStyles.get(i)) {
|
||||
StyleWithProperties style = (StyleWithProperties)
|
||||
getStyles().getStyleByDisplayName(sDisplayName);
|
||||
CSVList props = new CSVList(";");
|
||||
getParSc().applyProperties(style,props,true);
|
||||
props.addValue("clear","left");
|
||||
buf.append(sIndent).append("h").append(i).append(".").append(styleNames.addToExport(sDisplayName))
|
||||
.append(" {").append(props.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
return "";
|
||||
if (bConvertStyles) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
// Convert main style for this level
|
||||
if (ofr.getHeadingStyle(i) != null) {
|
||||
CSVList props = new CSVList(";");
|
||||
getParSc().applyProperties(ofr.getHeadingStyle(i), props, true);
|
||||
props.addValue("clear", "left");
|
||||
buf.append(sIndent);
|
||||
buf.append("h");
|
||||
buf.append(i);
|
||||
buf.append(" {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
buf.append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
// Convert other styles for this level
|
||||
for (String sDisplayName : otherLevelStyles.get(i)) {
|
||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName);
|
||||
CSVList props = new CSVList(";");
|
||||
getParSc().applyProperties(style, props, true);
|
||||
props.addValue("clear", "left");
|
||||
buf.append(sIndent);
|
||||
buf.append("h");
|
||||
buf.append(i);
|
||||
buf.append(".");
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
buf.append(" {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
buf.append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,11 +111,14 @@ public class ListStyleConverter extends StyleConverterHelper {
|
|||
CSVList parProps = new CSVList(";");
|
||||
cssListParMargins(style,nLevel,parProps);
|
||||
if (!parProps.isEmpty()) {
|
||||
buf.append(sIndent)
|
||||
.append(".listlevel")
|
||||
.append(nLevel)
|
||||
.append(styleNames.addToExport(sDisplayName))
|
||||
.append(" p {").append(parProps.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
|
||||
buf.append(sIndent);
|
||||
buf.append(".listlevel");
|
||||
buf.append(nLevel);
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
buf.append(" p {");
|
||||
buf.append(parProps.toString());
|
||||
buf.append("}");
|
||||
buf.append(config.prettyPrint() ? "\n" : " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue