/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in) throws Exception { return extractText(in, new RTFParser()); } }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(byte[], java.lang.String) */ @Override public I_CmsExtractionResult extractText(byte[] content, String encoding) throws Exception { String result = ""; try { // RTF always uses ASCII, so we don't need to care about the encoding String input = new String(content); // workaround to remove RTF keywords that cause a NPE in Java 1.4 // this is a known bug in Java 1.4 that was fixed in 1.5 // please see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042109 for the official bug report input = TS_REMOVE_PATTERN.matcher(input).replaceAll(""); // use build in RTF parser from Swing API RTFEditorKit rtfEditor = new RTFEditorKit(); Document doc = rtfEditor.createDefaultDocument(); rtfEditor.read(new StringReader(input), doc, 0); result = doc.getText(0, doc.getLength()); result = removeControlChars(result); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } return new CmsExtractionResult(result); }
textExtractor = CmsExtractorMsOfficeOLE2.getExtractor(); } else if (path1.endsWith(".rtf") && path2.endsWith(".rtf")) { textExtractor = CmsExtractorRtf.getExtractor(); } else if (path1.endsWith(".ppt") && path2.endsWith(".ppt")) { textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
/** * Returns the raw text content of a given vfs resource containing RTF data.<p> * * @see org.opencms.search.documents.I_CmsSearchExtractor#extractContent(CmsObject, CmsResource, CmsSearchIndex) */ public I_CmsExtractionResult extractContent(CmsObject cms, CmsResource resource, CmsSearchIndex index) throws CmsException { CmsFile file = readFile(cms, resource); try { return CmsExtractorRtf.getExtractor().extractText(file.getContents()); } catch (Exception e) { throw new CmsIndexException( Messages.get().container(Messages.ERR_TEXT_EXTRACTION_1, resource.getRootPath()), e); } }
/** * Returns the raw text content of a given vfs resource containing RTF data.<p> * * @see org.opencms.search.documents.I_CmsSearchExtractor#extractContent(CmsObject, CmsResource, CmsSearchIndex) */ public I_CmsExtractionResult extractContent(CmsObject cms, CmsResource resource, CmsSearchIndex index) throws CmsException { logContentExtraction(resource, index); CmsFile file = readFile(cms, resource); try { return CmsExtractorRtf.getExtractor().extractText(file.getContents()); } catch (Exception e) { throw new CmsIndexException( Messages.get().container(Messages.ERR_TEXT_EXTRACTION_1, resource.getRootPath()), e); } }
textExtractor = CmsExtractorMsExcel.getExtractor(); } else if (path1.endsWith(".rtf") && path2.endsWith(".rtf")) { textExtractor = CmsExtractorRtf.getExtractor(); } else if (path1.endsWith(".ppt") && path2.endsWith(".ppt")) { textExtractor = CmsExtractorMsPowerPoint.getExtractor();
textExtractor = CmsExtractorMsOfficeOLE2.getExtractor(); } else if (path1.endsWith(".rtf") && path2.endsWith(".rtf")) { textExtractor = CmsExtractorRtf.getExtractor(); } else if (path1.endsWith(".ppt") && path2.endsWith(".ppt")) { textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();