home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.text.html;
-
- import com.sun.java.swing.text.Style;
- import com.sun.java.swing.text.StyleConstants;
- import com.sun.java.swing.text.StyleContext;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.util.Enumeration;
- import java.util.Vector;
-
- class StyleReader extends HTMLStyleCallbackDefault {
- public static final String DEFAULT_STYLE_HIERARCHY = "default-hierarchy";
- public static final String CHILD_STYLE = "child-style";
- private style32 styleParser;
- private StyleContext styleContext;
- private Style _newStyle;
- private Style _parentStyle;
- private String _name;
- private Vector tags;
- // $FF: renamed from: ss com.sun.java.swing.text.html.StyleSheet
- protected static StyleSheet field_0 = new StyleSheet();
-
- public StyleReader(StyleContext var1) {
- this.styleContext = var1;
- Style var2 = this.styleContext.addStyle("default-hierarchy", (Style)null);
- var2.addAttribute("child-style", this.styleContext.getStyle("default"));
- field_0 = new StyleSheet(this.styleContext.getStyle("default-hierarchy"));
- this.tags = new Vector();
- this._parentStyle = this.styleContext.getStyle("default-hierarchy");
- }
-
- public int read(StyleContext var1, int var2, InputStream var3) {
- this.styleParser = new style32(new InputStreamReader(var3));
- this.styleParser.setCallback(this);
-
- try {
- this.styleParser.extstylesheet();
- } catch (ParseException var5) {
- System.out.println("Style Parse Error");
- System.out.println(var5);
- }
-
- return 0;
- }
-
- public static StyleSheet getStyleSheet() {
- return field_0;
- }
-
- private String makePName(String var1) {
- Object var2 = null;
- String var3;
- if (var1.equals("p")) {
- var3 = "impliedp";
- } else {
- var3 = var1.substring(0, var1.length() - 1) + "impliedp";
- }
-
- return var3;
- }
-
- private void dumpStyles(Style var1, String var2) {
- Enumeration var3 = var1.getAttributeNames();
-
- while(var3.hasMoreElements()) {
- Object var4 = var3.nextElement();
- Object var5 = var1.getAttribute(var4);
- if (!var4.equals(StyleConstants.ResolveAttribute)) {
- System.out.println(var2 + var4.toString() + " = " + var5.toString());
- }
-
- if (var5 instanceof Style && !var4.equals(StyleConstants.ResolveAttribute)) {
- this.dumpStyles((Style)var5, var2 + " ");
- }
- }
-
- }
-
- public void tagAction(String var1) {
- if (var1.equals("body")) {
- this._parentStyle = this.styleContext.getStyle("default-hierarchy");
- }
-
- this.tags.addElement(var1);
- String var2 = this.makeStyleName();
- Object var3 = null;
- if (!var1.equals("body")) {
- this._newStyle = this.styleContext.getStyle("SH" + var2);
- if (this._newStyle == null) {
- this._newStyle = this.styleContext.addStyle("SH" + var2, (Style)null);
- Style var4 = (Style)this._parentStyle.getAttribute("child-style");
- Style var5 = this.styleContext.addStyle(var2, var4);
- this._newStyle.addAttribute("child-style", var5);
- this._newStyle.addAttribute(StyleConstants.ResolveAttribute, this._parentStyle);
- this._parentStyle.addAttribute("SH" + var1, this._newStyle);
- }
- } else {
- this._newStyle = this._parentStyle;
- }
-
- this._parentStyle = this._newStyle;
- }
-
- public void depTagAction() {
- }
-
- public void classAction(String var1) {
- }
-
- public void pseudoclassAction(String var1) {
- }
-
- public void propertyAction(String var1) {
- this._name = var1;
- }
-
- public void valueAction(String var1) {
- Style var2 = (Style)this._newStyle.getAttribute("child-style");
- StyleXlater.translateProperty(field_0, var2, this._name, var1);
- this.tags.removeAllElements();
- this._parentStyle = this.styleContext.getStyle("default-hierarchy");
- }
-
- private String makeStyleName() {
- int var1 = this.tags.size();
- String var2 = new String();
- String var3 = (String)this.tags.elementAt(0);
- var2 = var2 + var3;
-
- for(int var4 = 1; var4 < var1; ++var4) {
- var3 = (String)this.tags.elementAt(var4);
- var2 = var2 + " " + var3;
- }
-
- return var2;
- }
- }
-