git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1615781 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_11_BETA2
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; | import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; | ||||
import org.apache.poi.poifs.common.POIFSConstants; | import org.apache.poi.poifs.common.POIFSConstants; | ||||
import org.apache.poi.util.IOUtils; | import org.apache.poi.util.IOUtils; | ||||
import org.apache.xmlbeans.impl.common.SystemCache; | |||||
public abstract class POIXMLDocument extends POIXMLDocumentPart{ | public abstract class POIXMLDocument extends POIXMLDocumentPart{ | ||||
public static final String DOCUMENT_CREATOR = "Apache POI"; | public static final String DOCUMENT_CREATOR = "Apache POI"; | ||||
protected POIXMLDocument(OPCPackage pkg) { | protected POIXMLDocument(OPCPackage pkg) { | ||||
super(pkg); | super(pkg); | ||||
this.pkg = pkg; | this.pkg = pkg; | ||||
// Workaround for XMLBEANS-512 - ensure that when we parse | |||||
// the file, we start with a fresh XML Parser each time, | |||||
// and avoid the risk of getting a SaxHandler that's in error | |||||
SystemCache.get().setSaxLoader(null); | |||||
} | } | ||||
/** | /** |
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.POIXMLDocumentPart; | |||||
import org.apache.poi.openxml4j.opc.PackagePart; | |||||
import org.apache.poi.openxml4j.opc.PackageRelationship; | |||||
import org.apache.xmlbeans.XmlException; | import org.apache.xmlbeans.XmlException; | ||||
import org.apache.xmlbeans.XmlOptions; | import org.apache.xmlbeans.XmlOptions; | ||||
import org.apache.poi.POIXMLDocumentPart; | |||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument; | ||||
import org.apache.poi.openxml4j.opc.PackagePart; | |||||
import org.apache.poi.openxml4j.opc.PackageRelationship; | |||||
/** | /** |
import org.apache.poi.EncryptedDocumentException; | import org.apache.poi.EncryptedDocumentException; | ||||
import org.apache.poi.POIDataSamples; | import org.apache.poi.POIDataSamples; | ||||
import org.apache.poi.POIXMLDocumentPart; | import org.apache.poi.POIXMLDocumentPart; | ||||
import org.apache.poi.POIXMLException; | |||||
import org.apache.poi.POIXMLProperties; | import org.apache.poi.POIXMLProperties; | ||||
import org.apache.poi.hssf.HSSFTestDataSamples; | import org.apache.poi.hssf.HSSFTestDataSamples; | ||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||||
assertEquals(null, props.getCoreProperties().getDescription()); | assertEquals(null, props.getCoreProperties().getDescription()); | ||||
// Now check the spreadsheet itself | // Now check the spreadsheet itself | ||||
// TODO Fix then enable | |||||
/* | |||||
try { | try { | ||||
new XSSFWorkbook(pkg); | new XSSFWorkbook(pkg); | ||||
fail("Should fail as too much expansion occurs"); | fail("Should fail as too much expansion occurs"); | ||||
} catch(POIXMLException e) { | } catch(POIXMLException e) { | ||||
// Expected | // Expected | ||||
} */ | |||||
} | |||||
// Try with one with the entities in the Content Types | // Try with one with the entities in the Content Types | ||||
try { | try { | ||||
} catch(Exception e) { | } catch(Exception e) { | ||||
// Expected | // Expected | ||||
} | } | ||||
// Check we can still parse valid files after all that | |||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx"); | |||||
assertEquals(3, wb.getNumberOfSheets()); | |||||
} | } | ||||
/** | /** |