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
This commit is contained in:
Nick Burch 2015-02-24 12:09:30 +00:00
parent d5065b1742
commit b6a88f09c8
3 changed files with 16 additions and 1 deletions

View File

@ -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. * 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<XWPFFooter> footers = new ArrayList<XWPFFooter>(); protected List<XWPFFooter> footers = new ArrayList<XWPFFooter>();
protected List<XWPFHeader> headers = new ArrayList<XWPFHeader>(); protected List<XWPFHeader> headers = new ArrayList<XWPFHeader>();
protected List<XWPFComment> comments = new ArrayList<XWPFComment>(); protected List<XWPFComment> comments = new ArrayList<XWPFComment>();

View File

@ -337,6 +337,21 @@ public final class TestXWPFDocument extends TestCase {
doc.getPackage().revert(); 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(){ public void testSettings(){
XWPFSettings settings = new XWPFSettings(); XWPFSettings settings = new XWPFSettings();

Binary file not shown.