aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2010-09-14 11:34:33 +0000
committerNick Burch <nick@apache.org>2010-09-14 11:34:33 +0000
commitdb4de8a4f38b5be6a3baddb63f45d89e8726e147 (patch)
tree24719018edf88be084769049c5ea92aa212ca5b7
parent0a3ac7d1e3da6990edc22bca36bbd8bd7c11d9dc (diff)
downloadpoi-db4de8a4f38b5be6a3baddb63f45d89e8726e147.tar.gz
poi-db4de8a4f38b5be6a3baddb63f45d89e8726e147.zip
Add a getBodyElements() method to XWPF IBody, to make access to embedded paragraphs and tables easier, and a few tidy-ups
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@996849 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java1
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java6
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java1
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java9
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java3
8 files changed, 30 insertions, 2 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index b230d40b1e..a0fc2a0159 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -34,6 +34,7 @@
<changes>
<release version="3.7-beta3" date="2010-??-??">
+ <action dev="poi-developers" type="add">Add a getBodyElements() method to XWPF IBody, to make access to embedded paragraphs and tables easier</action>
<action dev="poi-developers" type="add">More XSLFRelation entries for common .pptx file parts</action>
<action dev="poi-developers" type="fix">49872 - avoid exception in XSSFFormulaEvaluator.evaluateInCell when evaluating shared formulas</action>
<action dev="poi-developers" type="fix">49895 - avoid corruption of XSSFWorkbook after removing all merged cells from sheet</action>
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
index c42fde7d18..8f3aa9f7d0 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
@@ -50,6 +50,13 @@ public interface IBody {
* @return
*/
BodyType getPartType();
+
+ /**
+ * Returns an Iterator with paragraphs and tables,
+ * in the order that they occur in the text.
+ */
+ public List<IBodyElement> getBodyElements();
+
/**
* Returns the paragraph(s) that holds
* the text of the header or footer.
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 9f1acbbea7..bc773132ef 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -52,7 +52,6 @@ import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
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 fe24efcd34..5088eaee6f 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
@@ -70,6 +70,10 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
return headerFooter;
}
+ public List<IBodyElement> getBodyElements(){
+ return Collections.unmodifiableList(bodyElements);
+ }
+
/**
* Returns the paragraph(s) that holds
* the text of the header or footer.
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java
index 9de4eecdad..43fae3ac42 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java
@@ -129,6 +129,12 @@ public class XWPFStyle {
return null;
}
+ public String getName() {
+ if(ctStyle.isSetName())
+ return ctStyle.getName().getVal();
+ return null;
+ }
+
/**
* compares the names of the Styles
* @param compStyle
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
index 79262b2ddd..4927f321b0 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
@@ -46,7 +46,6 @@ public class XWPFTable implements IBodyElement{
protected List<XWPFTableRow> tableRows;
protected List<String> styleIDs;
protected IBody part;
- private XWPFDocument document;
public XWPFTable(CTTbl table, IBody part, int row, int col) {
this(table, part);
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
index 33adec4901..2497d801a9 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
@@ -74,6 +74,15 @@ public class XWPFTableCell implements IBody {
return ctTc;
}
+ /**
+ * returns an Iterator with paragraphs and tables
+ * @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements()
+ * @return
+ */
+ public List<IBodyElement> getBodyElements(){
+ return Collections.unmodifiableList(bodyElements);
+ }
+
public void setParagraph(XWPFParagraph p) {
if (ctTc.sizeOfPArray() == 0) {
ctTc.addNewP();
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
index bf82b7ce9c..ac7e4f7a5c 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
@@ -236,6 +236,9 @@ public final class TestXWPFParagraph extends TestCase {
assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray());
CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0);
assertEquals("poi", ctBookmark.getName());
+ for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) {
+ assertEquals("poi", bookmark.getName());
+ }
}
public void testGetSetNumID() {