*/
public void init(String stylefile)
throws Exception {
Style default_style = m_doc.addStyle(StyleContext.DEFAULT_STYLE, m_doc.getLogicalStyle(0));
Style parent_style = default_style;
TextFile file = new TextFile(stylefile);
file.openForRead(file_id);
TextToken token = file.nextToken();
for (; token != null; token = file.nextToken()) {
parent_style = default_style;
String style_name = token.getString();
if (token.isIdentifier()) {
token = file.nextToken();
if (token.isIdentifier("extends")) {
token = file.nextToken();
Style ps = m_doc.getStyle(token.getString());
if (ps != null) {
parent_style = ps;
}
token = file.nextToken();
}
Style new_style = m_doc.addStyle(style_name, parent_style);
error("new style " + style_name);
if (!token.isChar('{')) {
throw new Exception("Can't read style on line " + file.getActLine());
}
Attribute attr = readNextAttribute(file);
// set the attributes
for (; attr != null; attr = readNextAttribute(file)) {
attr.set(new_style);
}
} else {
break;
}
}
file.close();
}