diff --git a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java index 857f0dad2..21228f49f 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java @@ -61,6 +61,7 @@ public class POIXMLDocumentPart { DEFAULT_XML_OPTIONS.setUseDefaultNamespace(); DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces(); DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8"); + DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096); } private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT; diff --git a/src/ooxml/java/org/apache/poi/POIXMLProperties.java b/src/ooxml/java/org/apache/poi/POIXMLProperties.java index 27c1c49d1..e6f68691e 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLProperties.java +++ b/src/ooxml/java/org/apache/poi/POIXMLProperties.java @@ -33,6 +33,7 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; import org.apache.poi.openxml4j.util.Nullable; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty; @@ -73,7 +74,7 @@ public class POIXMLProperties { if(extRel.size() == 1) { extPart = pkg.getPart( extRel.getRelationship(0)); org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.parse( - extPart.getInputStream() + extPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); ext = new ExtendedProperties(props); } else { @@ -87,7 +88,7 @@ public class POIXMLProperties { if(custRel.size() == 1) { custPart = pkg.getPart( custRel.getRelationship(0)); org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse( - custPart.getInputStream() + custPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); cust = new CustomProperties(props); } else { diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java index b778c1032..37447cea5 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.poifs.crypt.ChainingMode; import org.apache.poi.poifs.crypt.CipherAlgorithm; import org.apache.poi.poifs.crypt.EncryptionInfo; @@ -111,7 +112,7 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder { protected static EncryptionDocument parseDescriptor(String descriptor) { try { - return EncryptionDocument.Factory.parse(descriptor); + return EncryptionDocument.Factory.parse(descriptor, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); } @@ -119,7 +120,7 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder { protected static EncryptionDocument parseDescriptor(InputStream descriptor) { try { - return EncryptionDocument.Factory.parse(descriptor); + return EncryptionDocument.Factory.parse(descriptor, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (Exception e) { throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java index c6efe6077..9526c968b 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java @@ -68,6 +68,7 @@ import javax.xml.xpath.XPathFactory; import org.apache.jcp.xml.dsig.internal.dom.DOMReference; import org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo; import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.ContentTypes; import org.apache.poi.openxml4j.opc.OPCPackage; @@ -212,7 +213,7 @@ public class SignatureInfo implements SignatureConfigurable { */ public SignatureDocument getSignatureDocument() throws IOException, XmlException { // TODO: check for XXE - return SignatureDocument.Factory.parse(signaturePart.getInputStream()); + return SignatureDocument.Factory.parse(signaturePart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } /** @@ -630,7 +631,7 @@ public class SignatureInfo implements SignatureConfigurable { try { OutputStream os = sigPart.getOutputStream(); - SignatureDocument sigDoc = SignatureDocument.Factory.parse(document); + SignatureDocument sigDoc = SignatureDocument.Factory.parse(document, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); sigDoc.save(os, xo); os.close(); } catch (Exception e) { diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/Office2010SignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/Office2010SignatureFacet.java index 3ea2e27af..de12275c4 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/Office2010SignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/Office2010SignatureFacet.java @@ -26,6 +26,7 @@ package org.apache.poi.poifs.crypt.dsig.facets; import javax.xml.crypto.MarshalException; +import org.apache.poi.POIXMLDocumentPart; import org.apache.xmlbeans.XmlException; import org.etsi.uri.x01903.v13.QualifyingPropertiesType; import org.etsi.uri.x01903.v13.UnsignedPropertiesType; @@ -56,7 +57,7 @@ public class Office2010SignatureFacet extends SignatureFacet { QualifyingPropertiesType qualProps; try { - qualProps = QualifyingPropertiesType.Factory.parse(nl.item(0)); + qualProps = QualifyingPropertiesType.Factory.parse(nl.item(0), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new MarshalException(e); } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java index 493afb843..2427f09fd 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java @@ -46,6 +46,7 @@ import java.util.UUID; import javax.xml.crypto.MarshalException; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.poifs.crypt.dsig.services.RevocationData; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -128,7 +129,7 @@ public class XAdESXLSignatureFacet extends SignatureFacet { NodeList qualNl = document.getElementsByTagNameNS(XADES_132_NS, "QualifyingProperties"); if (qualNl.getLength() == 1) { try { - qualDoc = QualifyingPropertiesDocument.Factory.parse(qualNl.item(0)); + qualDoc = QualifyingPropertiesDocument.Factory.parse(qualNl.item(0), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new MarshalException(e); } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java index dea586463..656672d50 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java @@ -48,6 +48,7 @@ import javax.xml.crypto.dsig.TransformException; import javax.xml.crypto.dsig.TransformService; import javax.xml.crypto.dsig.spec.TransformParameterSpec; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; import org.apache.poi.util.XmlSort; @@ -141,7 +142,7 @@ public class RelationshipTransformService extends TransformService { Node parentNode = domParent.getNode(); try { - TransformDocument transDoc = TransformDocument.Factory.parse(parentNode); + TransformDocument transDoc = TransformDocument.Factory.parse(parentNode, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); XmlObject xoList[] = transDoc.getTransform().selectChildren(RelationshipReferenceDocument.type.getDocumentElementName()); if (xoList.length == 0) { LOG.log(POILogger.WARN, "no RelationshipReference/@SourceId parameters present"); @@ -187,7 +188,7 @@ public class RelationshipTransformService extends TransformService { RelationshipsDocument relDoc; try { - relDoc = RelationshipsDocument.Factory.parse(octetStream); + relDoc = RelationshipsDocument.Factory.parse(octetStream, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (Exception e) { throw new TransformException(e.getMessage(), e); } diff --git a/src/ooxml/java/org/apache/poi/util/DocumentHelper.java b/src/ooxml/java/org/apache/poi/util/DocumentHelper.java index ac98b4455..492e54914 100644 --- a/src/ooxml/java/org/apache/poi/util/DocumentHelper.java +++ b/src/ooxml/java/org/apache/poi/util/DocumentHelper.java @@ -33,7 +33,7 @@ import org.xml.sax.SAXException; public final class DocumentHelper { private static POILogger logger = POILogFactory.getLogger(DocumentHelper.class); - + private DocumentHelper() {} /** diff --git a/src/ooxml/java/org/apache/poi/util/XmlSort.java b/src/ooxml/java/org/apache/poi/util/XmlSort.java index 1a88b0930..93ff71d69 100644 --- a/src/ooxml/java/org/apache/poi/util/XmlSort.java +++ b/src/ooxml/java/org/apache/poi/util/XmlSort.java @@ -23,6 +23,7 @@ import java.util.Comparator; import javax.xml.namespace.QName; +import org.apache.poi.POIXMLDocumentPart; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; @@ -49,7 +50,7 @@ public final class XmlSort File f = new File(args[0]); try { - XmlObject docInstance = XmlObject.Factory.parse(f); + XmlObject docInstance = XmlObject.Factory.parse(f, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); XmlObject element = null; if (args.length > 1) { diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java index f61d743a1..e896420e9 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java @@ -41,6 +41,7 @@ import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.sl.usermodel.Resources; import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; import org.apache.poi.util.LittleEndian; @@ -127,7 +128,7 @@ implements SlideShow { protected void onDocumentRead() throws IOException { try { PresentationDocument doc = - PresentationDocument.Factory.parse(getCorePart().getInputStream()); + PresentationDocument.Factory.parse(getCorePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _presentation = doc.getPresentation(); Map masterMap = new HashMap(); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java index 702d54427..5ded5a7ae 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java @@ -23,6 +23,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.Internal; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; @@ -65,7 +66,7 @@ public final class XSLFChart extends POIXMLDocumentPart { protected XSLFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); - chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream()).getChartSpace(); + chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartSpace(); chart = chartSpace.getChart(); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java index e52b9ec65..4274ba784 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java @@ -23,6 +23,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthor; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthorList; @@ -53,7 +54,7 @@ public class XSLFCommentAuthors extends POIXMLDocumentPart { super(part, rel); CmAuthorLstDocument doc = - CmAuthorLstDocument.Factory.parse(getPackagePart().getInputStream()); + CmAuthorLstDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _authors = doc.getCmAuthorLst(); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java index df3ca7ad0..16190c64c 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java @@ -21,6 +21,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.presentationml.x2006.main.CTComment; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList; @@ -53,7 +54,7 @@ public class XSLFComments extends POIXMLDocumentPart { super(part, rel); CmLstDocument doc = - CmLstDocument.Factory.parse(getPackagePart().getInputStream()); + CmLstDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _comments = doc.getCmLst(); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java index 0033665aa..7f87f6d69 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.util.Beta; import org.apache.xmlbeans.XmlCursor; @@ -67,7 +68,7 @@ public class XSLFCommonSlideData { if (o instanceof XmlAnyTypeImpl) { // Pesky XmlBeans bug - see Bugzilla #49934 try { - o = CTTable.Factory.parse(o.toString()); + o = CTTable.Factory.parse(o.toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new POIXMLException(e); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java index 0acb411fc..22b1607dd 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java @@ -25,6 +25,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.Notes; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData; import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide; @@ -56,7 +57,7 @@ implements Notes { super(part, rel); NotesDocument doc = - NotesDocument.Factory.parse(getPackagePart().getInputStream()); + NotesDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _notes = doc.getNotes(); setCommonSlideData(_notes.getCSld()); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java index 5da683ce5..b3d1777ac 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java @@ -25,6 +25,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.MasterSheet; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping; import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMaster; @@ -60,7 +61,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument; protected XSLFNotesMaster(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); NotesMasterDocument doc = - NotesMasterDocument.Factory.parse(getPackagePart().getInputStream()); + NotesMasterDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _slide = doc.getNotesMaster(); setCommonSlideData(_slide.getCSld()); } @@ -73,7 +74,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument; try { try { - NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is); + NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); CTNotesMaster slide = doc.getNotesMaster(); return slide; } finally { diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java index cb66f697f..cba6f3e61 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java @@ -27,6 +27,7 @@ import org.apache.poi.sl.draw.Drawable; import org.apache.poi.sl.usermodel.Notes; import org.apache.poi.sl.usermodel.Slide; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties; @@ -70,7 +71,7 @@ implements Slide { super(part, rel); SldDocument doc = - SldDocument.Factory.parse(getPackagePart().getInputStream()); + SldDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _slide = doc.getSld(); setCommonSlideData(_slide.getCSld()); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java index 48c5b2035..c72819708 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java @@ -23,6 +23,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.MasterSheet; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.Internal; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground; @@ -44,7 +45,7 @@ implements MasterSheet { public XSLFSlideLayout(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); SldLayoutDocument doc = - SldLayoutDocument.Factory.parse(getPackagePart().getInputStream()); + SldLayoutDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _layout = doc.getSldLayout(); setCommonSlideData(_layout.getCSld()); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java index e16b48031..e6f37386b 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java @@ -26,6 +26,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.MasterSheet; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle; @@ -69,7 +70,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument; protected XSLFSlideMaster(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); SldMasterDocument doc = - SldMasterDocument.Factory.parse(getPackagePart().getInputStream()); + SldMasterDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _slide = doc.getSldMaster(); setCommonSlideData(_slide.getCSld()); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java index 79a5bd6d7..264631641 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java @@ -21,6 +21,7 @@ import java.util.LinkedList; import java.util.List; import org.apache.poi.POIXMLDocument; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.OPCPackage; @@ -73,7 +74,7 @@ public class XSLFSlideShow extends POIXMLDocument { } presentationDoc = - PresentationDocument.Factory.parse(getCorePart().getInputStream()); + PresentationDocument.Factory.parse(getCorePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); embedds = new LinkedList(); for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) { @@ -145,7 +146,7 @@ public class XSLFSlideShow extends POIXMLDocument { public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException { PackagePart masterPart = getSlideMasterPart(master); SldMasterDocument masterDoc = - SldMasterDocument.Factory.parse(masterPart.getInputStream()); + SldMasterDocument.Factory.parse(masterPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); return masterDoc.getSldMaster(); } @@ -165,7 +166,7 @@ public class XSLFSlideShow extends POIXMLDocument { public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException { PackagePart slidePart = getSlidePart(slide); SldDocument slideDoc = - SldDocument.Factory.parse(slidePart.getInputStream()); + SldDocument.Factory.parse(slidePart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); return slideDoc.getSld(); } @@ -208,7 +209,7 @@ public class XSLFSlideShow extends POIXMLDocument { return null; NotesDocument notesDoc = - NotesDocument.Factory.parse(notesPart.getInputStream()); + NotesDocument.Factory.parse(notesPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); return notesDoc.getNotes(); } @@ -240,7 +241,7 @@ public class XSLFSlideShow extends POIXMLDocument { commentRels.getRelationship(0) ); CmLstDocument commDoc = - CmLstDocument.Factory.parse(cPart.getInputStream()); + CmLstDocument.Factory.parse(cPart.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); return commDoc.getCmLst(); } catch(InvalidFormatException e) { throw new IllegalStateException(e); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java index 3f1563166..7469e25d4 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java @@ -26,6 +26,7 @@ import java.util.List; import javax.xml.namespace.QName; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.sl.usermodel.TableShape; import org.apache.poi.util.Internal; @@ -67,7 +68,7 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable(tblStyleArray.length); for(CTTableStyle c : tblStyleArray){ diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java index 9c34ea55e..88b72602d 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java @@ -27,6 +27,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.Internal; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; @@ -57,7 +58,7 @@ public class XSLFTheme extends POIXMLDocumentPart { public XSLFTheme(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); ThemeDocument doc = - ThemeDocument.Factory.parse(getPackagePart().getInputStream()); + ThemeDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _theme = doc.getTheme(); initialize(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/dev/XSSFDump.java b/src/ooxml/java/org/apache/poi/xssf/dev/XSSFDump.java index a3e04eb24..ecfcca717 100644 --- a/src/ooxml/java/org/apache/poi/xssf/dev/XSSFDump.java +++ b/src/ooxml/java/org/apache/poi/xssf/dev/XSSFDump.java @@ -24,6 +24,7 @@ import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.internal.ZipHelper; import org.apache.poi.util.IOUtils; import org.apache.xmlbeans.XmlObject; @@ -70,7 +71,7 @@ public final class XSSFDump { try { if(entry.getName().endsWith(".xml") || entry.getName().endsWith(".vml") || entry.getName().endsWith(".rels")){ try { - XmlObject xml = XmlObject.Factory.parse(zip.getInputStream(entry)); + XmlObject xml = XmlObject.Factory.parse(zip.getInputStream(entry), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); xml.save(out, options); diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java index 7c250948c..172cf7a3b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java @@ -25,6 +25,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; @@ -208,7 +209,7 @@ public class XSSFReader { } //step 2. Read array of CTSheet elements, wrap it in a ArayList and construct an iterator //Note, using XMLBeans might be expensive, consider refactoring to use SAX or a plain regexp search - CTWorkbook wbBean = WorkbookDocument.Factory.parse(wb.getInputStream()).getWorkbook(); + CTWorkbook wbBean = WorkbookDocument.Factory.parse(wb.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getWorkbook(); sheetIterator = wbBean.getSheets().getSheetList().iterator(); } catch (InvalidFormatException e){ throw new POIXMLException(e); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java b/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java index bcced82bc..855353732 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/CalculationChain.java @@ -25,6 +25,7 @@ import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; /** * The cells in a workbook can be calculated in different orders depending on various optimizations and @@ -47,7 +48,7 @@ public class CalculationChain extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { - CalcChainDocument doc = CalcChainDocument.Factory.parse(is); + CalcChainDocument doc = CalcChainDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); chain = doc.getCalcChain(); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java index 95bbf2907..b9ef88a9f 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java @@ -25,6 +25,7 @@ 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.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment; @@ -55,7 +56,7 @@ public class CommentsTable extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { - CommentsDocument doc = CommentsDocument.Factory.parse(is); + CommentsDocument doc = CommentsDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); comments = doc.getComments(); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java b/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java index c11d51ef9..a96081ef3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/ExternalLinksTable.java @@ -28,6 +28,7 @@ import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalDefinedName; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalLink; @@ -54,7 +55,7 @@ public class ExternalLinksTable extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { - ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is); + ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); link = doc.getExternalLink(); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java b/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java index 33c161b4c..959df17b4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java @@ -27,6 +27,7 @@ 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.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.XSSFMap; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.xmlbeans.XmlException; @@ -68,7 +69,7 @@ public class MapInfo extends POIXMLDocumentPart { @SuppressWarnings("deprecation") public void readFrom(InputStream is) throws IOException { try { - MapInfoDocument doc = MapInfoDocument.Factory.parse(is); + MapInfoDocument doc = MapInfoDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); mapInfo = doc.getMapInfo(); maps= new HashMap(); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java index 420eed7c1..f88172b02 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java @@ -29,6 +29,7 @@ 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.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; @@ -116,7 +117,7 @@ public class SharedStringsTable extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { int cnt = 0; - _sstDoc = SstDocument.Factory.parse(is); + _sstDoc = SstDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); CTSst sst = _sstDoc.getSst(); count = (int)sst.getCount(); uniqueCount = (int)sst.getUniqueCount(); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java b/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java index cb1542e87..effcde544 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java @@ -26,6 +26,7 @@ import java.util.Vector; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.helpers.XSSFSingleXmlCell; import org.apache.xmlbeans.XmlException; @@ -61,7 +62,7 @@ public class SingleXmlCells extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { - SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is); + SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); singleXMLCells = doc.getSingleXmlCells(); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java index a119e457e..aec46b5ab 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.BuiltinFormats; import org.apache.poi.ss.usermodel.FontFamily; import org.apache.poi.ss.usermodel.FontScheme; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.apache.poi.xssf.usermodel.XSSFFactory; import org.apache.poi.xssf.usermodel.XSSFFont; @@ -147,7 +148,7 @@ public class StylesTable extends POIXMLDocumentPart { @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support protected void readFrom(InputStream is) throws IOException { try { - doc = StyleSheetDocument.Factory.parse(is); + doc = StyleSheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); CTStylesheet styleSheet = doc.getStyleSheet(); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java index 539cb1d90..0873f0757 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java @@ -22,6 +22,7 @@ import java.io.OutputStream; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; @@ -80,7 +81,7 @@ public class ThemesTable extends POIXMLDocumentPart { super(part, rel); try { - theme = ThemeDocument.Factory.parse(part.getInputStream()); + theme = ThemeDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch(XmlException e) { throw new IOException(e.getLocalizedMessage(), e); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java index 918a7faf8..37be56189 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java @@ -17,6 +17,7 @@ package org.apache.poi.xssf.usermodel; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.CellStyle; @@ -153,12 +154,12 @@ public class XSSFCellStyle implements CellStyle { // Create a new Xf with the same contents _cellXf = CTXf.Factory.parse( - src.getCoreXf().toString() + src.getCoreXf().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); // bug 56295: ensure that the fills is available and set correctly CTFill fill = CTFill.Factory.parse( - src.getCTFill().toString() + src.getCTFill().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); addFill(fill); @@ -177,7 +178,7 @@ public class XSSFCellStyle implements CellStyle { // Copy the font try { CTFont ctFont = CTFont.Factory.parse( - src.getFont().getCTFont().toString() + src.getFont().getCTFont().toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); XSSFFont font = new XSSFFont(ctFont); font.registerTo(_stylesSource); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java index 0f2179a9d..a31d2e8c1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.usermodel.charts.AxisPosition; import org.apache.poi.ss.usermodel.charts.ChartAxis; import org.apache.poi.ss.usermodel.charts.ChartAxisFactory; import org.apache.poi.ss.usermodel.charts.ChartData; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.Internal; import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis; import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis; @@ -100,7 +101,7 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA protected XSSFChart(PackagePart part, PackageRelationship rel) throws IOException, XmlException { super(part, rel); - chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream()).getChartSpace(); + chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartSpace(); chart = chartSpace.getChart(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java index 1b06370d8..5c8aae3c0 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java @@ -27,6 +27,7 @@ import java.util.Map; import javax.xml.namespace.QName; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; @@ -61,7 +62,7 @@ public class XSSFChartSheet extends XSSFSheet { super.read(new ByteArrayInputStream(BLANK_WORKSHEET)); try { - chartsheet = ChartsheetDocument.Factory.parse(is).getChartsheet(); + chartsheet = ChartsheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getChartsheet(); } catch (XmlException e){ throw new POIXMLException(e); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 728fedf86..d27a96e7c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -66,6 +66,7 @@ import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.SSCellRange; import org.apache.poi.ss.util.SheetUtil; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -193,7 +194,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { protected void read(InputStream is) throws IOException { try { - worksheet = WorksheetDocument.Factory.parse(is).getWorksheet(); + worksheet = WorksheetDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getWorksheet(); } catch (XmlException e){ throw new POIXMLException(e); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java index d228cf951..8cd1e10cd 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -28,6 +28,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.ss.util.CellReference; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.xssf.usermodel.helpers.XSSFXmlColumnPr; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable; @@ -69,7 +70,7 @@ public class XSSFTable extends POIXMLDocumentPart { public void readFrom(InputStream is) throws IOException { try { - TableDocument doc = TableDocument.Factory.parse(is); + TableDocument doc = TableDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); ctTable = doc.getTable(); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java index 75f292fa6..eb249f414 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java @@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.xssf.util.EvilUnclosedBRFixingInputStream; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; @@ -106,7 +107,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { protected void read(InputStream is) throws IOException, XmlException { XmlObject root = XmlObject.Factory.parse( - new EvilUnclosedBRFixingInputStream(is) + new EvilUnclosedBRFixingInputStream(is), POIXMLDocumentPart.DEFAULT_XML_OPTIONS ); _qnames = new ArrayList(); @@ -115,13 +116,13 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { Node nd = obj.getDomNode(); QName qname = new QName(nd.getNamespaceURI(), nd.getLocalName()); if (qname.equals(QNAME_SHAPE_LAYOUT)) { - _items.add(CTShapeLayout.Factory.parse(obj.xmlText())); + _items.add(CTShapeLayout.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS)); } else if (qname.equals(QNAME_SHAPE_TYPE)) { - CTShapetype st = CTShapetype.Factory.parse(obj.xmlText()); + CTShapetype st = CTShapetype.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); _items.add(st); _shapeTypeId = st.getId(); } else if (qname.equals(QNAME_SHAPE)) { - CTShape shape = CTShape.Factory.parse(obj.xmlText()); + CTShape shape = CTShape.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); String id = shape.getId(); if(id != null) { Matcher m = ptrn_shapeId.matcher(id); @@ -129,7 +130,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { } _items.add(shape); } else { - _items.add(XmlObject.Factory.parse(obj.xmlText())); + _items.add(XmlObject.Factory.parse(obj.xmlText(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS)); } _qnames.add(qname); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 0013580e4..a9a277fc2 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -64,6 +64,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.WorkbookUtil; import org.apache.poi.util.Beta; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; @@ -333,7 +334,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { @SuppressWarnings("deprecation") // getXYZArray() array accessors are deprecated protected void onDocumentRead() throws IOException { try { - WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream()); + WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); this.workbook = doc.getWorkbook(); ThemesTable theme = null; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index be206d739..9855e2fda 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -48,6 +48,7 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.apache.poi.util.DocumentHelper; import org.apache.poi.util.IOUtils; import org.apache.poi.util.IdentifierManager; import org.apache.poi.util.Internal; @@ -155,7 +156,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { @Override protected void onDocumentRead() throws IOException { try { - DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream()); + DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); ctDocument = doc.getDocument(); initFootnotes(); @@ -205,7 +206,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { header.onDocumentRead(); } else if (relation.equals(XWPFRelation.COMMENT.getRelation())) { // TODO Create according XWPFComment class, extending POIXMLDocumentPart - CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream()); + CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); for (CTComment ctcomment : cmntdoc.getComments().getCommentArray()) { comments.add(new XWPFComment(ctcomment, this)); } @@ -262,7 +263,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { this.footnotes = (XWPFFootnotes) p; this.footnotes.onDocumentRead(); } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) { - EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); + EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); for (CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) { endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn)); @@ -452,7 +453,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { throw new IllegalStateException("Expecting one Styles document part, but found " + parts.length); } - StylesDocument sd = StylesDocument.Factory.parse(parts[0].getInputStream()); + StylesDocument sd = StylesDocument.Factory.parse(parts[0].getInputStream(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); return sd.getStyles(); } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java index 8ae33260f..eaf28e319 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java @@ -28,6 +28,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; @@ -102,7 +103,7 @@ public class XWPFFooter extends XWPFHeaderFooter { InputStream is; try { is = getPackagePart().getInputStream(); - ftrDocument = FtrDocument.Factory.parse(is); + ftrDocument = FtrDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); headerFooter = ftrDocument.getFtr(); // parse the document with cursor and add // the XmlObject to its lists diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java index c84cab66c..ecdf71d79 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java @@ -31,7 +31,8 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes; @@ -71,7 +72,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart { FootnotesDocument notesDoc; try { InputStream is = getPackagePart().getInputStream(); - notesDoc = FootnotesDocument.Factory.parse(is); + notesDoc = FootnotesDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); ctFootnotes = notesDoc.getFootnotes(); } catch (XmlException e) { throw new POIXMLException(); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java index 2a31247fd..ccba7a00d 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java @@ -28,6 +28,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; @@ -105,7 +106,7 @@ public class XWPFHeader extends XWPFHeaderFooter { InputStream is; try { is = getPackagePart().getInputStream(); - hdrDocument = HdrDocument.Factory.parse(is); + hdrDocument = HdrDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); headerFooter = hdrDocument.getHdr(); // parse the document with cursor and add // the XmlObject to its lists diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java index 842bb4434..a2f03de09 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java @@ -32,6 +32,7 @@ import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum; @@ -75,7 +76,7 @@ public class XWPFNumbering extends POIXMLDocumentPart { InputStream is; is = getPackagePart().getInputStream(); try { - numberingDoc = NumberingDocument.Factory.parse(is); + numberingDoc = NumberingDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); ctNumbering = numberingDoc.getNumbering(); //get any Nums for (CTNum ctNum : ctNumbering.getNumArray()) { diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index b5e465dcb..5fb16060c 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -25,6 +25,7 @@ import java.util.List; import javax.xml.namespace.QName; +import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.util.Internal; @@ -32,50 +33,50 @@ import org.apache.poi.wp.usermodel.CharacterRun; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlString; -import org.apache.xmlbeans.XmlToken; -import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl; -import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; -import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject; -import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData; -import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; -import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D; -import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; -import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture; -import org.openxmlformats.schemas.drawingml.x2006.picture.CTPictureNonVisual; -import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor; -import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFFCheckBox; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedHpsMeasure; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedTwipsMeasure; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTUnderline; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalAlignRun; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrType; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun; -import org.w3c.dom.NodeList; +import org.apache.xmlbeans.XmlString; +import org.apache.xmlbeans.XmlToken; +import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl; +import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; +import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData; +import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; +import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D; +import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; +import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture; +import org.openxmlformats.schemas.drawingml.x2006.picture.CTPictureNonVisual; +import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor; +import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFFCheckBox; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedHpsMeasure; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedTwipsMeasure; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTUnderline; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalAlignRun; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrType; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun; +import org.w3c.dom.NodeList; import org.w3c.dom.Text; /** @@ -175,7 +176,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { if (pict instanceof XmlAnyTypeImpl) { // Pesky XmlBeans bug - see Bugzilla #49934 try { - pict = CTPicture.Factory.parse(pict.toString()); + pict = CTPicture.Factory.parse(pict.toString(), POIXMLDocumentPart.DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new POIXMLException(e); } @@ -945,7 +946,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { "" + "" + ""; - inline.set(XmlToken.Factory.parse(xml)); + inline.set(XmlToken.Factory.parse(xml, POIXMLDocumentPart.DEFAULT_XML_OPTIONS)); // Setup the inline inline.setDistT(0); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java index 30afbb925..1dbc29587 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java @@ -33,6 +33,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocProtect; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; @@ -403,7 +404,7 @@ public class XWPFSettings extends POIXMLDocumentPart { private void readFrom(InputStream inputStream) { try { - ctSettings = SettingsDocument.Factory.parse(inputStream).getSettings(); + ctSettings = SettingsDocument.Factory.parse(inputStream, POIXMLDocumentPart.DEFAULT_XML_OPTIONS).getSettings(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java index ed3960179..3be62b671 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java @@ -31,7 +31,8 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.util.DocumentHelper; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocDefaults; @@ -82,7 +83,7 @@ public class XWPFStyles extends POIXMLDocumentPart { StylesDocument stylesDoc; try { InputStream is = getPackagePart().getInputStream(); - stylesDoc = StylesDocument.Factory.parse(is); + stylesDoc = StylesDocument.Factory.parse(is, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); setStyles(stylesDoc.getStyles()); latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this); } catch (XmlException e) {