poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r898927 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/ ooxml/java/org/apache/poi/openxml4j/opc/ ooxml/java/org/apache/poi/util/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/java/org/apache/poi/xwpf/usermodel/
Date Wed, 13 Jan 2010 20:24:26 GMT
Author: yegor
Date: Wed Jan 13 20:24:15 2010
New Revision: 898927

URL: http://svn.apache.org/viewvc?rev=898927&view=rev
Log:
Avoid creating temporary files when opening OPC packages from input stream

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
    poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Jan 13 20:24:15 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-SNAPSHOT" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Avoid creating temporary files when
opening OPC packages from input stream</action>
            <action dev="POI-DEVELOPERS" type="add">Improved how HSMF handles multiple
recipients</action>
            <action dev="POI-DEVELOPERS" type="add">Add PublisherTextExtractor support
to ExtractorFactory</action>
            <action dev="POI-DEVELOPERS" type="add">Add XSLF support for text extraction
from tables</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java Wed Jan 13 20:24:15 2010
@@ -173,23 +173,6 @@
      */
     public abstract List<PackagePart> getAllEmbedds() throws OpenXML4JException;
 
-    /**
-     * YK: current implementation of OpenXML4J is funny.
-     * Packages opened by Package.open(InputStream is) are read-only,
-     * there is no way to change or even save such an instance in a OutputStream.
-     * The workaround is to create a copy via a temp file
-     */
-    protected static OPCPackage ensureWriteAccess(OPCPackage pkg) throws IOException {
-        if(pkg.getPackageAccess() == PackageAccess.READ){
-            try {
-                return PackageHelper.clone(pkg);
-            } catch (OpenXML4JException e){
-                throw new POIXMLException(e);
-            }
-        }
-        return pkg;
-    }
-
     protected final void load(POIXMLFactory factory) throws IOException {
     	Map<PackagePart, POIXMLDocumentPart> context = new HashMap<PackagePart, POIXMLDocumentPart>();
         try {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java Wed Jan 13 20:24:15
2010
@@ -217,7 +217,7 @@
 	 */
 	public static OPCPackage open(InputStream in) throws InvalidFormatException,
 			IOException {
-		OPCPackage pack = new ZipPackage(in, PackageAccess.READ);
+		OPCPackage pack = new ZipPackage(in, PackageAccess.READ_WRITE);
 		if (pack.partList == null) {
 			pack.getParts();
 		}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java Wed Jan 13 20:24:15 2010
@@ -34,23 +34,9 @@
  */
 public final class PackageHelper {
 
-    /**
-     * Clone the specified package.
-     *
-     * @param   pkg   the package to clone
-     * @return  the cloned package
-     */
-    public static OPCPackage clone(OPCPackage pkg) throws OpenXML4JException, IOException
{
-        return clone(pkg, createTempFile());
-    }
-
     public static OPCPackage open(InputStream is) throws IOException {
-        File file = TempFile.createTempFile("poi-ooxml-", ".tmp");
-        FileOutputStream out = new FileOutputStream(file);
-        IOUtils.copy(is, out);
-        out.close();
         try {
-            return OPCPackage.open(file.getAbsolutePath());
+            return OPCPackage.open(is);
         } catch (InvalidFormatException e){
             throw new POIXMLException(e);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Wed Jan 13 20:24:15
2010
@@ -166,7 +166,7 @@
      * @param pkg the OpenXML4J <code>Package</code> object.
      */
     public XSSFWorkbook(OPCPackage pkg) throws IOException {
-        super(ensureWriteAccess(pkg));
+        super(pkg);
 
         //build a tree of POIXMLDocumentParts, this workbook being the root
         load(XSSFFactory.getInstance());
@@ -174,7 +174,7 @@
 
     public XSSFWorkbook(InputStream is) throws IOException {
         super(PackageHelper.open(is));
-
+        
         //build a tree of POIXMLDocumentParts, this workbook being the root
         load(XSSFFactory.getInstance());
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=898927&r1=898926&r2=898927&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Wed Jan 13 20:24:15
2010
@@ -88,7 +88,7 @@
     private XWPFHeaderFooterPolicy headerFooterPolicy;
 
     public XWPFDocument(OPCPackage pkg) throws IOException {
-        super(ensureWriteAccess(pkg));
+        super(pkg);
 
         //build a tree of POIXMLDocumentParts, this document being the root
         load(XWPFFactory.getInstance());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message