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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63624] Bug in XWPFTableCell.setText()

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

Dominik Stadler <[hidden email]> changed:

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

--- Comment #1 from Dominik Stadler <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63624] Bug in XWPFTableCell.setText()

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

--- Comment #2 from [hidden email] ---
(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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

Dominik Stadler <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

iseletkov <[hidden email]> changed:

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

--- Comment #3 from iseletkov <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

--- Comment #4 from PJ Fanning <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63624

Dominik Stadler <[hidden email]> changed:

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

--- Comment #5 from Dominik Stadler <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]