poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1675738 - in /poi/trunk/src/ooxml: java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java
Date Fri, 24 Apr 2015 01:29:11 GMT
Author: nick
Date: Fri Apr 24 01:29:10 2015
New Revision: 1675738

URL: http://svn.apache.org/r1675738
Log:
#57829 Avoid XmlValueDisconnectedException when removing a XWPFRun from a XWPFParagraph by
removing from IRuns as well

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1675738&r1=1675737&r2=1675738&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Fri Apr 24 01:29:10
2015
@@ -1369,8 +1369,12 @@ public class XWPFParagraph implements IB
      */
     public boolean removeRun(int pos){
         if (pos >= 0 && pos < paragraph.sizeOfRArray()) {
-            getCTP().removeR(pos);
+            // Remove the run from our high level lists
+            XWPFRun run = runs.get(pos);
             runs.remove(pos);
+            iruns.remove(run);
+            // Remove the run from the low-level XML
+            getCTP().removeR(pos);
             return true;
         }
         return false;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java?rev=1675738&r1=1675737&r2=1675738&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java Fri Apr
24 01:29:10 2015
@@ -88,4 +88,19 @@ public class TestXWPFBugs {
         XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("56392.docx");
     	assertNotNull(doc);
     }
+    
+    /**
+     * Removing a run needs to remove it from both Runs and IRuns
+     */
+    @Test
+    public void test57829() throws Exception {
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
+        assertNotNull(doc);
+        assertEquals(3, doc.getParagraphs().size());
+        
+        for (XWPFParagraph paragraph : doc.getParagraphs()) {
+            paragraph.removeRun(0);
+            assertNotNull(paragraph.getText());
+        }
+    }
 }



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


Mime
View raw message