]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51111 - Correct XWPFParagraph tracking of new runs
authorNick Burch <nick@apache.org>
Tue, 3 May 2011 05:50:25 +0000 (05:50 +0000)
committerNick Burch <nick@apache.org>
Tue, 3 May 2011 05:50:25 +0000 (05:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1098920 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java

index 6280db36ad7db80f82b28e1c8762e58634f57568..b81681a103faa7c7717922764cd61eb4e822d31b 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta3" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51111 - Correct XWPFParagraph tracking of new runs</action>
            <action dev="poi-developers" type="fix">51115 - Handle DataFormatter escaping of "." in the same way as "-" and "/"</action>
            <action dev="poi-developers" type="fix">51100 - Fix IOUtils issue for NPOIFS reading from an InputStream where every block is full</action>
            <action dev="poi-developers" type="fix">50956 - Correct XSSF cell style cloning between workbooks</action>
index 2833695e923723d3bc312002505c568c17dbcd7e..a4cccccabe45ebfdc49265e829f18adbfc298e04 100644 (file)
@@ -260,7 +260,9 @@ public class XWPFParagraph implements IBodyElement{
      * @return a new text run
      */
     public XWPFRun createRun() {
-        return new XWPFRun(paragraph.addNewR(), this);
+       XWPFRun run = new XWPFRun(paragraph.addNewR(), this);
+       runs.add(run);
+       return run;
     }
 
     /**
index 6bf3c03ff0a5d92da088efae2e5ea4fff4a389ce..0fa1b92ba03a79bc6cd1aefe004c76579035c972 100644 (file)
@@ -252,6 +252,16 @@ public final class TestXWPFParagraph extends TestCase {
         assertEquals("10", p.getNumID().toString());
     }
     
+    public void testAddingRuns() throws Exception {
+       XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
+     
+       XWPFParagraph p = doc.getParagraphs().get(0);
+       assertEquals(2, p.getRuns().size());
+       
+       XWPFRun r = p.createRun();
+       assertEquals(3, p.getRuns().size());
+    }
+    
     public void testPictures() throws Exception {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("VariousPictures.docx");
        assertEquals(7, doc.getParagraphs().size());