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 9adc39704..6a28db2a8 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 7621404b8..85da27b9e 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 000000000..eb34b47b1 Binary files /dev/null and b/test-data/document/zero-length.docx differ