亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rtfgenerator.java

?? JAVA的一些源碼 JAVA2 STANDARD EDITION DEVELOPMENT KIT 5.0
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* * @(#)RTFGenerator.java	1.13 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.text.rtf;import java.lang.*;import java.util.*;import java.awt.Color;import java.awt.Font;import java.io.OutputStream;import java.io.IOException;import javax.swing.text.*;/** * Generates an RTF output stream (java.io.OutputStream) from rich text * (handed off through a series of LTTextAcceptor calls).  Can be used to * generate RTF from any object which knows how to write to a text acceptor * (e.g., LTAttributedText and LTRTFFilter). * * <p>Note that this is a lossy conversion since RTF's model of * text does not exactly correspond with LightText's.  * * @see LTAttributedText * @see LTRTFFilter * @see LTTextAcceptor * @see java.io.OutputStream */class RTFGenerator extends Object{    /* These dictionaries map Colors, font names, or Style objects       to Integers */    Dictionary colorTable;    int colorCount;    Dictionary fontTable;    int fontCount;    Dictionary styleTable;    int styleCount;    /* where all the text is going */    OutputStream outputStream;    boolean afterKeyword;    MutableAttributeSet outputAttributes;    /* the value of the last \\ucN keyword emitted */    int unicodeCount;    /* for efficiency's sake (ha) */    private Segment workingSegment;    int[] outputConversion;    /** The default color, used for text without an explicit color     *  attribute. */    static public final Color defaultRTFColor = Color.black;    static public final float defaultFontSize = 12f;    static public final String defaultFontFamily = "Helvetica";    /* constants so we can avoid allocating objects in inner loops */    /* these should all be final, but javac seems to be a bit buggy */    static protected Integer One, Zero;    static protected Boolean False;    static protected Float ZeroPointZero;    static private Object MagicToken;    /* An array of character-keyword pairs. This could be done       as a dictionary (and lookup would be quicker), but that       would require allocating an object for every character       written (slow!). */    static class CharacterKeywordPair      { public char character; public String keyword; };    static protected CharacterKeywordPair[] textKeywords;    static {	One = new Integer(1);	Zero = new Integer(0);	False = Boolean.valueOf(false);	MagicToken = new Object();	ZeroPointZero = new Float(0);	Dictionary textKeywordDictionary = RTFReader.textKeywords;        Enumeration keys = textKeywordDictionary.keys();	Vector tempPairs = new Vector();	while(keys.hasMoreElements()) {	    CharacterKeywordPair pair = new CharacterKeywordPair();	    pair.keyword = (String)keys.nextElement();	    pair.character = ((String)textKeywordDictionary.get(pair.keyword)).charAt(0);	    tempPairs.addElement(pair);	}	textKeywords = new CharacterKeywordPair[tempPairs.size()];	tempPairs.copyInto(textKeywords);    }    static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7',				      '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };static public void writeDocument(Document d, OutputStream to)    throws IOException{    RTFGenerator gen = new RTFGenerator(to);    Element root = d.getDefaultRootElement();    gen.examineElement(root);    gen.writeRTFHeader();    gen.writeDocumentProperties(d);    /* TODO this assumes a particular element structure; is there       a way to iterate more generically ? */    int max = root.getElementCount();    for(int idx = 0; idx < max; idx++)	gen.writeParagraphElement(root.getElement(idx));    gen.writeRTFTrailer();}public RTFGenerator(OutputStream to){    colorTable = new Hashtable();    colorTable.put(defaultRTFColor, new Integer(0));    colorCount = 1;    fontTable = new Hashtable();    fontCount = 0;    styleTable = new Hashtable();    /* TODO: put default style in style table */    styleCount = 0;    workingSegment = new Segment();    outputStream = to;    unicodeCount = 1;}public void examineElement(Element el){    AttributeSet a = el.getAttributes();    String fontName;    Object foregroundColor, backgroundColor;    tallyStyles(a);    if (a != null) {	/* TODO: default color must be color 0! */		foregroundColor = StyleConstants.getForeground(a);	if (foregroundColor != null &&	    colorTable.get(foregroundColor) == null) {	    colorTable.put(foregroundColor, new Integer(colorCount));	    colorCount ++;	}		backgroundColor = a.getAttribute(StyleConstants.Background);	if (backgroundColor != null &&	    colorTable.get(backgroundColor) == null) {	    colorTable.put(backgroundColor, new Integer(colorCount));	    colorCount ++;	}		fontName = StyleConstants.getFontFamily(a);		if (fontName == null)	    fontName = defaultFontFamily;	if (fontName != null &&	    fontTable.get(fontName) == null) {	    fontTable.put(fontName, new Integer(fontCount));	    fontCount ++;	}    }    int el_count = el.getElementCount();    for(int el_idx = 0; el_idx < el_count; el_idx ++) {	examineElement(el.getElement(el_idx));    }}private void tallyStyles(AttributeSet a) {    while (a != null) {        if (a instanceof Style) {	    Integer aNum = (Integer)styleTable.get(a);	    if (aNum == null) {		styleCount = styleCount + 1;	        aNum = new Integer(styleCount);		styleTable.put(a, aNum);	    }	}	a = a.getResolveParent();    }}private Style findStyle(AttributeSet a){    while(a != null) {        if (a instanceof Style) {	    Object aNum = styleTable.get(a);	    if (aNum != null)	        return (Style)a;	}	a = a.getResolveParent();    }    return null;}private Integer findStyleNumber(AttributeSet a, String domain){    while(a != null) {        if (a instanceof Style) {	    Integer aNum = (Integer)styleTable.get(a);	    if (aNum != null) {		if (domain == null ||		    domain.equals(a.getAttribute(Constants.StyleType)))		    return aNum;	    }		  	}	a = a.getResolveParent();    }    return null;}static private Object attrDiff(MutableAttributeSet oldAttrs,			       AttributeSet newAttrs, 			       Object key,			       Object dfl){    Object oldValue, newValue;    oldValue = oldAttrs.getAttribute(key);    newValue = newAttrs.getAttribute(key);    if (newValue == oldValue)	return null;    if (newValue == null) {	oldAttrs.removeAttribute(key);	if (dfl != null && !dfl.equals(oldValue))	    return dfl;        else	    return null;    }    if (oldValue == null ||	!equalArraysOK(oldValue, newValue)) {	oldAttrs.addAttribute(key, newValue);	return newValue;    }    return null;}static private boolean equalArraysOK(Object a, Object b){    Object[] aa, bb;    if (a == b)	return true;    if (a == null || b == null)	return false;    if (a.equals(b))	return true;    if (!(a.getClass().isArray() && b.getClass().isArray()))	return false;    aa = (Object[])a;    bb = (Object[])b;    if (aa.length != bb.length)	return false;        int i;    int l = aa.length;    for(i = 0; i < l; i++) {	if (!equalArraysOK(aa[i], bb[i]))	    return false;    }    return true;}    /* Writes a line break to the output file, for ease in debugging */public void writeLineBreak()    throws IOException{    writeRawString("\n");    afterKeyword = false;}public void writeRTFHeader()    throws IOException{    int index;    /* TODO: Should the writer attempt to examine the text it's writing       and pick a character set which will most compactly represent the       document? (currently the writer always uses the ansi character       set, which is roughly ISO-8859 Latin-1, and uses Unicode escapes       for all other characters. However Unicode is a relatively       recent addition to RTF, and not all readers will understand it.) */    writeBegingroup();    writeControlWord("rtf", 1);    writeControlWord("ansi");    outputConversion = outputConversionForName("ansi");    writeLineBreak();    /* write font table */    String[] sortedFontTable = new String[fontCount];    Enumeration fonts = fontTable.keys();    String font;    while(fonts.hasMoreElements()) {	font = (String)fonts.nextElement();	Integer num = (Integer)(fontTable.get(font));	sortedFontTable[num.intValue()] = font;    }    writeBegingroup();    writeControlWord("fonttbl");    for(index = 0; index < fontCount; index ++) {	writeControlWord("f", index);	writeControlWord("fnil");  /* TODO: supply correct font style */	writeText(sortedFontTable[index]);	writeText(";");    }    writeEndgroup();    writeLineBreak();    /* write color table */    if (colorCount > 1) {	Color[] sortedColorTable = new Color[colorCount];	Enumeration colors = colorTable.keys();	Color color;	while(colors.hasMoreElements()) {	    color = (Color)colors.nextElement();	    Integer num = (Integer)(colorTable.get(color));	    sortedColorTable[num.intValue()] = color;	}	writeBegingroup();	writeControlWord("colortbl");	for(index = 0; index < colorCount; index ++) {	    color = sortedColorTable[index];	    if (color != null) {		writeControlWord("red", color.getRed());		writeControlWord("green", color.getGreen());		writeControlWord("blue", color.getBlue());	    }	    writeRawString(";");	}	writeEndgroup();	writeLineBreak();    }    /* write the style sheet */    if (styleCount > 1) {	writeBegingroup();	writeControlWord("stylesheet");	Enumeration styles = styleTable.keys();	while(styles.hasMoreElements()) {	    Style style = (Style)styles.nextElement();	    int styleNumber = ((Integer)styleTable.get(style)).intValue();	    writeBegingroup();	    String styleType = (String)style.getAttribute(Constants.StyleType);	    if (styleType == null)	        styleType = Constants.STParagraph;	    if (styleType.equals(Constants.STCharacter)) {	        writeControlWord("*");		writeControlWord("cs", styleNumber);	    } else if(styleType.equals(Constants.STSection)) {	        writeControlWord("*");		writeControlWord("ds", styleNumber);	    } else {	        writeControlWord("s", styleNumber);	    }        	    AttributeSet basis = style.getResolveParent();	    MutableAttributeSet goat;	    if (basis == null) {	        goat = new SimpleAttributeSet();	    } else {	        goat = new SimpleAttributeSet(basis);	    }	    updateSectionAttributes(goat, style, false);	    updateParagraphAttributes(goat, style, false);	    updateCharacterAttributes(goat, style, false);	    basis = style.getResolveParent();	    if (basis != null && basis instanceof Style) {	        Integer basedOn = (Integer)styleTable.get(basis);		if (basedOn != null) {		    writeControlWord("sbasedon", basedOn.intValue());		}	    }	    	    Style nextStyle = (Style)style.getAttribute(Constants.StyleNext);	    if (nextStyle != null) {	        Integer nextNum = (Integer)styleTable.get(nextStyle);		if (nextNum != null) {		    writeControlWord("snext", nextNum.intValue());		}	    }	    	    Boolean hidden = (Boolean)style.getAttribute(Constants.StyleHidden);	    if (hidden != null && hidden.booleanValue())	        writeControlWord("shidden");	    Boolean additive = (Boolean)style.getAttribute(Constants.StyleAdditive);	    if (additive != null && additive.booleanValue())	        writeControlWord("additive");	    	    writeText(style.getName());	    writeText(";");	    writeEndgroup();	}	writeEndgroup();	writeLineBreak();    }    outputAttributes = new SimpleAttributeSet();}void writeDocumentProperties(Document doc)    throws IOException{    /* Write the document properties */    int i;    boolean wroteSomething = false;        for(i = 0; i < RTFAttributes.attributes.length; i++) {        RTFAttribute attr = RTFAttributes.attributes[i];	if (attr.domain() != RTFAttribute.D_DOCUMENT)	    continue;	Object prop = doc.getProperty(attr.swingName());	boolean ok = attr.writeValue(prop, this, false);	if (ok)	    wroteSomething = true;    }    if (wroteSomething)        writeLineBreak();}public void writeRTFTrailer()    throws IOException{    writeEndgroup();    writeLineBreak();}protected void checkNumericControlWord(MutableAttributeSet currentAttributes,				       AttributeSet newAttributes,				       Object attrName,				       String controlWord,				       float dflt, float scale)    throws IOException{    Object parm;    if ((parm = attrDiff(currentAttributes, newAttributes,			 attrName, MagicToken)) != null) {	float targ;	if (parm == MagicToken)	    targ = dflt;	else	    targ = ((Number)parm).floatValue();	writeControlWord(controlWord, Math.round(targ * scale));    }}protected void checkControlWord(MutableAttributeSet currentAttributes,				AttributeSet newAttributes,				RTFAttribute word)    throws IOException{    Object parm;    if ((parm = attrDiff(currentAttributes, newAttributes,			 word.swingName(), MagicToken)) != null) {        if (parm == MagicToken)	    parm = null;	word.writeValue(parm, this, true);    }}protected void checkControlWords(MutableAttributeSet currentAttributes,				 AttributeSet newAttributes,				 RTFAttribute words[],				 int domain)    throws IOException{    int wordIndex;    int wordCount = words.length;    for(wordIndex = 0; wordIndex < wordCount; wordIndex++) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区性视频| 国产精品美日韩| 日本一区中文字幕| 日本久久电影网| 亚洲人精品一区| 99精品欧美一区二区三区小说| 欧美成人一区二区三区片免费 | www一区二区| 麻豆91在线看| 久久综合色播五月| 国产传媒一区在线| 日韩一区二区三区高清免费看看| 亚洲色图在线视频| 成人久久18免费网站麻豆 | 亚洲男人的天堂在线观看| 丁香啪啪综合成人亚洲小说| 亚洲欧美日韩系列| aaa亚洲精品一二三区| 亚洲在线免费播放| 精品国产1区2区3区| 99久久精品99国产精品| 视频一区免费在线观看| 国产欧美一区二区在线| 欧美吻胸吃奶大尺度电影| 精品一区二区三区在线播放视频| 欧美一区二区三区精品| 精品国产乱码久久久久久久久| 亚洲成人免费av| 欧美一区二区三区精品| 日本亚洲电影天堂| 日韩欧美电影在线| 99久久精品免费看| 奇米在线7777在线精品 | 日韩一卡二卡三卡四卡| 麻豆91小视频| 中文字幕人成不卡一区| 日韩欧美综合在线| 91丝袜美腿高跟国产极品老师| 亚洲精品视频自拍| 欧美r级在线观看| 色94色欧美sute亚洲线路一ni| 亚洲三级在线看| 欧美日韩一卡二卡三卡| 黄一区二区三区| 最新成人av在线| 91精品国产综合久久精品图片| 日韩中文字幕不卡| 欧美一区二区三区日韩| 国产盗摄女厕一区二区三区| 国产亚洲短视频| 成人黄色在线看| 理论电影国产精品| 国产精品丝袜一区| 日韩欧美国产一区二区三区 | 欧美三级欧美一级| 成人午夜在线播放| 美美哒免费高清在线观看视频一区二区 | 欧美一区二区性放荡片| 99久久久无码国产精品| 日韩成人dvd| 亚洲欧洲综合另类| 国产色综合久久| 欧美一级爆毛片| 欧美视频第二页| 91老师国产黑色丝袜在线| 国产成人精品免费| 免费成人你懂的| 国产日产欧美精品一区二区三区| 99re成人精品视频| 国产成人在线影院| 狠狠色丁香婷婷综合| 五月综合激情婷婷六月色窝| 综合自拍亚洲综合图不卡区| 91高清在线观看| 国产风韵犹存在线视精品| 一区二区三区国产| 欧美激情中文不卡| 欧美剧情片在线观看| 国产成人鲁色资源国产91色综| 亚洲综合色婷婷| 亚洲视频一区二区在线| 日韩一区二区在线看| 欧美性猛片aaaaaaa做受| 国产一区二区三区四| 美女免费视频一区| 男女视频一区二区| 日韩主播视频在线| 午夜激情久久久| 欧美视频精品在线观看| 91精品办公室少妇高潮对白| 久草热8精品视频在线观看| 爽好久久久欧美精品| 亚洲国产另类精品专区| 夜夜操天天操亚洲| 亚洲黄色性网站| 一区二区三区中文字幕精品精品 | 91精品在线免费| 欧美日韩精品一区二区在线播放| 国产福利一区在线观看| 国产精品亚洲一区二区三区妖精| 五月天丁香久久| 亚洲成人自拍网| 日韩精品一级二级| 日韩高清一区二区| 蜜桃视频一区二区三区在线观看| 亚洲精品日韩一| 一个色在线综合| 国产精品入口麻豆九色| 国产精品色哟哟网站| 欧美国产成人精品| 欧美一区二区在线视频| 日韩欧美的一区二区| 欧美精品一级二级| 欧美日韩成人一区| 91精品蜜臀在线一区尤物| 欧美日韩在线不卡| 欧美无乱码久久久免费午夜一区| 大美女一区二区三区| 精品一区二区三区蜜桃| 精品午夜久久福利影院| 亚洲自拍偷拍网站| 夜夜精品视频一区二区| 五月天一区二区| 久久精品二区亚洲w码| 极品少妇一区二区| 国产麻豆精品久久一二三| 成人午夜短视频| 91在线视频网址| 色综合中文字幕| 欧美色涩在线第一页| 欧美在线免费观看视频| 欧美色图在线观看| 日韩欧美一级二级| 欧美一级一区二区| 久久久久国色av免费看影院| 欧美一区二区视频在线观看2022| 99r国产精品| 色久综合一二码| 在线中文字幕不卡| 欧美一区二区成人| 日本一区二区三区免费乱视频| 久久日韩粉嫩一区二区三区| 国产精品毛片高清在线完整版| 国产农村妇女精品| 夜夜嗨av一区二区三区中文字幕 | 成人午夜视频网站| 色婷婷国产精品综合在线观看| 99视频有精品| 欧美日韩精品一区二区| 久久午夜电影网| 亚洲欧美激情插| 欧美aⅴ一区二区三区视频| 狠狠色综合日日| 色综合久久六月婷婷中文字幕| 成人综合在线网站| 91在线视频在线| 日韩一区二区三区电影在线观看| 日韩欧美在线不卡| 国产精品高潮久久久久无| 国产精品国产自产拍在线| 亚洲欧洲中文日韩久久av乱码| ...中文天堂在线一区| 一区二区三区不卡在线观看 | 国产精品一区免费在线观看| 免费观看30秒视频久久| 丁香网亚洲国际| 欧美群妇大交群的观看方式| 国产午夜精品美女毛片视频| 国产精品久99| 午夜日韩在线观看| 国产在线精品不卡| 国内精品国产成人| 91亚洲精品久久久蜜桃| 日韩精品一区二区三区视频播放| 日韩一区二区麻豆国产| 日韩一区二区三区电影| 国产精品福利电影一区二区三区四区| 久久久久国产精品厨房| 亚洲宅男天堂在线观看无病毒| 亚洲一区二区三区激情| 国产成人8x视频一区二区| 欧美肥妇毛茸茸| 1000精品久久久久久久久| 偷拍日韩校园综合在线| 成人在线视频首页| 欧美日韩免费不卡视频一区二区三区| 欧美日韩国产综合草草| 久久欧美中文字幕| 亚洲午夜激情av| 国产一区二区三区免费播放| 欧美日韩高清一区| 国产精品久久久久影院色老大| 中文字幕日韩精品一区| 奇米影视一区二区三区| 黄一区二区三区| 欧美三级视频在线| 国产欧美日韩中文久久| 日韩精品视频网站| 91在线精品一区二区| 精品国产电影一区二区|