]> source.dussan.org Git - poi.git/commitdiff
Add a getBodyElements() method to XWPF IBody, to make access to embedded paragraphs...
authorNick Burch <nick@apache.org>
Tue, 14 Sep 2010 11:34:33 +0000 (11:34 +0000)
committerNick Burch <nick@apache.org>
Tue, 14 Sep 2010 11:34:33 +0000 (11:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@996849 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java

index b230d40b1ea2ecae755317f32e91415a11afe634..a0fc2a0159ba6334e327c69286fc2a6c497a74cd 100644 (file)
@@ -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>
index c42fde7d183e62fd606f880651848899732d0536..8f3aa9f7d0c90ebf3949a5c6cbf2752ba878d365 100644 (file)
@@ -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.
index 9f1acbbea7fe9aa4952804e7d19ebbb46217e347..bc773132efe8fc760acbefa5fe43045c4924fe9b 100644 (file)
@@ -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;
index fe24efcd34609a8bb3eac2bb47bb5e88f1f9a38c..5088eaee6f84fd7132e06e92f75d82e3b2ee9c70 100644 (file)
@@ -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.
index 9de4eecdad62ab6df3287a7a9cd5ada93f279123..43fae3ac42797fafd4346b7db1785c4421918151 100644 (file)
@@ -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
index 79262b2ddd0eafe2cb7973a8ddbb14b5033d000b..4927f321b011b7b2fec8670639663123b2e55a5e 100644 (file)
@@ -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);
index 33adec49011dd5bf695430febcbf4ce3c6a03575..2497d801a956acc15f0f15f8d91147508c3abb91 100644 (file)
@@ -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();
index bf82b7ce9c53354f9ab50d3e91f877ab5421130e..ac7e4f7a5c3d4f8619ad0766894924053255a723 100644 (file)
@@ -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() {