for (int row=0; row<rows; row++) {\r
for (int col=0; col<cols; col++) {\r
TableCell<?,?> tc = ts.getCell(row, col);\r
- DrawTextShape dts = df.getDrawable(tc);\r
- dts.drawContent(graphics);\r
+ if (tc != null) {\r
+ DrawTextShape dts = df.getDrawable(tc);\r
+ dts.drawContent(graphics);\r
+ }\r
}\r
}\r
}\r
* @param args the border attributes\r
*/\r
private static void setEdges(TableCell<?,?> cell, BorderEdge edges[], Object... args) {\r
+ if (cell == null) {\r
+ return;\r
+ }\r
for (BorderEdge be : edges) {\r
if (be != null) {\r
if (args.length == 0) {\r
double maxHeight = 0;\r
for (int col=0; col<cols; col++) {\r
XSLFTableCell tc = getCell(row, col);\r
- if (tc.getGridSpan() != 1 || tc.getRowSpan() != 1) {\r
+ if (tc == null || tc.getGridSpan() != 1 || tc.getRowSpan() != 1) {\r
continue;\r
}\r
// need to set the anchor before height calculation\r
for (int col=0; col<cols; col++) {\r
Rectangle2D bounds = new Rectangle2D.Double(newX, newY, colWidths[col], rowHeights[row]);\r
XSLFTableCell tc = getCell(row, col);\r
- tc.setAnchor(bounds);\r
- newX += colWidths[col]+DrawTableShape.borderSize;\r
+ if (tc != null) {\r
+ tc.setAnchor(bounds);\r
+ newX += colWidths[col]+DrawTableShape.borderSize;\r
+ }\r
}\r
newY += rowHeights[row]+DrawTableShape.borderSize;\r
}\r
for (int row=0; row<rows; row++) {\r
for (int col=0; col<cols; col++) {\r
XSLFTableCell tc = getCell(row, col);\r
+ if (tc == null) {\r
+ continue;\r
+ }\r
Rectangle2D mergedBounds = tc.getAnchor();\r
for (int col2=col+1; col2<col+tc.getGridSpan(); col2++) {\r
assert(col2 < cols);\r
int col = 0;\r
for (TextDirection td : tds) {\r
TableCell<?,?> c = tbl1.getCell(0, col++);\r
- c.setTextDirection(td);\r
- c.setText("bla");\r
+ if (c != null) {\r
+ c.setTextDirection(td);\r
+ c.setText("bla");\r
+ }\r
}\r
\r
ByteArrayOutputStream bos = new ByteArrayOutputStream();\r
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
+import org.apache.poi.xslf.usermodel.XSLFTable;
+import org.apache.poi.xslf.usermodel.XSLFTableCell;
+import org.apache.poi.xslf.usermodel.XSLFTableRow;
+import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.poi.xslf.usermodel.XSLFTextRun;
import org.junit.Ignore;
import org.junit.Test;
rwPptx.close();
ppt.close();
}
-}
+
+
+ @Test
+ public void bug60373() throws IOException {
+ XMLSlideShow ppt = new XMLSlideShow();
+ XSLFSlide sl = ppt.createSlide();
+ XSLFTable t = sl.createTable();
+ XSLFTableRow r = t.addRow();
+ bug60373_addCell(r);
+ bug60373_addCell(r);
+ r = t.addRow();
+ XSLFTableCell c = bug60373_addCell(r);
+ // call getTextHeight, when table is not fully populated
+ double th = c.getTextHeight();
+ assertTrue(th > 10);
+ ppt.close();
+ }
+
+ private static XSLFTableCell bug60373_addCell(XSLFTableRow r) {
+ XSLFTableCell cell = r.addCell();
+ XSLFTextParagraph p = cell.addNewTextParagraph();
+ XSLFTextRun tr = p.addNewTextRun();
+ tr.setText("t");
+ return cell;
+ }
+
+}
\ No newline at end of file