3261N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * MinimalHTMLWriter is a fallback writer used by the 0N/A * HTMLEditorKit to write out HTML for a document that 0N/A * is a not produced by the EditorKit. 0N/A * The format for the document is: 0N/A * <!-- list of named styles 0N/A * font-family: SansSerif; 0N/A * <p style=normal> 0N/A * <b>Bold, italic, and underline attributes 0N/A * of the run are emitted as HTML tags. 0N/A * The remaining attributes are emitted as 0N/A * part of the style attribute of a <span> tag. 0N/A * The syntax is similar to inline styles.</b> 0N/A * @author Sunita Mani 0N/A * These static finals are used to 0N/A * tweak and query the fontMask about which 0N/A * of these tags need to be generated or 0N/A private static final int BOLD =
0x01;
0N/A // Used to map StyleConstants to CSS. 0N/A * Stores the attributes of the previous run. 0N/A * Used to compare with the current run's 0N/A * attributeset. If identical, then a 0N/A * <span> tag is not emitted. 0N/A * Maps from style name as held by the Document, to the archived 0N/A * style name (style name written out). These may differ. 0N/A * Creates a new MinimalHTMLWriter. 0N/A * @param doc StyledDocument 0N/A * Creates a new MinimalHTMLWriter. 0N/A * @param doc StyledDocument 0N/A * @param pos The location in the document to fetch the 0N/A * @param len The amount to write out. 0N/A * Generates HTML output 0N/A * from a StyledDocument. 0N/A * @exception IOException on any I/O error 0N/A * @exception BadLocationException if pos represents an invalid 0N/A * location within the document. 0N/A * Writes out all the attributes for the 0N/A * StyleConstants.ParagraphConstants, 0N/A * StyleConstants.CharacterConstants, 0N/A * StyleConstants.FontConstants, 0N/A * StyleConstants.ColorConstants. 0N/A * The attribute name and value are separated by a colon. 0N/A * Each pair is separated by a semicolon. 0N/A * @exception IOException on any I/O error 0N/A * @exception IOException on any I/O error 0N/A * Writes out a start tag appropriately 0N/A * indented. Also increments the indent level. 0N/A * @exception IOException on any I/O error 0N/A * Writes out an end tag appropriately 0N/A * indented. Also decrements the indent level. 0N/A * @exception IOException on any I/O error 0N/A * Writes out the <head> and <style> 0N/A * tags, and then invokes writeStyles() to write 0N/A * out all the named styles as the content of the 0N/A * <style> tag. The content is surrounded by 0N/A * valid HTML comment markers to ensure that the 0N/A * that do not support the tag. 0N/A * @exception IOException on any I/O error 0N/A * Writes out all the named styles as the 0N/A * content of the <style> tag. 0N/A * @exception IOException on any I/O error 0N/A * Access to DefaultStyledDocument done to workaround 0N/A * a missing API in styled document to access the 0N/A /** PENDING: Once the name attribute is removed 0N/A from the list we check check for 0. **/ 0N/A * Iterates over the elements in the document 0N/A * and processes elements based on whether they are 0N/A * branch elements or leaf elements. This method specially handles 0N/A * leaf elements that are text. 0N/A * @exception IOException on any I/O error 0N/A This will be a section element for a styled document. 0N/A We represent this element in HTML as the body tags. 0N/A Therefore we ignore it. 0N/A * Emits an end tag for a <p> 0N/A * tag. Before writing out the tag, this method ensures 0N/A * that all other tags that have been opened are 0N/A * appropriately closed off. 0N/A * @exception IOException on any I/O error 0N/A * Emits the start tag for a paragraph. If 0N/A * the paragraph has a named style associated with it, 0N/A * then this method also generates a class attribute for the 0N/A * <p> tag and sets its value to be the name of the 0N/A * @exception IOException on any I/O error 0N/A * Responsible for writing out other non-text leaf 0N/A * @exception IOException on any I/O error 0N/A * Responsible for handling Icon Elements; 0N/A * deliberately unimplemented. How to implement this method is 0N/A * an issue of policy. For example, if you're generating 0N/A * an <img> tag, how should you 0N/A * represent the src attribute (the location of the image)? 0N/A * In certain cases it could be a URL, in others it could 0N/A * be read from a stream. 0N/A * @param elem element of type StyleConstants.IconElementName 0N/A * Responsible for handling Component Elements; 0N/A * deliberately unimplemented. 0N/A * How this method is implemented is a matter of policy. 0N/A * Returns true if the element is a text element. 0N/A * Writes out the attribute set 0N/A * in an HTML-compliant manner. 0N/A * @exception IOException on any I/O error 0N/A * @exception BadLocationException if pos represents an invalid 0N/A * location within the document. 0N/A * bold <b>, italic <i>, and <u> tags for the 0N/A * text based on its attribute settings. 0N/A * @exception IOException on any I/O error 0N/A * Tweaks the appropriate bits of fontMask 0N/A * to reflect whether the text is to be displayed in 0N/A * bold, italic, and/or with an underline. 0N/A * Writes out start tags <u>, <i>, and <b> based on 0N/A * the mask settings. 0N/A * @exception IOException on any I/O error 0N/A * Writes out end tags for <u>, <i>, and <b> based on 0N/A * the mask settings. 0N/A * @exception IOException on any I/O error 0N/A * Writes out the remaining 0N/A * character-level attributes (attributes other than bold, 0N/A * italic, and underline) in an HTML-compliant way. Given that 0N/A * attributes such as font family and font size have no direct 0N/A * mapping to HTML tags, a <span> tag is generated and its 0N/A * style attribute is set to contain the list of remaining 0N/A * attributes just like inline styles. 0N/A * @exception IOException on any I/O error 0N/A * Returns true if we are currently in a <font> tag. 0N/A * This is no longer used, instead <span> will be written out. 0N/A * Writes out an end tag for the <font> tag. 0N/A * @exception IOException on any I/O error 0N/A * This is no longer used, instead <span> will be written out. 0N/A * Writes out a start tag for the <font> tag. 0N/A * Because font tags cannot be nested, 0N/A * this method closes out 0N/A * any enclosing font tag before writing out a 0N/A * @exception IOException on any I/O error 0N/A * Writes out a start tag for the <font> tag. 0N/A * Because font tags cannot be nested, 0N/A * this method closes out 0N/A * any enclosing font tag before writing out a 0N/A * @exception IOException on any I/O error 0N/A * Writes out an end tag for the <span> tag. 0N/A * @exception IOException on any I/O error 0N/A * Adds the style named <code>style</code> to the style mapping. This 0N/A * returns the name that should be used when outputting. CSS does not 0N/A * allow the full Unicode set to be used as a style name. 0N/A * Returns the mapped style name corresponding to <code>style</code>.