diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 26e10deab..2730545cc 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + Implement the load method on MemoryPackagePart 50967 - Support for continued ExtSSTRecords 48968 - Support for HOUR, MINUTE and SECOND date formulas Added NPOIFS constructors to most POIDocument classes and their extractors, and more widely deprecated the Document(DirectoryNode, POIFSFileSystem) constructor in favour of the more general Document(DirectoryNode) one diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java index 0d7f8d39c..f950e2ca3 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java @@ -18,6 +18,8 @@ package org.apache.poi.openxml4j.opc.internal; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -27,6 +29,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagePartName; import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller; +import org.apache.poi.util.IOUtils; /** * Memory version of a package part. Use to @@ -111,7 +114,20 @@ public final class MemoryPackagePart extends PackagePart { @Override public boolean load(InputStream ios) throws InvalidFormatException { - throw new InvalidFormatException("Method not implemented"); + // Grab the data + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + IOUtils.copy(ios, baos); + } catch(IOException e) { + throw new InvalidFormatException(e.getMessage()); + } + + // Save it + data = baos.toByteArray(); + length = data.length; + + // All done + return true; } @Override