Bug 47147 - XWPFTableCell.getCell() creates an unecessary Paragraph
Summary: XWPFTableCell.getCell() creates an unecessary Paragraph
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.5-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-04 06:15 UTC by luzifer
Modified: 2011-05-27 14:48 UTC (History)
0 users



Attachments
Fix issues with "setText". (3.03 KB, application/octet-stream)
2011-05-06 13:11 UTC, Stefan Stern
Details

Note You need to log in before you can comment on or make changes to this bug.
Description luzifer 2009-05-04 06:15:05 UTC
XWPFTable table = doc.createTable(1,3);
XWPFTableRow row = table.getRow(0);
XWPFTableCell cell = row.getCell(1);
cell = row.getCell(1);
cell = row.getCell(1);
cell = row.getCell(1);
cell = row.getCell(1);
cell = row.getCell(1);
cell.setText("text");

The resulting cell will have mutltiple parapgraphs. 
But only one should be there with the specified text.

The first cell of the table has a similar bug. createTable adds an unecessary paragraph too.
Comment 1 Stefan Stern 2011-05-06 11:31:30 UTC
Patch in progress, coming soon.
Comment 2 Stefan Stern 2011-05-06 13:11:09 UTC
Created attachment 26963 [details]
Fix issues with "setText".

Looking into the ECM-576 specification, an empty cell always comes with an empty paragraph. Or, to use Word as reference, create an empty Word DOCX document, add a table with 2 rows and 2 coloums, save the document and look into the XML. You'll see that Word creates an empty Paragraph for each Cell. 

What was wrong in the XWPFCell class was the "setText" method. Fixed this method and another bug in the contructor. There every row created was added to the "rows" field twice. Once in "createRow" method and afterwards in the constructor.
Comment 3 Nick Burch 2011-05-27 14:48:09 UTC
Thanks, applied with tweaks in r1128331.