⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtfdestinationshppict.java

📁 处理PDF
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		}		switch (dataFormat) {		case FORMAT_HEXADECIMAL:			hexChars.append((char) ch);			if (hexChars.length() == 2) {				try {					dataOS.write((char) Integer.parseInt(hexChars.toString(),							16));				} catch (NumberFormatException e) {					e.printStackTrace();				}				hexChars = new StringBuffer();			}			break;		case FORMAT_BINARY:			if (dataOS == null) {				dataOS = new ByteArrayOutputStream();			}			// HGS - FIX ME IF PROBLEM!			dataOS.write((char) (ch));			// PNG signature should be.			//			   (decimal)              137  80  78  71  13  10  26  10			//			   (hexadecimal)           89  50  4e  47  0d  0a  1a  0a			//			   (ASCII C notation)    \211   P   N   G  \r  \n \032 \n			binaryLength--;			if (binaryLength == 0) {				dataFormat = FORMAT_HEXADECIMAL;			}			break;		}		return true;	}	public boolean handleControlWord(RtfCtrlWordData ctrlWordData) {		boolean result = false;		boolean skipCtrlWord = false;		if (this.rtfParser.isImport()) {			skipCtrlWord = true;			if (ctrlWordData.ctrlWord.equals("shppict")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("nonshppict")) /* never gets here because this is a destination set to null */{				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			} else if (ctrlWordData.ctrlWord.equals("blipuid")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			} else if (ctrlWordData.ctrlWord.equals("picprop")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			} else if (ctrlWordData.ctrlWord.equals("pict")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("emfblip")) {				result = true;				pictureType = Image.ORIGINAL_NONE;			} else if (ctrlWordData.ctrlWord.equals("pngblip")) {				result = true;				pictureType = Image.ORIGINAL_PNG;			} else if (ctrlWordData.ctrlWord.equals("jepgblip")) {				result = true;				pictureType = Image.ORIGINAL_JPEG;			} else if (ctrlWordData.ctrlWord.equals("macpict")) {				result = true;				pictureType = Image.ORIGINAL_NONE;			} else if (ctrlWordData.ctrlWord.equals("pmmetafile")) {				result = true;				pictureType = Image.ORIGINAL_NONE;			} else if (ctrlWordData.ctrlWord.equals("wmetafile")) {				result = true;				pictureType = Image.ORIGINAL_WMF;			} else if (ctrlWordData.ctrlWord.equals("dibitmap")) {				result = true;				pictureType = Image.ORIGINAL_NONE;			} else if (ctrlWordData.ctrlWord.equals("wbitmap")) {				result = true;				pictureType = Image.ORIGINAL_BMP;			}			/* bitmap information */			else if (ctrlWordData.ctrlWord.equals("wbmbitspixel")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("wbmplanes")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("wbmwidthbytes")) {				result = true;			} else			/* picture size, scaling and cropping */			if (ctrlWordData.ctrlWord.equals("picw")) {				this.width = ctrlWordData.toLong();				result = true;			} else if (ctrlWordData.ctrlWord.equals("pich")) {				this.height = ctrlWordData.toLong();				result = true;			} else if (ctrlWordData.ctrlWord.equals("picwgoal")) {				this.desiredWidth = ctrlWordData.toLong();				result = true;			} else if (ctrlWordData.ctrlWord.equals("pichgoal")) {				this.desiredHeight = ctrlWordData.toLong();				result = true;			} else if (ctrlWordData.ctrlWord.equals("picscalex")) {				this.scaleX = ctrlWordData.toInteger();				result = true;			} else if (ctrlWordData.ctrlWord.equals("picscaley")) {				this.scaleY = ctrlWordData.toInteger();				result = true;			} else if (ctrlWordData.ctrlWord.equals("picscaled")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("picprop")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			} else if (ctrlWordData.ctrlWord.equals("defshp")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("piccropt")) {				this.cropTop = ctrlWordData.toInteger();				result = true;			} else if (ctrlWordData.ctrlWord.equals("piccropb")) {				this.cropBottom = ctrlWordData.toInteger();				result = true;			} else if (ctrlWordData.ctrlWord.equals("piccropl")) {				this.cropLeft = ctrlWordData.toInteger();				result = true;			} else if (ctrlWordData.ctrlWord.equals("piccropr")) {				this.cropRight = ctrlWordData.toInteger();				result = true;			} else			/* metafile information */			if (ctrlWordData.ctrlWord.equals("picbmp")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("picbpp")) {				result = true;			} else			/* picture data */			if (ctrlWordData.ctrlWord.equals("bin")) {				this.dataFormat = FORMAT_BINARY;				// set length to param				this.binaryLength = ctrlWordData.longValue();				this.rtfParser.setTokeniserStateBinary(binaryLength);				result = true;			} else if (ctrlWordData.ctrlWord.equals("blipupi")) {				result = true;			} else if (ctrlWordData.ctrlWord.equals("blipuid")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			} else if (ctrlWordData.ctrlWord.equals("bliptag")) {				result = true;			}		}		if (this.rtfParser.isConvert()) {			if (ctrlWordData.ctrlWord.equals("shppict")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("nonshppict")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			}			if (ctrlWordData.ctrlWord.equals("blipuid")) {				result = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			}			if (ctrlWordData.ctrlWord.equals("pict")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("emfblip")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("pngblip")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("jepgblip")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("macpict")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("pmmetafile")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("wmetafile")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			}			if (ctrlWordData.ctrlWord.equals("dibitmap")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("wbitmap")) {				result = true;			}			/* bitmap information */			if (ctrlWordData.ctrlWord.equals("wbmbitspixel")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("wbmplanes")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("wbmwidthbytes")) {				result = true;			}			/* picture size, scaling and cropping */			if (ctrlWordData.ctrlWord.equals("picw")) {				this.width = ctrlWordData.toLong();				result = true;			}			if (ctrlWordData.ctrlWord.equals("pich")) {				this.height = ctrlWordData.toLong();				result = true;			}			if (ctrlWordData.ctrlWord.equals("picwgoal")) {				this.desiredWidth = ctrlWordData.toLong();				result = true;			}			if (ctrlWordData.ctrlWord.equals("pichgoal")) {				this.desiredHeight = ctrlWordData.toLong();				result = true;			}			if (ctrlWordData.ctrlWord.equals("picscalex")) {				this.scaleX = ctrlWordData.toInteger();				result = true;			}			if (ctrlWordData.ctrlWord.equals("picscaley")) {				this.scaleY = ctrlWordData.toInteger();				result = true;			}			if (ctrlWordData.ctrlWord.equals("picscaled")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("picprop")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			}			if (ctrlWordData.ctrlWord.equals("defshp")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("piccropt")) {				this.cropTop = ctrlWordData.toInteger();				result = true;			}			if (ctrlWordData.ctrlWord.equals("piccropb")) {				this.cropBottom = ctrlWordData.toInteger();				result = true;			}			if (ctrlWordData.ctrlWord.equals("piccropl")) {				this.cropLeft = ctrlWordData.toInteger();				result = true;			}			if (ctrlWordData.ctrlWord.equals("piccropr")) {				this.cropRight = ctrlWordData.toInteger();				result = true;			}			/* metafile information */			if (ctrlWordData.ctrlWord.equals("picbmp")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("picbpp")) {				result = true;			}			/* picture data */			if (ctrlWordData.ctrlWord.equals("bin")) {				dataFormat = FORMAT_BINARY;				result = true;			}			if (ctrlWordData.ctrlWord.equals("blipupi")) {				result = true;			}			if (ctrlWordData.ctrlWord.equals("blipuid")) {				skipCtrlWord = true;				this.rtfParser.setTokeniserStateSkipGroup();				result = true;			}			if (ctrlWordData.ctrlWord.equals("bliptag")) {				result = true;			}		}		if (!skipCtrlWord) {			switch (this.rtfParser.getConversionType()) {			case RtfParser.TYPE_IMPORT_FULL:				writeBuffer();				writeText(ctrlWordData.toString());				result = true;				break;			case RtfParser.TYPE_IMPORT_FRAGMENT:				writeBuffer();				writeText(ctrlWordData.toString());				result = true;				break;			case RtfParser.TYPE_CONVERT:				result = true;				break;			default: // error because is should be an import or convert				result = false;				break;			}		}		return result;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()	 */	public void setToDefaults() {		this.buffer = new StringBuffer();		//this.data = null;		this.width = null;		this.height = null;		this.desiredWidth = null;		this.desiredHeight = null;		this.scaleX = new Integer(100);		this.scaleY = new Integer(100);		this.scaled = null;		this.inlinePicture = Boolean.FALSE;		this.wordArt = Boolean.FALSE;		this.cropTop = new Integer(0);		this.cropBottom = new Integer(0);		this.cropLeft = new Integer(0);		this.cropRight = new Integer(0);		this.bitmap = false;		this.bbp = 1;		this.dataFormat = FORMAT_HEXADECIMAL;		this.binaryLength = 0;		this.unitsPerInch = null;		this.tag = "";	}	private void writeBuffer() {		writeText(this.buffer.toString());		//setToDefaults();	}	private void writeText(String value) {		if (this.rtfParser.getState().newGroup) {			this.rtfParser.getRtfDocument().add(new RtfDirectContent("{"));			this.rtfParser.getState().newGroup = false;		}		if (value.length() > 0) {			this.rtfParser.getRtfDocument().add(new RtfDirectContent(value));		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -