001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo 018 * Antoine Taillefer 019 */ 020 021package org.nuxeo.ecm.core.convert.plugins.text.extractors; 022 023import java.io.IOException; 024import java.util.zip.ZipEntry; 025import java.util.zip.ZipInputStream; 026 027import org.xml.sax.InputSource; 028import org.xml.sax.SAXException; 029import org.xml.sax.XMLReader; 030 031/** 032 * Based on Apache JackRabbit OOo converter. 033 */ 034public class OOo2TextConverter extends XmlZip2TextConverter { 035 036 private static final String CONTENT_ZIP_ENTRY_NAME = "content.xml"; 037 038 protected void readXmlZipContent(ZipInputStream zis, XMLReader reader, StringBuilder sb) throws IOException, 039 SAXException { 040 041 ZipEntry zipEntry = zis.getNextEntry(); 042 while (zipEntry != null) { 043 if (CONTENT_ZIP_ENTRY_NAME.equals(zipEntry.getName())) { 044 OOoXmlContentHandler contentHandler = new OOoXmlContentHandler(); 045 reader.setContentHandler(contentHandler); 046 reader.parse(new InputSource(zis)); 047 sb.append(contentHandler.getContent()); 048 break; 049 } 050 zipEntry = zis.getNextEntry(); 051 } 052 } 053}