Skip to content

Commit

Permalink
#837 Modified PdfPTable add cell method to return cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybob007 committed Oct 30, 2022
1 parent ee6099f commit 9d35857
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public PdfPCell getDefaultCell() {
*
* @param cell the cell element
*/
public void addCell(PdfPCell cell) {
public PdfPCell addCell(PdfPCell cell) {
rowCompleted = false;
PdfPCell ncell = new PdfPCell(cell);

Expand Down Expand Up @@ -499,6 +499,8 @@ public void addCell(PdfPCell cell) {
currentRow[currentRowIdx] = ncell;
currentRowIdx += colspan;
}

return ncell;
}

/**
Expand Down Expand Up @@ -579,19 +581,20 @@ boolean rowSpanAbove(int currRow, int currCol) {
*
* @param text the text for the cell
*/
public void addCell(String text) {
addCell(new Phrase(text));
public PdfPCell addCell(String text) {
return addCell(new Phrase(text));
}

/**
* Adds a nested table.
*
* @param table the table to be added to the cell
*/
public void addCell(PdfPTable table) {
public PdfPCell addCell(PdfPTable table) {
defaultCell.setTable(table);
addCell(defaultCell);
defaultCell.setTable(null);
return defaultCell;
}

/**
Expand All @@ -600,21 +603,23 @@ public void addCell(PdfPTable table) {
* @param image the <CODE>Image</CODE> to add to the table.
* This image will fit in the cell
*/
public void addCell(Image image) {
public PdfPCell addCell(Image image) {
defaultCell.setImage(image);
addCell(defaultCell);
defaultCell.setImage(null);
return defaultCell;
}

/**
* Adds a cell element.
*
* @param phrase the <CODE>Phrase</CODE> to be added to the cell
*/
public void addCell(Phrase phrase) {
public PdfPCell addCell(Phrase phrase) {
defaultCell.setPhrase(phrase);
addCell(defaultCell);
defaultCell.setPhrase(null);
return defaultCell;
}

/**
Expand Down

0 comments on commit 9d35857

Please sign in to comment.