You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/08/02 03:03:19 UTC

[Bug 63624] New: Bug in XWPFTableCell.setText()

https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

            Bug ID: 63624
           Summary: Bug in XWPFTableCell.setText()
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
          Assignee: dev@poi.apache.org
          Reporter: canbingzt@gmail.com
  Target Milestone: ---

If the cell has no paragraph, call XWPFTableCell.setText() , then call
XWPFTableCell.getText(), the result is empty.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] Bug in XWPFTableCell.setText()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

--- Comment #2 from canbingzt@gmail.com ---
(In reply to Dominik Stadler from comment #1)
> Can you provide some self-sufficient source code which reproduces this
> problem so it is easier for others to take a look?

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(); //actual is empty
Assert.assertEquals(expected, actual);


//under code work well
XWPFParagraph p;
if (cell.getParagraphs() == null || cell.getParagraphs().size() == 0) {
    p = cell.addParagraph();
} else {
    p = cell.getParagraphArray(0);
}
p.createRun().setText(text, 0);

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] Bug in XWPFTableCell.setText()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
                 OS|                            |All

--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Can you provide some self-sufficient source code which reproduces this problem
so it is easier for others to take a look?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Bug in                      |XWPFTableCell.setText()
                   |XWPFTableCell.setText()     |returns empty when no
                   |                            |paragraph is created

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
I did a quick test and it seems to be fixed now, therefore closing this for
now.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

--- Comment #4 from PJ Fanning <fa...@yahoo.com> ---
Hi iseletkov,

Alain Bearez appears to have added a fix on March 27th. Could you try the
latest POI code?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |66988


Referenced Bugs:

https://bz.apache.org/bugzilla/show_bug.cgi?id=66988
[Bug 66988] cell.setText(String) only appends text
-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

--- Comment #6 from PJ Fanning <fa...@yahoo.com> ---
https://bz.apache.org/bugzilla/show_bug.cgi?id=66988 changes the behaviour to
make setText replace the text and adds a new appendText to append.

66988 will be part of POI 5.2.4.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63624] XWPFTableCell.setText() returns empty when no paragraph is created

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

iseletkov <is...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from iseletkov <is...@gmail.com> ---
Method setText() does not add new paragraph to "paragraphs" list, while
getText() uses info from "paragraphs" only.

public void setText(String text) {
        CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() :
ctTc.getPArray(0);
        XWPFParagraph par = new XWPFParagraph(ctP, this);
        par.createRun().setText(text);
    }

public String getText() {
        StringBuilder text = new StringBuilder();
        for (XWPFParagraph p : paragraphs) {
            text.append(p.getText());
        }
        return text.toString();
    } 

I think new line is needed in line 433:
paragraphs.add(par);

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org