poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abea...@apache.org
Subject svn commit: r1875744 - in /poi/trunk/src/ooxml: java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java
Date Fri, 27 Mar 2020 03:13:31 GMT
Author: abearez
Date: Fri Mar 27 03:13:31 2020
New Revision: 1875744

URL: http://svn.apache.org/viewvc?rev=1875744&view=rev
Log:
#63624: setText in XWPFTableCell updates the xml and also updates the runs and iruns

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java?rev=1875744&r1=1875743&r2=1875744&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java Fri Mar 27 03:13:31
2020
@@ -427,8 +427,7 @@ public class XWPFTableCell implements IB
     }
 
     public void setText(String text) {
-        CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() : ctTc.getPArray(0);
-        XWPFParagraph par = new XWPFParagraph(ctP, this);
+        XWPFParagraph par = (paragraphs.size() == 0) ? addParagraph() : paragraphs.get(0);
         par.createRun().setText(text);
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java?rev=1875744&r1=1875743&r2=1875744&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java Fri
Mar 27 03:13:31 2020
@@ -149,4 +149,18 @@ public class TestXWPFTableCell {
         assertEquals(2500, cell.getWidth());
         doc.close();
     }
+
+    @Test
+    public void testBug63624() throws Exception {
+        XWPFDocument doc = new XWPFDocument();
+        XWPFTable table = doc.createTable(1, 1);
+        XWPFTableRow row = table.getRow(0);
+        XWPFTableCell cell = row.getCell(0);
+
+        String expected = "this must not be empty";
+        cell.setText(expected);
+        String actual = cell.getText();
+        assertEquals(expected, actual);
+        doc.close();
+    }
 }



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


Mime
View raw message