XWPFParagraph setters and need to check for PPr?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

XWPFParagraph setters and need to check for PPr?

Hannes Erven-2

I've downloaded POI 4.1.1 and am trying to keep some paragraphs of a
Word document together.

For a "regular" paragraph, this is fairly easy:

My document also has a table with several rows, and I would also like to
keep some of those together. But:
        XWPFTable table = document.createTable(3, 2);
        XWPFTableRow row = table.getRow(0);
        XWPFParagraph p0 = row.getCell(0).getParagraphArray(0);

throws a NullPointerException in XWPFParagraph line 426.

Looking at the sources, getCTP().getPPR() is null. When I insert these
lines just before setKeepNext():

        CTP ctP = p0.getCTP();
        if (! ctP.isSetPPr()) ctP.addNewPPr();

... it works.

Is this expected?

Thank you very much,
best regards


To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]