Browse Source

#63624: setText in XWPFTableCell updates the xml and also updates the runs and iruns

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1875744 13f79535-47bb-0310-9956-ffa450edef68
tags/before_ooxml_3rd_edition
Alain Béarez 4 years ago
parent
commit
31f5443674

+ 1
- 2
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java View File

@@ -427,8 +427,7 @@ public class XWPFTableCell implements IBody, ICell {
}

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);
}


+ 14
- 0
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java View File

@@ -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();
}
}

Loading…
Cancel
Save