home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.html;
-
- import java.io.IOException;
- import java.io.Writer;
- import java.util.Enumeration;
- import java.util.Stack;
- import java.util.Vector;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.DefaultListModel;
- import javax.swing.text.AbstractDocument;
- import javax.swing.text.AbstractWriter;
- import javax.swing.text.AttributeSet;
- import javax.swing.text.BadLocationException;
- import javax.swing.text.Document;
- import javax.swing.text.Element;
- import javax.swing.text.ElementIterator;
- import javax.swing.text.MutableAttributeSet;
- import javax.swing.text.Segment;
- import javax.swing.text.SimpleAttributeSet;
- import javax.swing.text.Style;
- import javax.swing.text.StyleConstants;
- import javax.swing.text.StyleContext;
- import javax.swing.text.html.HTML.Attribute;
- import javax.swing.text.html.HTML.Tag;
-
- public class HTMLWriter extends AbstractWriter {
- private Stack blockElementStack;
- private boolean inContent;
- private boolean inPre;
- private int preEndOffset;
- private boolean inTextArea;
- private boolean newlineOutputed;
- private boolean completeDoc;
- private Vector tags;
- private Vector tagValues;
- private Segment segment;
- private Vector tagsToRemove;
- private boolean wroteHead;
- private boolean replaceEntities;
- private char[] tempChars;
- private boolean indentNext;
- private boolean writeCSS;
- private MutableAttributeSet convAttr;
- private MutableAttributeSet oConvAttr;
-
- public HTMLWriter(Writer var1, HTMLDocument var2) {
- this(var1, var2, 0, ((AbstractDocument)var2).getLength());
- }
-
- public HTMLWriter(Writer var1, HTMLDocument var2, int var3, int var4) {
- super(var1, var2, var3, var4);
- this.blockElementStack = new Stack();
- this.inContent = false;
- this.inPre = false;
- this.inTextArea = false;
- this.newlineOutputed = false;
- this.tags = new Vector(10);
- this.tagValues = new Vector(10);
- this.tagsToRemove = new Vector(10);
- this.indentNext = false;
- this.writeCSS = false;
- this.convAttr = new SimpleAttributeSet();
- this.oConvAttr = new SimpleAttributeSet();
- this.completeDoc = var3 == 0 && var4 == ((AbstractDocument)var2).getLength();
- ((AbstractWriter)this).setLineLength(80);
- }
-
- public void write() throws IOException, BadLocationException {
- ElementIterator var1 = ((AbstractWriter)this).getElementIterator();
- Element var2 = null;
- Object var3 = null;
- this.wroteHead = false;
- ((AbstractWriter)this).setCurrentLineLength(0);
- this.replaceEntities = false;
- ((AbstractWriter)this).setCanWrapLines(false);
- if (this.segment == null) {
- this.segment = new Segment();
- }
-
- this.inPre = false;
-
- while((var6 = var1.next()) != null) {
- if (((AbstractWriter)this).inRange(var6)) {
- if (var2 != null) {
- if (this.indentNeedsIncrementing(var2, var6)) {
- ((AbstractWriter)this).incrIndent();
- } else if (var2.getParentElement() != var6.getParentElement()) {
- for(Element var7 = (Element)this.blockElementStack.peek(); var7 != var6.getParentElement(); var7 = (Element)this.blockElementStack.peek()) {
- this.blockElementStack.pop();
- if (!this.synthesizedElement(var7)) {
- if (!this.matchNameAttribute(var7.getAttributes(), Tag.PRE)) {
- ((AbstractWriter)this).decrIndent();
- }
-
- this.endTag(var7);
- }
- }
- } else if (var2.getParentElement() == var6.getParentElement()) {
- Element var4 = (Element)this.blockElementStack.peek();
- if (var4 == var2) {
- this.blockElementStack.pop();
- this.endTag(var4);
- }
- }
- }
-
- if (var6.isLeaf() && !this.isFormElementWithContent(var6.getAttributes())) {
- this.emptyTag(var6);
- } else {
- this.blockElementStack.push(var6);
- this.startTag(var6);
- }
-
- var2 = var6;
- }
- }
-
- this.closeOutUnwantedEmbeddedTags((AttributeSet)null);
-
- while(!this.blockElementStack.empty()) {
- var2 = (Element)this.blockElementStack.pop();
- if (!this.synthesizedElement(var2)) {
- if (!this.matchNameAttribute(var2.getAttributes(), Tag.PRE)) {
- ((AbstractWriter)this).decrIndent();
- }
-
- this.endTag(var2);
- }
- }
-
- if (this.completeDoc) {
- this.writeAdditionalComments();
- }
-
- this.segment.array = null;
- }
-
- protected void writeAttributes(AttributeSet var1) throws IOException {
- this.convAttr.removeAttributes(this.convAttr);
- convertToHTML32(var1, this.convAttr);
- Enumeration var2 = this.convAttr.getAttributeNames();
-
- while(var2.hasMoreElements()) {
- Object var3 = var2.nextElement();
- if (!(var3 instanceof HTML.Tag) && !(var3 instanceof StyleConstants) && var3 != Attribute.ENDTAG) {
- ((AbstractWriter)this).write(" " + var3 + "=\"" + this.convAttr.getAttribute(var3) + "\"");
- }
- }
-
- }
-
- protected void emptyTag(Element var1) throws BadLocationException, IOException {
- if (!this.inContent && !this.inPre) {
- ((AbstractWriter)this).indent();
- }
-
- AttributeSet var2 = var1.getAttributes();
- this.closeOutUnwantedEmbeddedTags(var2);
- this.writeEmbeddedTags(var2);
- if (this.matchNameAttribute(var2, Tag.CONTENT)) {
- this.inContent = true;
- this.text(var1);
- } else if (this.matchNameAttribute(var2, Tag.COMMENT)) {
- this.comment(var1);
- } else {
- boolean var3 = this.isBlockTag(var1.getAttributes());
- if (this.inContent && var3) {
- this.writeLineSeparator();
- ((AbstractWriter)this).indent();
- }
-
- Object var4 = var2 != null ? var2.getAttribute(StyleConstants.NameAttribute) : null;
- Object var5 = var2 != null ? var2.getAttribute(Attribute.ENDTAG) : null;
- boolean var6 = false;
- if (var4 != null && var5 != null && var5 instanceof String && ((String)var5).equals("true")) {
- var6 = true;
- }
-
- if (this.completeDoc && this.matchNameAttribute(var2, Tag.HEAD)) {
- if (var6) {
- this.writeStyles(((HTMLDocument)((AbstractWriter)this).getDocument()).getStyleSheet());
- }
-
- this.wroteHead = true;
- }
-
- ((AbstractWriter)this).write('<');
- if (var6) {
- ((AbstractWriter)this).write('/');
- }
-
- ((AbstractWriter)this).write(var1.getName());
- this.writeAttributes(var2);
- ((AbstractWriter)this).write('>');
- if (this.matchNameAttribute(var2, Tag.TITLE) && !var6) {
- Document var7 = var1.getDocument();
- String var8 = (String)var7.getProperty("title");
- ((AbstractWriter)this).write(var8);
- } else if (!this.inContent || var3) {
- this.writeLineSeparator();
- if (var3 && this.inContent) {
- ((AbstractWriter)this).indent();
- }
- }
- }
-
- }
-
- protected boolean isBlockTag(AttributeSet var1) {
- Object var2 = var1.getAttribute(StyleConstants.NameAttribute);
- if (var2 instanceof HTML.Tag) {
- HTML.Tag var3 = (HTML.Tag)var2;
- return var3.isBlock();
- } else {
- return false;
- }
- }
-
- protected void startTag(Element var1) throws IOException, BadLocationException {
- if (!this.synthesizedElement(var1)) {
- AttributeSet var2 = var1.getAttributes();
- Object var3 = var2.getAttribute(StyleConstants.NameAttribute);
- HTML.Tag var4;
- if (var3 instanceof HTML.Tag) {
- var4 = (HTML.Tag)var3;
- } else {
- var4 = null;
- }
-
- if (var4 == Tag.PRE) {
- this.inPre = true;
- this.preEndOffset = var1.getEndOffset();
- }
-
- this.closeOutUnwantedEmbeddedTags(var2);
- if (this.inContent) {
- this.writeLineSeparator();
- this.inContent = false;
- this.newlineOutputed = false;
- }
-
- if (this.completeDoc && var4 == Tag.BODY && !this.wroteHead) {
- this.wroteHead = true;
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("<head>");
- this.writeLineSeparator();
- ((AbstractWriter)this).incrIndent();
- this.writeStyles(((HTMLDocument)((AbstractWriter)this).getDocument()).getStyleSheet());
- ((AbstractWriter)this).decrIndent();
- this.writeLineSeparator();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("</head>");
- this.writeLineSeparator();
- }
-
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write(var1.getName());
- this.writeAttributes(var2);
- ((AbstractWriter)this).write('>');
- if (var4 != Tag.PRE) {
- this.writeLineSeparator();
- }
-
- if (var4 == Tag.TEXTAREA) {
- this.textAreaContent(var1.getAttributes());
- } else if (var4 == Tag.SELECT) {
- this.selectContent(var1.getAttributes());
- } else if (this.completeDoc && var4 == Tag.BODY) {
- this.writeMaps(((HTMLDocument)((AbstractWriter)this).getDocument()).getMaps());
- } else if (var4 == Tag.HEAD) {
- this.wroteHead = true;
- }
-
- }
- }
-
- protected void textAreaContent(AttributeSet var1) throws BadLocationException, IOException {
- Document var2 = (Document)var1.getAttribute(StyleConstants.ModelAttribute);
- if (var2 != null && var2.getLength() > 0) {
- if (this.segment == null) {
- this.segment = new Segment();
- }
-
- var2.getText(0, var2.getLength(), this.segment);
- if (this.segment.count > 0) {
- this.inTextArea = true;
- ((AbstractWriter)this).incrIndent();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).setCanWrapLines(true);
- this.replaceEntities = true;
- ((AbstractWriter)this).write(this.segment.array, this.segment.offset, this.segment.count);
- this.replaceEntities = false;
- ((AbstractWriter)this).setCanWrapLines(false);
- this.writeLineSeparator();
- this.inTextArea = false;
- ((AbstractWriter)this).decrIndent();
- }
- }
-
- }
-
- protected void text(Element var1) throws BadLocationException, IOException {
- int var2 = Math.max(((AbstractWriter)this).getStartOffset(), var1.getStartOffset());
- int var3 = Math.min(((AbstractWriter)this).getEndOffset(), var1.getEndOffset());
- if (var2 < var3) {
- if (this.segment == null) {
- this.segment = new Segment();
- }
-
- ((AbstractWriter)this).getDocument().getText(var2, var3 - var2, this.segment);
- this.newlineOutputed = false;
- if (this.segment.count > 0) {
- if (this.segment.array[this.segment.offset + this.segment.count - 1] == '\n') {
- this.newlineOutputed = true;
- }
-
- if (this.inPre && var3 == this.preEndOffset) {
- if (this.segment.count <= 1) {
- return;
- }
-
- --this.segment.count;
- }
-
- this.replaceEntities = true;
- ((AbstractWriter)this).setCanWrapLines(!this.inPre);
- ((AbstractWriter)this).write(this.segment.array, this.segment.offset, this.segment.count);
- ((AbstractWriter)this).setCanWrapLines(false);
- this.replaceEntities = false;
- }
- }
-
- }
-
- protected void selectContent(AttributeSet var1) throws IOException {
- Object var2 = var1.getAttribute(StyleConstants.ModelAttribute);
- ((AbstractWriter)this).incrIndent();
- if (var2 instanceof OptionListModel) {
- OptionListModel var3 = (OptionListModel)var2;
- int var4 = ((DefaultListModel)var3).getSize();
-
- for(int var5 = 0; var5 < var4; ++var5) {
- Option var6 = (Option)((DefaultListModel)var3).getElementAt(var5);
- this.writeOption(var6);
- }
- } else if (var2 instanceof OptionComboBoxModel) {
- OptionComboBoxModel var7 = (OptionComboBoxModel)var2;
- int var8 = ((DefaultComboBoxModel)var7).getSize();
-
- for(int var9 = 0; var9 < var8; ++var9) {
- Option var10 = (Option)((DefaultComboBoxModel)var7).getElementAt(var9);
- this.writeOption(var10);
- }
- }
-
- ((AbstractWriter)this).decrIndent();
- }
-
- protected void writeOption(Option var1) throws IOException {
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write("option ");
- if (var1.getValue() != null) {
- ((AbstractWriter)this).write("value=" + var1.getValue());
- }
-
- if (var1.isSelected()) {
- ((AbstractWriter)this).write(" selected");
- }
-
- ((AbstractWriter)this).write('>');
- if (var1.getLabel() != null) {
- ((AbstractWriter)this).write(var1.getLabel());
- }
-
- this.writeLineSeparator();
- }
-
- protected void endTag(Element var1) throws IOException {
- if (!this.synthesizedElement(var1)) {
- if (this.matchNameAttribute(var1.getAttributes(), Tag.PRE)) {
- this.inPre = false;
- }
-
- this.closeOutUnwantedEmbeddedTags(var1.getAttributes());
- if (this.inContent) {
- if (!this.newlineOutputed) {
- this.writeLineSeparator();
- }
-
- this.newlineOutputed = false;
- this.inContent = false;
- }
-
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write('/');
- ((AbstractWriter)this).write(var1.getName());
- ((AbstractWriter)this).write('>');
- this.writeLineSeparator();
- }
- }
-
- protected void comment(Element var1) throws BadLocationException, IOException {
- AttributeSet var2 = var1.getAttributes();
- if (this.matchNameAttribute(var2, Tag.COMMENT)) {
- Object var3 = var2.getAttribute(Attribute.COMMENT);
- if (var3 instanceof String) {
- this.writeComment((String)var3);
- } else {
- this.writeComment((String)null);
- }
- }
-
- }
-
- void writeComment(String var1) throws IOException {
- ((AbstractWriter)this).write("<!--");
- if (var1 != null) {
- ((AbstractWriter)this).write(var1);
- }
-
- ((AbstractWriter)this).write("-->");
- this.writeLineSeparator();
- }
-
- void writeAdditionalComments() throws IOException {
- Object var1 = ((AbstractWriter)this).getDocument().getProperty("AdditionalComments");
- if (var1 instanceof Vector) {
- Vector var2 = (Vector)var1;
- int var3 = 0;
-
- for(int var4 = var2.size(); var3 < var4; ++var3) {
- this.writeComment(var2.elementAt(var3).toString());
- }
- }
-
- }
-
- protected boolean synthesizedElement(Element var1) {
- return this.matchNameAttribute(var1.getAttributes(), Tag.IMPLIED);
- }
-
- protected boolean matchNameAttribute(AttributeSet var1, HTML.Tag var2) {
- Object var3 = var1.getAttribute(StyleConstants.NameAttribute);
- if (var3 instanceof HTML.Tag) {
- HTML.Tag var4 = (HTML.Tag)var3;
- if (var4 == var2) {
- return true;
- }
- }
-
- return false;
- }
-
- protected void writeEmbeddedTags(AttributeSet var1) throws IOException {
- var1 = this.convertToHTML(var1, this.oConvAttr);
- Enumeration var2 = var1.getAttributeNames();
-
- while(var2.hasMoreElements()) {
- Object var3 = var2.nextElement();
- if (var3 instanceof HTML.Tag) {
- HTML.Tag var4 = (HTML.Tag)var3;
- if (var4 != Tag.FORM && !this.tags.contains(var4)) {
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write(var4.toString());
- Object var5 = var1.getAttribute(var4);
- if (var5 != null && var5 instanceof AttributeSet) {
- this.writeAttributes((AttributeSet)var5);
- }
-
- ((AbstractWriter)this).write('>');
- this.tags.addElement(var4);
- this.tagValues.addElement(var5);
- }
- }
- }
-
- }
-
- private boolean noMatchForTagInAttributes(AttributeSet var1, HTML.Tag var2, Object var3) {
- if (var1 != null && var1.isDefined(var2)) {
- Object var4 = var1.getAttribute(var2);
- if (var3 == null ? var4 == null : var4 != null && var3.equals(var4)) {
- return false;
- }
- }
-
- return true;
- }
-
- protected void closeOutUnwantedEmbeddedTags(AttributeSet var1) throws IOException {
- this.tagsToRemove.removeAllElements();
- var1 = this.convertToHTML(var1, (MutableAttributeSet)null);
- int var4 = -1;
- int var5 = this.tags.size();
-
- for(int var6 = var5 - 1; var6 >= 0; --var6) {
- HTML.Tag var2 = (HTML.Tag)this.tags.elementAt(var6);
- Object var3 = this.tagValues.elementAt(var6);
- if (var1 == null || this.noMatchForTagInAttributes(var1, var2, var3)) {
- var4 = var6;
- this.tagsToRemove.addElement(var2);
- }
- }
-
- if (var4 != -1) {
- boolean var7 = var5 - var4 == this.tagsToRemove.size();
-
- for(int var8 = var5 - 1; var8 >= var4; --var8) {
- HTML.Tag var12 = (HTML.Tag)this.tags.elementAt(var8);
- if (var7 || this.tagsToRemove.contains(var12)) {
- this.tags.removeElementAt(var8);
- this.tagValues.removeElementAt(var8);
- }
-
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write('/');
- ((AbstractWriter)this).write(var12.toString());
- ((AbstractWriter)this).write('>');
- }
-
- var5 = this.tags.size();
-
- for(int var9 = var4; var9 < var5; ++var9) {
- HTML.Tag var13 = (HTML.Tag)this.tags.elementAt(var9);
- ((AbstractWriter)this).write('<');
- ((AbstractWriter)this).write(var13.toString());
- Object var10 = this.tagValues.elementAt(var9);
- if (var10 != null && var10 instanceof AttributeSet) {
- this.writeAttributes((AttributeSet)var10);
- }
-
- ((AbstractWriter)this).write('>');
- }
- }
-
- }
-
- private boolean isFormElementWithContent(AttributeSet var1) {
- return this.matchNameAttribute(var1, Tag.TEXTAREA) || this.matchNameAttribute(var1, Tag.SELECT);
- }
-
- private boolean indentNeedsIncrementing(Element var1, Element var2) {
- if (var2.getParentElement() == var1 && !this.inPre) {
- if (this.indentNext) {
- this.indentNext = false;
- return true;
- }
-
- if (this.synthesizedElement(var2)) {
- this.indentNext = true;
- } else if (!this.synthesizedElement(var1)) {
- return true;
- }
- }
-
- return false;
- }
-
- void writeMaps(Enumeration var1) throws IOException {
- if (var1 != null) {
- while(var1.hasMoreElements()) {
- Map var2 = (Map)var1.nextElement();
- String var3 = var2.getName();
- ((AbstractWriter)this).incrIndent();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("<map");
- if (var3 != null) {
- ((AbstractWriter)this).write(" name=\"");
- ((AbstractWriter)this).write(var3);
- ((AbstractWriter)this).write("\">");
- } else {
- ((AbstractWriter)this).write('>');
- }
-
- this.writeLineSeparator();
- ((AbstractWriter)this).incrIndent();
- AttributeSet[] var4 = var2.getAreas();
- if (var4 != null) {
- int var5 = 0;
-
- for(int var6 = var4.length; var5 < var6; ++var5) {
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("<area");
- this.writeAttributes(var4[var5]);
- ((AbstractWriter)this).write("></area>");
- this.writeLineSeparator();
- }
- }
-
- ((AbstractWriter)this).decrIndent();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("</map>");
- this.writeLineSeparator();
- ((AbstractWriter)this).decrIndent();
- }
- }
-
- }
-
- void writeStyles(StyleSheet var1) throws IOException {
- if (var1 != null) {
- Enumeration var2 = ((StyleContext)var1).getStyleNames();
- if (var2 != null) {
- boolean var3 = false;
-
- while(var2.hasMoreElements()) {
- String var4 = (String)var2.nextElement();
- if (!"default".equals(var4) && this.writeStyle(var4, ((StyleContext)var1).getStyle(var4), var3)) {
- var3 = true;
- }
- }
-
- if (var3) {
- this.writeStyleEndTag();
- }
- }
- }
-
- }
-
- boolean writeStyle(String var1, Style var2, boolean var3) throws IOException {
- boolean var4 = false;
- Enumeration var5 = var2.getAttributeNames();
- if (var5 != null) {
- while(var5.hasMoreElements()) {
- Object var6 = var5.nextElement();
- if (var6 instanceof CSS.Attribute) {
- String var7 = var2.getAttribute(var6).toString();
- if (var7 != null) {
- if (!var3) {
- this.writeStyleStartTag();
- var3 = true;
- }
-
- if (!var4) {
- var4 = true;
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write(var1);
- ((AbstractWriter)this).write(" {");
- } else {
- ((AbstractWriter)this).write(";");
- }
-
- ((AbstractWriter)this).write(' ');
- ((AbstractWriter)this).write(var6.toString());
- ((AbstractWriter)this).write(": ");
- ((AbstractWriter)this).write(var7);
- }
- }
- }
- }
-
- if (var4) {
- ((AbstractWriter)this).write(" }");
- this.writeLineSeparator();
- }
-
- return var4;
- }
-
- void writeStyleStartTag() throws IOException {
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("<style type=\"text/css\">");
- ((AbstractWriter)this).incrIndent();
- this.writeLineSeparator();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("<!--");
- ((AbstractWriter)this).incrIndent();
- this.writeLineSeparator();
- }
-
- void writeStyleEndTag() throws IOException {
- ((AbstractWriter)this).decrIndent();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("-->");
- this.writeLineSeparator();
- ((AbstractWriter)this).decrIndent();
- ((AbstractWriter)this).indent();
- ((AbstractWriter)this).write("</style>");
- this.writeLineSeparator();
- ((AbstractWriter)this).indent();
- }
-
- AttributeSet convertToHTML(AttributeSet var1, MutableAttributeSet var2) {
- if (var2 == null) {
- var2 = this.convAttr;
- }
-
- var2.removeAttributes(var2);
- if (this.writeCSS) {
- convertToHTML40(var1, var2);
- } else {
- convertToHTML32(var1, var2);
- }
-
- return var2;
- }
-
- private static void convertToHTML32(AttributeSet var0, MutableAttributeSet var1) {
- if (var0 != null) {
- Enumeration var2 = var0.getAttributeNames();
- String var3 = "";
-
- while(var2.hasMoreElements()) {
- Object var4 = var2.nextElement();
- if (var4 instanceof CSS.Attribute) {
- if (var4 != javax.swing.text.html.CSS.Attribute.FONT_FAMILY && var4 != javax.swing.text.html.CSS.Attribute.FONT_SIZE && var4 != javax.swing.text.html.CSS.Attribute.COLOR) {
- if (var4 == javax.swing.text.html.CSS.Attribute.FONT_WEIGHT) {
- CSS.FontWeight var5 = (CSS.FontWeight)var0.getAttribute(javax.swing.text.html.CSS.Attribute.FONT_WEIGHT);
- if (var5 != null && var5.getValue() > 400) {
- var1.addAttribute(Tag.B, SimpleAttributeSet.EMPTY);
- }
- } else if (var4 == javax.swing.text.html.CSS.Attribute.FONT_STYLE) {
- String var6 = var0.getAttribute(var4).toString();
- if (var6.indexOf("italic") >= 0) {
- var1.addAttribute(Tag.I, SimpleAttributeSet.EMPTY);
- }
- } else if (var4 == javax.swing.text.html.CSS.Attribute.TEXT_DECORATION) {
- String var7 = var0.getAttribute(var4).toString();
- if (var7.indexOf("underline") >= 0) {
- var1.addAttribute(Tag.U, SimpleAttributeSet.EMPTY);
- }
-
- if (var7.indexOf("line-through") >= 0) {
- var1.addAttribute(Tag.STRIKE, SimpleAttributeSet.EMPTY);
- }
- } else if (var4 == javax.swing.text.html.CSS.Attribute.VERTICAL_ALIGN) {
- String var8 = var0.getAttribute(var4).toString();
- if (var8.indexOf("sup") >= 0) {
- var1.addAttribute(Tag.SUP, SimpleAttributeSet.EMPTY);
- }
-
- if (var8.indexOf("sub") >= 0) {
- var1.addAttribute(Tag.SUB, SimpleAttributeSet.EMPTY);
- }
- } else if (var4 == javax.swing.text.html.CSS.Attribute.TEXT_ALIGN) {
- var1.addAttribute(Attribute.ALIGN, var0.getAttribute(var4).toString());
- } else {
- if (var3.length() > 0) {
- var3 = var3 + "; ";
- }
-
- var3 = var3 + var4 + ": " + var0.getAttribute(var4);
- }
- } else {
- createFontAttribute((CSS.Attribute)var4, var0, var1);
- }
- } else {
- var1.addAttribute(var4, var0.getAttribute(var4));
- }
- }
-
- if (var3.length() > 0) {
- var1.addAttribute(Attribute.STYLE, var3);
- }
-
- }
- }
-
- private static void createFontAttribute(CSS.Attribute var0, AttributeSet var1, MutableAttributeSet var2) {
- Object var3 = (MutableAttributeSet)var2.getAttribute(Tag.FONT);
- if (var3 == null) {
- var3 = new SimpleAttributeSet();
- var2.addAttribute(Tag.FONT, var3);
- }
-
- String var4 = var1.getAttribute(var0).toString();
- if (var0 == javax.swing.text.html.CSS.Attribute.FONT_FAMILY) {
- ((MutableAttributeSet)var3).addAttribute(Attribute.FACE, var4);
- } else if (var0 == javax.swing.text.html.CSS.Attribute.FONT_SIZE) {
- ((MutableAttributeSet)var3).addAttribute(Attribute.SIZE, var4);
- } else if (var0 == javax.swing.text.html.CSS.Attribute.COLOR) {
- ((MutableAttributeSet)var3).addAttribute(Attribute.COLOR, var4);
- }
-
- }
-
- private static void convertToHTML40(AttributeSet var0, MutableAttributeSet var1) {
- Enumeration var2 = var0.getAttributeNames();
- String var3 = "";
-
- while(var2.hasMoreElements()) {
- Object var4 = var2.nextElement();
- if (var4 instanceof CSS.Attribute) {
- var3 = var3 + " " + var4 + "=" + var0.getAttribute(var4) + ";";
- } else {
- var1.addAttribute(var4, var0.getAttribute(var4));
- }
- }
-
- if (var3.length() > 0) {
- var1.addAttribute(Attribute.STYLE, var3);
- }
-
- }
-
- protected void writeLineSeparator() throws IOException {
- boolean var1 = this.replaceEntities;
- this.replaceEntities = false;
- super.writeLineSeparator();
- this.replaceEntities = var1;
- }
-
- protected void output(char[] var1, int var2, int var3) throws IOException {
- if (!this.replaceEntities) {
- super.output(var1, var2, var3);
- } else {
- int var4 = var2;
- var3 += var2;
-
- for(int var5 = var2; var5 < var3; ++var5) {
- switch (var1[var5]) {
- case '\t':
- case '\n':
- case '\r':
- break;
- case '"':
- if (var5 > var4) {
- super.output(var1, var4, var5 - var4);
- }
-
- var4 = var5 + 1;
- this.output(""");
- break;
- case '&':
- if (var5 > var4) {
- super.output(var1, var4, var5 - var4);
- }
-
- var4 = var5 + 1;
- this.output("&");
- break;
- case '<':
- if (var5 > var4) {
- super.output(var1, var4, var5 - var4);
- }
-
- var4 = var5 + 1;
- this.output("<");
- break;
- case '>':
- if (var5 > var4) {
- super.output(var1, var4, var5 - var4);
- }
-
- var4 = var5 + 1;
- this.output(">");
- break;
- default:
- if (var1[var5] < ' ' || var1[var5] > 127) {
- if (var5 > var4) {
- super.output(var1, var4, var5 - var4);
- }
-
- var4 = var5 + 1;
- this.output("");
- this.output(String.valueOf(var1[var5]));
- this.output(";");
- }
- }
- }
-
- if (var4 < var3) {
- super.output(var1, var4, var3 - var4);
- }
-
- }
- }
-
- private void output(String var1) throws IOException {
- int var2 = var1.length();
- if (this.tempChars == null || this.tempChars.length < var2) {
- this.tempChars = new char[var2];
- }
-
- var1.getChars(0, var2, this.tempChars, 0);
- super.output(this.tempChars, 0, var2);
- }
- }
-