From b9e791ac99a847677f476a5500691695dd27c628 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 5 Oct 2011 21:26:49 +0000 Subject: [PATCH] Fix bug #51950 - XWPF may not always have footnotes in a document git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1179449 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../org/apache/poi/xwpf/usermodel/XWPFDocument.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index cb49fb56ab..b391783ff2 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 51950 - XWPF fix for footnotes not always being present in a document 51963 - Correct AreaReference handling of references containing a sheet name which includes a comma 51955 - XSSFReader supplied StylesTables need to have the theme data available 51716 - Removed incorrect assert in SXSSFSheet#getSXSSFSheet 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 231103ed55..c7d37d1bc5 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -351,15 +351,20 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } public XWPFFootnote getFootnoteByID(int id) { - return footnotes.getFootnoteById(id); + if(footnotes == null) return null; + return footnotes.getFootnoteById(id); } public XWPFFootnote getEndnoteByID(int id) { - return endnotes.get(id); + if(endnotes == null) return null; + return endnotes.get(id); } public List getFootnotes() { - return footnotes.getFootnotesList(); + if(footnotes == null) { + return Collections.emptyList(); + } + return footnotes.getFootnotesList(); } public XWPFHyperlink[] getHyperlinks() {