aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2023-10-26 18:20:33 +0000
committerPJ Fanning <fanningpj@apache.org>2023-10-26 18:20:33 +0000
commit89ccbec1dd0f5058413ae0bc4196c26dd7fb5fef (patch)
tree1c657e4129dca495ffdfaee050c7fb29627724ad /poi-ooxml
parent070393a06fd1285d5dbeddca88c738cb93f5732e (diff)
downloadpoi-89ccbec1dd0f5058413ae0bc4196c26dd7fb5fef.tar.gz
poi-89ccbec1dd0f5058413ae0bc4196c26dd7fb5fef.zip
[bug-67579] add new XWPFDocument/XMLSlideShow constructor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913363 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java19
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java19
2 files changed, 32 insertions, 6 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
index 38562f5a58..77f7c0e61c 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
@@ -129,14 +129,27 @@ public class XMLSlideShow extends POIXMLDocument
}
/**
- * @param is InputStream
+ * @param stream InputStream, which is closed after it is read
* @throws IOException If reading data from the stream fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
* @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
- public XMLSlideShow(InputStream is) throws IOException {
- this(PackageHelper.open(is));
+ public XMLSlideShow(InputStream stream) throws IOException {
+ this(stream, true);
+ }
+
+ /**
+ * @param stream InputStream
+ * @param closeStream Whether to close the InputStream
+ * @throws IOException If reading data from the stream fails
+ * @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * input format
+ * @since POI 5.2.5
+ */
+ public XMLSlideShow(InputStream stream, boolean closeStream) throws IOException {
+ this(PackageHelper.open(stream, closeStream));
}
static OPCPackage empty() {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
index c9d84c426e..544bd209cf 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -150,14 +150,27 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
/**
- * @param is The InputStream to read data from
+ * @param stream The InputStream to read data from - the stream is closed
* @throws IOException If reading data from the stream fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
* @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
- public XWPFDocument(InputStream is) throws IOException {
- super(PackageHelper.open(is));
+ public XWPFDocument(InputStream stream) throws IOException {
+ this(stream, true);
+ }
+
+ /**
+ * @param stream The InputStream to read data from
+ * @param closeStream Whether to close the InputStream
+ * @throws IOException If reading data from the stream fails
+ * @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * input format
+ * @since POI 5.2.5
+ */
+ public XWPFDocument(InputStream stream, boolean closeStream) throws IOException {
+ super(PackageHelper.open(stream, closeStream));
//build a tree of POIXMLDocumentParts, this workbook being the root
load(XWPFFactory.getInstance());