();
ExportNameCollection outlineStyleNames = new ExportNameCollection(true);
/** Create a new PresentationStyleConverter
* @param ofr an OfficeReader
to read style information from
* @param config the configuration to use
* @param converter the main Converter
class
* @param nType the type of xhtml to use
*/
public PresentationStyleConverter(OfficeReader ofr, XhtmlConfig config, Converter converter, int nType) {
super(ofr,config,converter,nType);
// style maps for presentations are currently not supported:
this.styleMap = new XhtmlStyleMap();
}
/** Return a prefix to be used in generated css class names
* @return the prefix
*/
public String getClassNamePrefix() { return "prsnt"; }
/** Get the family of presentation styles
* @return the style family
*/
public OfficeStyleFamily getStyles() {
return ofr.getPresentationStyles();
}
/** Create default tag name to represent a presentation object
* @param style to use
* @return the tag name.
*/
public String getDefaultTagName(StyleWithProperties style) {
return "div";
}
/** 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 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(sIndent)
.append("li.outline")
.append(styleNames.getExportName(sDisplayName))
.append(" p {").append(props.toString()).append("}")
.append(config.prettyPrint() ? "\n" : " ");
}
}
}
return buf.toString();
}
else {
return "";
}
}
public void enterOutline(String sStyleName) {
sCurrentOutlineStyle = sStyleName;
if (!outlineStyles.containsKey(sCurrentOutlineStyle)) {
String[] sNames = new String[10];
outlineStyles.put(sCurrentOutlineStyle,sNames);
StyleWithProperties style1 = ofr.getPresentationStyle(sCurrentOutlineStyle);
if (style1!=null) {
String sCurrentOutlineStyle1 = sCurrentOutlineStyle;
if (style1.isAutomatic()) { sCurrentOutlineStyle1 = style1.getParentName(); }
sNames[1] = sCurrentOutlineStyle1;
String sBaseName = sCurrentOutlineStyle1.substring(0,sCurrentOutlineStyle1.length()-1);
for (int i=2; i<10; i++) {
String sName = sBaseName + Integer.toString(i);
StyleWithProperties style = ofr.getPresentationStyle(sName);
if (style!=null && style.getParentName().equals(sNames[i-1])) {
sNames[i] = sName;
}
else {
break;
}
}
sNames[1] = null;
}
}
}
public void exitOutline() {
sCurrentOutlineStyle = null;
}
public void applyOutlineStyle(int nLevel, StyleInfo info) {
if (2<=nLevel && nLevel<=9 && sCurrentOutlineStyle!=null) {
if (outlineStyles.containsKey(sCurrentOutlineStyle)) {
info.sClass = "outline"+outlineStyleNames.getExportName(outlineStyles.get(sCurrentOutlineStyle)[nLevel]);
}
}
}
}