From de3eb33bd375d03c3b833be2a96518c56e85da56 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sat, 9 Aug 2008 12:15:32 +0000 Subject: [PATCH] Improve how XWPFParagraph works, so it is child order aware git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@684239 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xwpf/XWPFDocument.java | 8 +- .../poi/xwpf/usermodel/XWPFHeaderFooter.java | 35 +++++++ .../poi/xwpf/usermodel/XWPFParagraph.java | 34 +++++-- .../poi/xwpf/usermodel/TestXWPFParagraph.java | 96 +++++++++++++++++++ 4 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java diff --git a/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java index d53cfa576..6b25a42b9 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/XWPFDocument.java @@ -159,10 +159,14 @@ public class XWPFDocument extends POIXMLDocument { return wordDoc.getDocument(); } - public Iterator getParagraphsIterator() - { + public Iterator getParagraphsIterator() { return paragraphs.iterator(); } + public XWPFParagraph[] getParagraphs() { + return paragraphs.toArray( + new XWPFParagraph[paragraphs.size()] + ); + } public Iterator getTablesIterator() { diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index 4b1325f18..7150014e2 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -30,4 +30,39 @@ public abstract class XWPFHeaderFooter { protected XWPFHeaderFooter() { headerFooter = CTHdrFtr.Factory.newInstance(); } + + public CTHdrFtr _getHdrFtr() { + return headerFooter; + } + + /** + * Returns the paragraph(s) that holds + * the text of the header or footer. + * Normally there is only the one paragraph, but + * there could be more in certain cases. + */ + public XWPFParagraph[] getParagraphs() { + XWPFParagraph[] paras = + new XWPFParagraph[headerFooter.getPArray().length]; + for(int i=0; i