poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1241398 - /poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
Date Tue, 07 Feb 2012 09:48:22 GMT
Author: yegor
Date: Tue Feb  7 09:48:22 2012
New Revision: 1241398

URL: http://svn.apache.org/viewvc?rev=1241398&view=rev
Log:
Bugzilla 52570: misc fixes in XWPFDocument

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=1241398&r1=1241397&r2=1241398&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Tue Feb  7 09:48:22
2012
@@ -302,6 +302,10 @@ public class XWPFDocument extends POIXML
     	return Collections.unmodifiableList(bodyElements);
     }
     
+    public Iterator<IBodyElement> getBodyElementsIterator() {
+    	return bodyElements.iterator();
+    }
+
     /**
 	 * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs()
      */
@@ -492,7 +496,7 @@ public class XWPFDocument extends POIXML
     }
     
     /**
-     * Look up the paragraph at the specified position in the body elemnts list
+     * Look up the paragraph at the specified position in the body elements list
      * and return this paragraphs position in the paragraphs list
      * 
      * @param pos
@@ -604,7 +608,6 @@ public class XWPFDocument extends POIXML
             cursor.toParent();
             CTTbl t = (CTTbl) cursor.getObject();
             XWPFTable newT = new XWPFTable(t, this);
-            cursor.removeXmlContents();
             XmlObject o = null;
             while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) {
                 o = cursor.getObject();
@@ -616,17 +619,23 @@ public class XWPFDocument extends POIXML
                 tables.add(pos, newT);
             }
             int i = 0;
-            cursor = t.newCursor();
+            XmlCursor tableCursor = t.newCursor();
+            try {
+                cursor.toCursor(tableCursor);
             while (cursor.toPrevSibling()) {
                 o = cursor.getObject();
                 if (o instanceof CTP || o instanceof CTTbl)
                     i++;
             }
             bodyElements.add(i, newT);
-            cursor = t.newCursor();
+            	cursor.toCursor(tableCursor);
             cursor.toEndToken();
             return newT;
         }
+            finally {
+            	tableCursor.dispose();
+            }
+        }
         return null;
     }
 
@@ -1317,7 +1326,7 @@ public class XWPFDocument extends POIXML
 			return null;
 		}
 		XWPFTableRow tableRow = table.getRow(row);
-		if(row == null){
+		if (tableRow == null) {
 			return null;
 		}
 		return tableRow.getTableCell(cell);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message