From: Nick Burch Date: Tue, 24 Feb 2015 12:09:30 +0000 (+0000) Subject: Patch from rojotek from github-18 - Handle documents with a picture-only header X-Git-Tag: REL_3_12_FINAL~106 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=970d7d7c18a56cddc69756cfe1f0ef55dac05d15;p=poi.git Patch from rojotek from github-18 - Handle documents with a picture-only header git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1661908 13f79535-47bb-0310-9956-ffa450edef68 --- 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 9adc397048..6a28db2a87 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -92,7 +92,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { /** * Keeps track on all id-values used in this document and included parts, like headers, footers, etc. */ - private IdentifierManager drawingIdManager = new IdentifierManager(1L,4294967295L); + private IdentifierManager drawingIdManager = new IdentifierManager(0L,4294967295L); protected List footers = new ArrayList(); protected List headers = new ArrayList(); protected List comments = new ArrayList(); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java index 7621404b8d..85da27b9e6 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java @@ -337,6 +337,21 @@ public final class TestXWPFDocument extends TestCase { doc.getPackage().revert(); } + public void testZeroLengthLibreOfficeDocumentWithWaterMarkHeader() throws IOException { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("zero-length.docx"); + POIXMLProperties properties = doc.getProperties(); + + assertNotNull(properties.getCoreProperties()); + + XWPFHeader headerArray = doc.getHeaderArray(0); + assertEquals(1, headerArray.getAllPictures().size()); + assertEquals("image1.png", headerArray.pictures.get(0).getFileName()); + assertEquals("", headerArray.getText()); + + POIXMLProperties.ExtendedProperties extendedProperties = properties.getExtendedProperties(); + assertNotNull(extendedProperties); + assertEquals(0, extendedProperties.getUnderlyingProperties().getCharacters()); + } public void testSettings(){ XWPFSettings settings = new XWPFSettings(); diff --git a/test-data/document/zero-length.docx b/test-data/document/zero-length.docx new file mode 100644 index 0000000000..eb34b47b1a Binary files /dev/null and b/test-data/document/zero-length.docx differ