From 970d7d7c18a56cddc69756cfe1f0ef55dac05d15 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 24 Feb 2015 12:09:30 +0000 Subject: [PATCH] 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 --- .../apache/poi/xwpf/usermodel/XWPFDocument.java | 2 +- .../poi/xwpf/usermodel/TestXWPFDocument.java | 15 +++++++++++++++ test-data/document/zero-length.docx | Bin 0 -> 10469 bytes 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test-data/document/zero-length.docx 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 0000000000000000000000000000000000000000..eb34b47b1a5f854f785c09ab9a2f6ec4b315c176 GIT binary patch literal 10469 zcmaKS1yEee7A@}X5;Qg5 z)!E%=t=_%6Pwyow2?~Y=1O){Jl-R5+0`!}~zWvs+H88iMqkX@Y$4E(n3cv-NJ);Yq zu9#B=4UXOt3tAE1K>8&gpN@}0GMSXWt_r}k$cAJMw7FcJf0(oweaVte3k?H+5d(p(D_qqH9s+jhdE7{zh4{>X)N~A|4sk_vN^lnZc$gmB>&=et=t-xVA9b zW~Bj;4t+JM#7G2s!e?mLgrP$`)lsO*G zS;P3*Et?%~^jv{ibWEVaD7eU%6+(Pzzm0zcXIp z`PP+L-yr4_VL#1$UVgC#ld5~7;2bNfu2679d?&|U+=7!#M;*kFA?JbYVpHwyJmr29 zgt?109{x3pMOYeQOvw}}u`>N{oAi4hB7($6^@U5^36*(cBbByoMZyIJQ^);UTUPa+ z4EY;%YXoe9d`-Q>EBRlmo|&=5Khd2fe0!1m-k)#^f+nZ1t1XUwft*Uo4zCihVX6v% zc*n~+HUL}rh6V}v-|&9;U%dKOdJYx_miGSzTplz04pjmrA8OmiGhf}#JOfUem{l0ImJxh#tYlIKt`Ptn<(jA0B@Tq_2(KenK@I|F-r z6H6nzcV2`eBoTV(;XVV>h%fO`RL+aVTDL&DfCbI6v%3zUsSUOr;t0$vq9_oEr403Iu&~WacnzTG zcVidVP$i<(_1o5>CK6$u%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