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
This commit is contained in:
parent
bc37e5bf28
commit
77f5742c75
@ -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>
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user